pvanand commited on
Commit
6fe2220
1 Parent(s): 7bd26ee

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +19 -13
main.py CHANGED
@@ -55,25 +55,31 @@ async def generate_report(request: Request, query: QueryModel):
55
  description = query.description
56
  user_id = query.user_id
57
  internet = "online" if query.internet else "offline"
58
- output_format = sys_prompts[internet][query.output_format]
59
  data_format = query.data_format
60
- #return {output_format,data_format}
61
  # Combine query with user keywords
62
- search_query = query_str
63
-
64
- # Search for relevant URLs
65
- urls = search_brave(search_query, num_results=4)
 
66
 
67
- # Fetch and extract content from the URLs
68
- all_text_with_urls = fetch_and_extract_content(data_format, urls, query_str)
69
 
70
- # Prepare the prompt for generating the report
71
- additional_context = limit_tokens(str(all_text_with_urls))
72
- prompt = f"#### ADDITIONAL CONTEXT:{additional_context} #### CREATE A DETAILED REPORT FOR THE QUERY:{query_str} #### IN THE CONTEXT OF ### CONTEXT: {description}"
73
- md_report = together_response(prompt, model=llm_default_medium, SysPrompt=SysPromptMd)
74
 
 
 
 
 
 
 
75
  # Insert data into database (or other storage)
76
- #insert_data(user_id, query_str, description, str(all_text_with_urls), md_report)
77
  references_html = dict()
78
  for text, url in all_text_with_urls:
79
  references_html[url] = str(md_to_html(text))
 
55
  description = query.description
56
  user_id = query.user_id
57
  internet = "online" if query.internet else "offline"
58
+ sys_prompt_output_format = sys_prompts[internet][query.output_format]
59
  data_format = query.data_format
60
+
61
  # Combine query with user keywords
62
+ if query.internet:
63
+ search_query = query_str
64
+
65
+ # Search for relevant URLs
66
+ urls = search_brave(search_query, num_results=4)
67
 
68
+ # Fetch and extract content from the URLs
69
+ all_text_with_urls = fetch_and_extract_content(data_format, urls, query_str)
70
 
71
+ # Prepare the prompt for generating the report
72
+ additional_context = limit_tokens(str(all_text_with_urls))
73
+ prompt = f"#### COMPLETE THE TASK: {query_str} #### IN THE CONTEXT OF ### CONTEXT: {description} #### ADDITIONAL CONTEXT:{additional_context}"
 
74
 
75
+ else:
76
+ prompt = f"#### COMPLETE THE TASK: {query_str} #### IN THE CONTEXT OF ### CONTEXT: {description}"
77
+ all_text_with_urls = [("","")]
78
+
79
+ md_report = together_response(prompt, model=llm_default_medium, SysPrompt=sys_prompt_output_format)
80
+
81
  # Insert data into database (or other storage)
82
+ insert_data(user_id, query_str, description, str(all_text_with_urls), md_report)
83
  references_html = dict()
84
  for text, url in all_text_with_urls:
85
  references_html[url] = str(md_to_html(text))