Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -151,17 +151,6 @@ def expand_snippet_area(soup: BeautifulSoup, snippet: str) -> Tag:
|
|
| 151 |
def fine_tune_report(adjustment_request: str, openai_api_key: str, serpapi_api_key: str, report_html: str,
|
| 152 |
initial_request: str, qa: str, target_style: str, knowledge_crumbs: str,
|
| 153 |
complementary_guidance: str) -> (str, str):
|
| 154 |
-
"""
|
| 155 |
-
...
|
| 156 |
-
The function fine-tunes the report by:
|
| 157 |
-
1. Identifying unique strings in the area to adjust.
|
| 158 |
-
2. Using expand_snippet_area (which now receives a BeautifulSoup object) to locate the container.
|
| 159 |
-
3. Calling an LLM to produce an improved container and then replacing the original.
|
| 160 |
-
4. Optionally updating the reference table and appending a summary.
|
| 161 |
-
"""
|
| 162 |
-
import os
|
| 163 |
-
import json
|
| 164 |
-
|
| 165 |
os.environ["OPENAI_API_KEY"] = openai_api_key
|
| 166 |
os.environ["SERPAPI_API_KEY"] = serpapi_api_key
|
| 167 |
|
|
@@ -172,7 +161,26 @@ def fine_tune_report(adjustment_request: str, openai_api_key: str, serpapi_api_k
|
|
| 172 |
|
| 173 |
prompt_identify = (
|
| 174 |
f"""You are a meticulous technical editor.
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
Only output valid JSON."""
|
| 177 |
)
|
| 178 |
response_identify = openai_call(prompt=prompt_identify, model="o3-mini", max_tokens_param=5000, temperature=0)
|
|
|
|
| 151 |
def fine_tune_report(adjustment_request: str, openai_api_key: str, serpapi_api_key: str, report_html: str,
|
| 152 |
initial_request: str, qa: str, target_style: str, knowledge_crumbs: str,
|
| 153 |
complementary_guidance: str) -> (str, str):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
os.environ["OPENAI_API_KEY"] = openai_api_key
|
| 155 |
os.environ["SERPAPI_API_KEY"] = serpapi_api_key
|
| 156 |
|
|
|
|
| 161 |
|
| 162 |
prompt_identify = (
|
| 163 |
f"""You are a meticulous technical editor.
|
| 164 |
+
|
| 165 |
+
Below is the full report HTML and a user adjustment request.
|
| 166 |
+
Extract one or more unique plain-text string(s) (without any HTML tags or formatting) that uniquely appear in the area(s) targeted by the adjustment request.
|
| 167 |
+
|
| 168 |
+
// Examples
|
| 169 |
+
|
| 170 |
+
if the user request to "Add xyz in the conclusion", the unique string to identify should be specific to the conclusion
|
| 171 |
+
if the user request to "correct the graph after section 1.2", the unique string should be one of the string that appear specifically in the graph after section 1.2 (ex: the title)
|
| 172 |
+
if the user request is "Remove any mention about the car industry", the unique string(s) should be a sentence that would be in a paragraph of the report that would talk about car industry
|
| 173 |
+
--> The unique string is what would allow to identify precisely through a search the section targeted by the user request, it has to be concise and unique.
|
| 174 |
+
|
| 175 |
+
Output them in a JSON object with the key "identified_unique_strings" mapped to a list of strings.
|
| 176 |
+
Ensure these strings exactly match the content in the report.
|
| 177 |
+
|
| 178 |
+
Full Report HTML:
|
| 179 |
+
{report_html}
|
| 180 |
+
|
| 181 |
+
User Adjustment Request:
|
| 182 |
+
{adjustment_request}
|
| 183 |
+
|
| 184 |
Only output valid JSON."""
|
| 185 |
)
|
| 186 |
response_identify = openai_call(prompt=prompt_identify, model="o3-mini", max_tokens_param=5000, temperature=0)
|