Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions apps/spotlight/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from typing import Dict


AWS_REGION = os.environ["AWS_REGION"]
AWS_ACCESS_KEY_ID = os.environ["AWS_ACCESS_KEY_ID"]
AWS_SECRET_ACCESS_KEY = os.environ["AWS_SECRET_ACCESS_KEY"]
AWS_REGION = os.environ.get("AWS_REGION")
AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID")
AWS_SECRET_ACCESS_KEY = os.environ.get("AWS_SECRET_ACCESS_KEY")

OPENAI_API_KEY = os.environ["OPENAI_API_KEY"]
KNOWLEDGE_BASE_ID = os.environ["KNOWLEDGE_BASE_ID"]
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
KNOWLEDGE_BASE_ID = os.environ.get("KNOWLEDGE_BASE_ID")


bedrock_session = boto3.Session(
Expand All @@ -37,7 +37,7 @@ def get_openai_response(*, system_prompt: str) -> dict:
{"role": "system", "content": system_prompt}
],
temperature=0,
max_tokens=256,
max_tokens=1000,
top_p=0,
frequency_penalty=0,
presence_penalty=0
Expand Down
25 changes: 25 additions & 0 deletions apps/spotlight/migrations/0002_copyexportsettings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.1.14 on 2024-09-12 20:38

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('spotlight', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='CopyExportSettings',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('workspace_id', models.IntegerField(help_text='Workspace id of the organization')),
('reimbursable_export_setting', models.JSONField(null=True)),
('ccc_export_setting', models.JSONField(null=True)),
],
options={
'db_table': 'copy_export_settings',
},
),
]
9 changes: 9 additions & 0 deletions apps/spotlight/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ class Query(models.Model):

class Meta:
db_table = 'queries'

class CopyExportSettings(models.Model):

workspace_id = models.IntegerField(help_text="Workspace id of the organization")
reimbursable_export_setting = models.JSONField(null=True)
ccc_export_setting = models.JSONField(null=True)

class Meta:
db_table = 'copy_export_settings'
898 changes: 580 additions & 318 deletions apps/spotlight/prompts/spotlight_prompt.py

Large diffs are not rendered by default.

