Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -59,12 +59,12 @@ async def generate_report(request: Request, query: QueryModel):
|
|
59 |
query_str = query.topic
|
60 |
description = query.description
|
61 |
user_id = query.user_id
|
62 |
-
internet = query.internet
|
63 |
sys_prompt_output_format = sys_prompts[internet][query.output_format]
|
64 |
data_format = query.data_format
|
65 |
|
66 |
# Combine query with user keywords
|
67 |
-
if internet:
|
68 |
search_query = description
|
69 |
# Search for relevant URLs
|
70 |
try:
|
@@ -76,10 +76,10 @@ async def generate_report(request: Request, query: QueryModel):
|
|
76 |
prompt = f"#### COMPLETE THE TASK: {description} #### IN THE CONTEXT OF ### CONTEXT: {query_str} USING THE #### SCRAPED DATA:{additional_context}"
|
77 |
|
78 |
except Exception as e:
|
79 |
-
internet = False
|
80 |
print("failed to search/scrape results, falling back to LLM response")
|
81 |
|
82 |
-
if not internet:
|
83 |
prompt = f"#### COMPLETE THE TASK: {description} #### IN THE CONTEXT OF ### CONTEXT: {query_str}"
|
84 |
all_text_with_urls = [("","")]
|
85 |
|
|
|
59 |
query_str = query.topic
|
60 |
description = query.description
|
61 |
user_id = query.user_id
|
62 |
+
internet = "online" if query.internet else "offline"
|
63 |
sys_prompt_output_format = sys_prompts[internet][query.output_format]
|
64 |
data_format = query.data_format
|
65 |
|
66 |
# Combine query with user keywords
|
67 |
+
if query.internet:
|
68 |
search_query = description
|
69 |
# Search for relevant URLs
|
70 |
try:
|
|
|
76 |
prompt = f"#### COMPLETE THE TASK: {description} #### IN THE CONTEXT OF ### CONTEXT: {query_str} USING THE #### SCRAPED DATA:{additional_context}"
|
77 |
|
78 |
except Exception as e:
|
79 |
+
query.internet = False
|
80 |
print("failed to search/scrape results, falling back to LLM response")
|
81 |
|
82 |
+
if not query.internet:
|
83 |
prompt = f"#### COMPLETE THE TASK: {description} #### IN THE CONTEXT OF ### CONTEXT: {query_str}"
|
84 |
all_text_with_urls = [("","")]
|
85 |
|