Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -395,7 +395,9 @@ def openai_call(prompt: str, messages: list = None, model: str = "o3-mini",
|
|
| 395 |
return err_msg
|
| 396 |
|
| 397 |
def analyze_with_gpt4o(query: str, snippet: str, breadth: int, temperature: float = 0.7, max_tokens: int = 8000) -> dict:
|
| 398 |
-
#
|
|
|
|
|
|
|
| 399 |
snippet_words = len(snippet.split())
|
| 400 |
# decide a proportional max tokens (cap at 3000 for example)
|
| 401 |
# e.g. 1 token ~ ~0.75 words, so we do something simplistic:
|
|
@@ -1347,7 +1349,8 @@ def iterative_deep_research_gen(initial_query: str, reportstyle: str, breadth: i
|
|
| 1347 |
analysis = analyze_with_gpt4o(initial_query, semantically_rich_snippet, breadth)
|
| 1348 |
|
| 1349 |
# Analyze the cleaned content with GPT-4o-mini
|
| 1350 |
-
|
|
|
|
| 1351 |
analysis_summary = analysis.get("summary", "")
|
| 1352 |
if isinstance(analysis_summary, (dict, list)):
|
| 1353 |
analysis_summary = json.dumps(analysis_summary)
|
|
|
|
| 395 |
return err_msg
|
| 396 |
|
| 397 |
def analyze_with_gpt4o(query: str, snippet: str, breadth: int, temperature: float = 0.7, max_tokens: int = 8000) -> dict:
|
| 398 |
+
# If snippet is a callable, call it to get the string.
|
| 399 |
+
if callable(snippet):
|
| 400 |
+
snippet = snippet()
|
| 401 |
snippet_words = len(snippet.split())
|
| 402 |
# decide a proportional max tokens (cap at 3000 for example)
|
| 403 |
# e.g. 1 token ~ ~0.75 words, so we do something simplistic:
|
|
|
|
| 1349 |
analysis = analyze_with_gpt4o(initial_query, semantically_rich_snippet, breadth)
|
| 1350 |
|
| 1351 |
# Analyze the cleaned content with GPT-4o-mini
|
| 1352 |
+
cleaned_text = clean_content(raw_content) # Call the function to get a string.
|
| 1353 |
+
analysis = analyze_with_gpt4o(initial_query, cleaned_text, breadth)
|
| 1354 |
analysis_summary = analysis.get("summary", "")
|
| 1355 |
if isinstance(analysis_summary, (dict, list)):
|
| 1356 |
analysis_summary = json.dumps(analysis_summary)
|