Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -62,6 +62,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 62 |
embedding_model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
|
| 63 |
qa_pipeline = pipeline("text2text-generation", model="google/flan-t5-base")
|
| 64 |
|
|
|
|
| 65 |
def document_qna_tool_fn(pdf_path: str, question: str) -> str:
|
| 66 |
import traceback
|
| 67 |
|
|
@@ -97,14 +98,6 @@ def document_qna_tool_fn(pdf_path: str, question: str) -> str:
|
|
| 97 |
except Exception as e:
|
| 98 |
return f"[EXCEPTION] {type(e).__name__}: {str(e)}\n{traceback.format_exc()}"
|
| 99 |
|
| 100 |
-
# Wrap the function using Tool(...)
|
| 101 |
-
document_qna_tool = Tool(
|
| 102 |
-
name="document_qna_tool",
|
| 103 |
-
description="Answer questions about a PDF document.",
|
| 104 |
-
func=document_qna_tool_fn
|
| 105 |
-
)
|
| 106 |
-
|
| 107 |
-
|
| 108 |
# -------------------- Other Components --------------------
|
| 109 |
final_answer = FinalAnswerTool()
|
| 110 |
search_tool = DuckDuckGoSearchTool()
|
|
@@ -128,7 +121,7 @@ agent = CodeAgent(
|
|
| 128 |
get_current_weather,
|
| 129 |
image_generation_tool,
|
| 130 |
search_tool,
|
| 131 |
-
document_qna_tool,
|
| 132 |
final_answer
|
| 133 |
],
|
| 134 |
max_steps=6,
|
|
|
|
| 62 |
embedding_model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
|
| 63 |
qa_pipeline = pipeline("text2text-generation", model="google/flan-t5-base")
|
| 64 |
|
| 65 |
+
@Tool
|
| 66 |
def document_qna_tool_fn(pdf_path: str, question: str) -> str:
|
| 67 |
import traceback
|
| 68 |
|
|
|
|
| 98 |
except Exception as e:
|
| 99 |
return f"[EXCEPTION] {type(e).__name__}: {str(e)}\n{traceback.format_exc()}"
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
# -------------------- Other Components --------------------
|
| 102 |
final_answer = FinalAnswerTool()
|
| 103 |
search_tool = DuckDuckGoSearchTool()
|
|
|
|
| 121 |
get_current_weather,
|
| 122 |
image_generation_tool,
|
| 123 |
search_tool,
|
| 124 |
+
document_qna_tool,
|
| 125 |
final_answer
|
| 126 |
],
|
| 127 |
max_steps=6,
|