175 changes: 175 additions & 0 deletions apps/spotlight/prompts/suggestion_context_page_prompt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
SUGGESTION_PROMPT = """

Objectives:
You are a AI agent that suggests what actions and features
we provide for a specific page. You will get the user input at the end.

Instructions:
These are the pages and their corresponding actions we provide, you will get the
URL as input and you have to reply the actions list:
Output should be in JSON format.


1. For /dashboard
Output:
{{
"suggestions": {{
"actions": [
{{
"code": "trigger_export",
"title": "Export IIF file",
"description": "Export the current data to an IIF file."
}}
]
}}
}}


2. For /export_settings
Output:
{{
"suggestions": {{
"actions": [
{{
"code": "enable_reimbursable_expenses_export",
"title": "Enable reimbursable export settings",
"description": "Enable the option to export reimbursable expenses in Export Configuration."
}},
{{
"code": "disable_reimbursable_expenses_export",
"title": "Disable reimbursable export settings",
"description": "Disable the option to export reimbursable expenses in Export Configuration."
}},
{{
"code": "set_reimbursable_expenses_export_module_bill",
"title": "Select reimbursable export module as bill",
"description": "Choose Bill as the type of transaction in QuickBooks Desktop to export your Fyle expenses."
}},
{{
"code": "set_reimbursable_expenses_export_module_journal_entry",
"title": "Select reimbursable export module as journal entry",
"description": "Choose Journal Entry as the type of transaction in QuickBooks Desktop to export your Fyle expenses."
}},
{{
"code": "set_reimbursable_expenses_export_grouping_expense"
"title": "Group reimbursable expenses export by expense",
"description": "Set grouping to expense, this grouping reflects how the expense entries are posted in QuickBooks Desktop."
}},
{{
"code": "set_reimbursable_expenses_export_grouping_report",
"title": "Group reimbursable expenses export by report",
"description": "Set grouping to expense_report, this grouping reflects how the expense entries are posted in QuickBooks Desktop."
}},
{{
"code": "set_reimbursable_expenses_export_state_processing",
"title": "Set reimbursable expenses export state as processing",
"description": "You could choose to export expenses when they have been approved and are awaiting payment clearance."
}},
{{
"code": "set_reimbursable_expenses_export_state_paid",
"title": "Set reimbursable expenses export state as paid",
"description": "You could choose to export expenses when they have been paid out."
}},
{{
"code": "enable_corporate_card_expenses_export",
"title": "Enable option corporate card expenses export",
"description": "Enable the option to export of credit card expenses from Fyle to QuickBooks Desktop."
}},
{{
"code": "disable_corporate_card_expenses_export",
"title": "Disable reimbursable export settings",
"description": "Disable the option to export of credit card expenses from Fyle to QuickBooks Desktop."
}},
{{
"code": "set_corporate_credit_card_expenses_export_credit_card_purchase",
"title": "Set Credit Card Purchase transaction type to export",
"description": "Credit Card Purchase type of transaction in QuickBooks Desktop to be export as Fyle expenses."
}},
{{
"code": "set_corporate_credit_card_expenses_export_journal_entry",
"title": "Set Journal Entry transaction type to export",
"description": "Journal Entry type of transaction in QuickBooks Desktop to be export as Fyle expenses."
}},
{{
"code": "set_corporate_credit_card_expenses_purchased_from_field_employee",
"title": "Set Purchased From field to Employee",
"description": "Employee field should be represented as Payee for the credit card purchase."
}},
{{
"code": "set_corporate_credit_card_expenses_purchased_from_field_vendor",
"title": "Set Purchased From field to Vendor",
"description": "Vendor field should be represented as Payee for the credit card purchase."
}},
{{
"code": "set_corporate_credit_card_expenses_export_grouping_report",
"title": "Group corporate credit expenses export to report",
"description": "Group reports as the expense entries posted in QuickBooks Desktop."
}},
{{
"code": "set_corporate_credit_card_expenses_export_grouping_expense",
"title": "Group corporate credit expenses export to expenses",
"description": "Group expense as the expense entries posted in QuickBooks Desktop."
}},
{{
"code": "set_corporate_credit_card_expenses_export_state_approved",
"title": "Set corporate credit expenses export to approved state",
"description": "Set corporate credit expenses to export expenses when they have been approved and are awaiting payment clearance"
}},
{{
"code": "set_corporate_credit_card_expenses_export_state_closed",
"title": "Set corporate credit expenses export to closed state",
"description": "Set corporate credit expenses to export expenses when they have been closed"
}}
]

}}
}}

3. /field_mappings
Output:
{{
"suggestions": {{
"actions": [
{{
"code": "set_customer_field_mapping_to_project"
"title": "Map Customer field to Project",
"description": "Set Project field in Fyle mapped to 'Customers' field in QuickBooks Desktops."
}},
{{
"code": "set_customer_field_mapping_to_cost_center",
"title": "Map Customer field to Cost Center",
"description": "Set Cost Center field in Fyle mapped to 'Customers' field in QuickBooks Desktop."
}},
{{
"code" "set_class_field_mapping_to_project",
"title": "Map Class field to Project",
"description": "Set Project field in Fyle mapped to 'Class' field in QuickBooks Desktop."
}},
{{
"code": "set_class_field_mapping_to_cost_center",
"title": "Map Class field to Cost Center",
"description": "Set Cost Center field in Fyle mapped to 'Class' field in QuickBooks Desktop."
}}
]
}}
}}


-----------------------------
Important things to take care:
1. Match the user query and only reply the actions, nothing less nothing more.
2. Dont match the exact URL, it can be a bit different containing things in the beginning
or the end.
3. If the user query doesn't match any of the above provided URL please reply with empty suggestion like this:

{{
"suggestions": {{
"actions": []
}}
}}

---------------------------
User Query: {user_query}
---------------------------

"""
9 changes: 9 additions & 0 deletions apps/spotlight/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from rest_framework import serializers

from .models import Query


class QuerySerializer(serializers.ModelSerializer):
class Meta:
model = Query
fields = ['query']
Loading