-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FS-109/Add Report to Prompt #57
base: main
Are you sure you want to change the base?
Changes from 5 commits
d985736
f0b63aa
48fdc0e
72d513f
7d88597
52deeed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
description: "Intent" | ||
description: 'Intent' | ||
|
||
providers: | ||
- id: openai:gpt-4o-mini | ||
|
@@ -8,54 +8,95 @@ providers: | |
prompts: file://promptfoo_test_runner.py:create_prompt | ||
|
||
tests: | ||
- description: "questions directed towards the database lookups should have only 1 question -1" | ||
- description: 'questions directed towards the database lookups should have only 1 question -1' | ||
vars: | ||
system_prompt_template: "intent-system" | ||
user_prompt_template: "intent" | ||
system_prompt_template: 'intent-system' | ||
user_prompt_template: 'intent' | ||
user_prompt_args: | ||
chat_history: [] | ||
question: "Check the database and tell me the average ESG score (Environmental) for the WhiteRock ETF fund" | ||
question: 'Check the database and tell me the average ESG score (Environmental) for the WhiteRock ETF fund' | ||
assert: | ||
- type: javascript | ||
value: JSON.parse(output).questions.length === 0 | ||
|
||
- description: "questions directed towards the database look ups should have only 1 question -2" | ||
- description: 'questions directed towards the database look ups should have only 1 question -2' | ||
vars: | ||
system_prompt_template: "intent-system" | ||
user_prompt_template: "intent" | ||
system_prompt_template: 'intent-system' | ||
user_prompt_template: 'intent' | ||
user_prompt_args: | ||
chat_history: [] | ||
question: "Using Bloomberg.csv dataset give me the company with the best esg score" | ||
question: 'Using Bloomberg.csv dataset give me the company with the best esg score' | ||
assert: | ||
- type: javascript | ||
value: JSON.parse(output).questions.length === 0 | ||
|
||
- description: "verify that the correct company name is determined from the chat history" | ||
- description: 'verify that the correct company name is determined from the chat history' | ||
vars: | ||
system_prompt_template: "intent-system" | ||
user_prompt_template: "intent" | ||
system_prompt_template: 'intent-system' | ||
user_prompt_template: 'intent' | ||
user_prompt_args: | ||
chat_history: | | ||
[ | ||
"User: When was Coca Cola founded?", | ||
"System: Coca-Cola was founded on May 8, 1886.", | ||
] | ||
question: "What is their best selling product?" | ||
question: 'What is their best selling product?' | ||
assert: | ||
- type: javascript | ||
value: output.includes("Coca-Cola") || output.includes("Coca Cola") | ||
|
||
- description: "verify that the question is correctly split up" | ||
- description: 'verify that the question is correctly split up' | ||
vars: | ||
system_prompt_template: "intent-system" | ||
user_prompt_template: "intent" | ||
system_prompt_template: 'intent-system' | ||
user_prompt_template: 'intent' | ||
user_prompt_args: | ||
chat_history: [] | ||
question: "Compare Ryanair emissions to other companies in the industry" | ||
question: 'Compare Ryanair emissions to other companies in the industry' | ||
assert: | ||
- type: javascript | ||
value: JSON.parse(output).questions[0].includes("Ryanair") | ||
- type: llm-rubric | ||
value: The 1st item in the questions array contains a question about finding the emissions for Ryanair | ||
- type: llm-rubric | ||
value: The 2nd item in the questions array contains a question about finding the emissions for companies in the industry | ||
|
||
- description: 'verify intent for finding ESG scores online in the Technology sector' | ||
vars: | ||
system_prompt_template: 'intent-system' | ||
user_prompt_template: 'intent' | ||
user_prompt_args: | ||
chat_history: [] | ||
question: 'provide a list of companies with the highest ESG scores in the Technology sector?' | ||
assert: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this relevant to this PR? |
||
- type: javascript | ||
value: JSON.parse(output).user_intent.includes("Technology sector") | ||
- type: javascript | ||
value: JSON.parse(output).questions[0].includes("highest ESG scores") | ||
- type: llm-rubric | ||
value: The output correctly identifies the intent to search online for companies in the Technology sector with high ESG scores. | ||
|
||
- description: 'Validation - General information is rejected' | ||
vars: | ||
system_prompt_template: 'validator' | ||
user_prompt_template: 'validate' | ||
user_prompt_args: | ||
task: 'Provide a list of companies with the highest ESG scores in the Technology sector.' | ||
answer: "As of the end of 2023, the Technology sector had the highest weighted-average ESG score among all sectors, according to the MSCI ACWI SRI Index. However, I don't have a specific list of individual companies with the highest scores." | ||
assert: | ||
- type: javascript | ||
value: JSON.parse(output).response === "false" | ||
- type: llm-rubric | ||
value: The reasoning should explain that general sector information is insufficient to fulfill the task. | ||
|
||
- description: 'Validation - Incorrect company is rejected' | ||
vars: | ||
system_prompt_template: 'validator' | ||
user_prompt_template: 'validate' | ||
user_prompt_args: | ||
task: "What are Apple's ESG scores?" | ||
answer: "Microsoft's ESG (Environmental, Social, and Governance) scores are as follows: Environmental Score of 95.0, Social Score of 90.0, Governance Score of 92.0." | ||
assert: | ||
- type: javascript | ||
value: JSON.parse(output).response === "false" | ||
- type: llm-rubric | ||
value: The reasoning should explain that the scores provided do not match Apple's scores as requested. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
The conversation history is: | ||
{{ chat_history }} | ||
|
||
The uploaded file's content is: | ||
{{ uploaded_file_content }} | ||
|
||
The question is: | ||
{{ question }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,20 @@ def clear_session_file_uploads(): | |
set_session(UPLOADS_META_SESSION_KEY, []) | ||
|
||
|
||
def get_uploaded_file_content() -> str | None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, unfortunately I think there has been some confusion with this ticket, I'll update the ticket to be more clear. "Report" was meant to be the report generated for the user by the Report Agent / report flow, not the file that was uploaded (whilst we have been commonly testing InferESG with Sustainability Reports, we have been describing these input files as "Narrative Files") |
||
session_file_meta = get_session_file_uploads_meta() | ||
if session_file_meta: | ||
upload_id = session_file_meta[0]['uploadId'] | ||
session_file_data = get_session_file_upload(upload_id) | ||
if session_file_data: | ||
session_file_content = session_file_data.get('content') | ||
return session_file_content | ||
else: | ||
logger.warning("No session file data found.") | ||
else: | ||
logger.warning("No session file uploads found.") | ||
return None | ||
|
||
def store_report(report: FileUploadReport): | ||
redis_client.set(REPORT_KEY_PREFIX + report["id"], json.dumps(report)) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
engine = PromptEngine() | ||
|
||
|
||
async def search_urls(search_query, num_results=10) -> str: | ||
async def search_urls(search_query, num_results=30) -> str: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be part of this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @IMladjenovic - This MR is on top of the Web agent one...and the web agent one is yet to me merged back to the main.. |
||
logger.info(f"Searching the web for: {search_query}") | ||
try: | ||
https_urls = [str(url) for url in search(search_query, num_results=num_results) if str(url).startswith("https")] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As commented on the other PR, can we keep these as double quotes for now?