Update app.py
Browse filest-strings not yet avail on hf spaces
app.py
CHANGED
|
@@ -10,6 +10,7 @@ import whisper
|
|
| 10 |
import gradio as gr
|
| 11 |
import inspect
|
| 12 |
import pandas as pd
|
|
|
|
| 13 |
|
| 14 |
# --- constants ---
|
| 15 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
@@ -97,7 +98,7 @@ class Agent:
|
|
| 97 |
)
|
| 98 |
|
| 99 |
def __call__(self, question_text, file_name) -> str:
|
| 100 |
-
template =
|
| 101 |
When given a question:
|
| 102 |
- If necessary, perform a web search using the tool `web_search` to find possible sources of information.
|
| 103 |
- If the web search only returns titles and short snippets, you MUST visit the actual webpage using the `visit_webpage` tool to read the full content before answering.
|
|
@@ -119,7 +120,7 @@ class Agent:
|
|
| 119 |
{question_text}
|
| 120 |
-- end of question --
|
| 121 |
If the questions mentions the need to use a file, use the following `file_name` value below as the `file_name` parameter in any function calls:
|
| 122 |
-
file_name: {file_name}"""
|
| 123 |
enhanced_question = template.substitute(question_text=question_text, file_name=file_name)
|
| 124 |
response = self.agent.run(enhanced_question)
|
| 125 |
return response
|
|
|
|
| 10 |
import gradio as gr
|
| 11 |
import inspect
|
| 12 |
import pandas as pd
|
| 13 |
+
from string import Template
|
| 14 |
|
| 15 |
# --- constants ---
|
| 16 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
|
| 98 |
)
|
| 99 |
|
| 100 |
def __call__(self, question_text, file_name) -> str:
|
| 101 |
+
template = Template("""You are a highly precise question-answering agent.
|
| 102 |
When given a question:
|
| 103 |
- If necessary, perform a web search using the tool `web_search` to find possible sources of information.
|
| 104 |
- If the web search only returns titles and short snippets, you MUST visit the actual webpage using the `visit_webpage` tool to read the full content before answering.
|
|
|
|
| 120 |
{question_text}
|
| 121 |
-- end of question --
|
| 122 |
If the questions mentions the need to use a file, use the following `file_name` value below as the `file_name` parameter in any function calls:
|
| 123 |
+
file_name: {file_name}""")
|
| 124 |
enhanced_question = template.substitute(question_text=question_text, file_name=file_name)
|
| 125 |
response = self.agent.run(enhanced_question)
|
| 126 |
return response
|