pvanand commited on
Commit
7183db2
1 Parent(s): 9fa0fe5

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -2
main.py CHANGED
@@ -9,6 +9,7 @@ from datetime import datetime, timedelta
9
  from fastapi_cache import FastAPICache
10
  from fastapi_cache.backends.inmemory import InMemoryBackend
11
  from fastapi_cache.decorator import cache
 
12
 
13
  # Load environment variables from .env file
14
  #load_dotenv("keys.env")
@@ -77,9 +78,9 @@ async def generate_report(query: QueryModel):
77
  all_text_with_urls = [("", "")]
78
 
79
  if query.internet:
80
- search_query = description
81
  try:
82
- urls, optimized_search_query = search_brave(search_query, num_results=4)
83
  all_text_with_urls = fetch_and_extract_content(data_format, urls, query_str)
84
  additional_context = limit_tokens(str(all_text_with_urls))
85
  prompt = f"#### COMPLETE THE TASK: {description} #### IN THE CONTEXT OF ### CONTEXT: {query_str} USING THE #### SCRAPED DATA:{additional_context}"
 
9
  from fastapi_cache import FastAPICache
10
  from fastapi_cache.backends.inmemory import InMemoryBackend
11
  from fastapi_cache.decorator import cache
12
+ import asyncio
13
 
14
  # Load environment variables from .env file
15
  #load_dotenv("keys.env")
 
78
  all_text_with_urls = [("", "")]
79
 
80
  if query.internet:
81
+ search_query = re.sub(r'[^\w\s]', '', description).strip()
82
  try:
83
+ urls, optimized_search_query = await search_brave(search_query, num_results=4)
84
  all_text_with_urls = fetch_and_extract_content(data_format, urls, query_str)
85
  additional_context = limit_tokens(str(all_text_with_urls))
86
  prompt = f"#### COMPLETE THE TASK: {description} #### IN THE CONTEXT OF ### CONTEXT: {query_str} USING THE #### SCRAPED DATA:{additional_context}"