Spaces:
Runtime error
Runtime error
Update tools.py
Browse files
tools.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
| 1 |
# tools.py
|
| 2 |
|
| 3 |
from smolagents import tool
|
| 4 |
-
from retriever import retrieve_relevant_context
|
| 5 |
-
|
| 6 |
|
| 7 |
def clean_answer_with_prompt(agent_output: str) -> str:
|
| 8 |
"""
|
|
@@ -24,31 +22,11 @@ def build_prompt(question: str, context: str) -> str:
|
|
| 24 |
)
|
| 25 |
return f"{system_instruction}Context:\n{context}\n\nQuestion: {question}\nAnswer:"
|
| 26 |
|
| 27 |
-
|
| 28 |
-
@tool
|
| 29 |
-
def guest_info_tool(name: str) -> str:
|
| 30 |
-
|
| 31 |
-
Retrieves background info about a guest using the document store.
|
| 32 |
-
|
| 33 |
-
Args:
|
| 34 |
-
name (str): The name of the guest to retrieve context for.
|
| 35 |
-
|
| 36 |
-
Returns:
|
| 37 |
-
str: Relevant background information from the document store.
|
| 38 |
-
"""
|
| 39 |
-
return retrieve_relevant_context(name)
|
| 40 |
|
| 41 |
@tool
|
| 42 |
def greeting_tool(name: str) -> str:
|
| 43 |
-
"""
|
| 44 |
-
Generates a custom greeting for the guest.
|
| 45 |
-
|
| 46 |
-
Args:
|
| 47 |
-
name (str): The name of the guest to greet.
|
| 48 |
-
|
| 49 |
-
Returns:
|
| 50 |
-
str: A friendly greeting message.
|
| 51 |
-
"""
|
| 52 |
return f"Welcome to the gala, {name}! We're honored to have you with us."
|
| 53 |
-
|
| 54 |
-
|
|
|
|
| 1 |
# tools.py
|
| 2 |
|
| 3 |
from smolagents import tool
|
|
|
|
|
|
|
| 4 |
|
| 5 |
def clean_answer_with_prompt(agent_output: str) -> str:
|
| 6 |
"""
|
|
|
|
| 22 |
)
|
| 23 |
return f"{system_instruction}Context:\n{context}\n\nQuestion: {question}\nAnswer:"
|
| 24 |
|
| 25 |
+
# These tools are optional; remove or fix if using
|
| 26 |
+
# @tool
|
| 27 |
+
# def guest_info_tool(name: str) -> str:
|
| 28 |
+
# return "Background info not available."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
@tool
|
| 31 |
def greeting_tool(name: str) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
return f"Welcome to the gala, {name}! We're honored to have you with us."
|
|
|
|
|
|