Spaces:
Sleeping
Sleeping
Update app.py
Browse filesAdded a summerizer tool
app.py
CHANGED
@@ -49,6 +49,21 @@ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may
|
|
49 |
custom_role_conversions=None,
|
50 |
)
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
# Import tool from Hub
|
54 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
@@ -58,7 +73,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
58 |
|
59 |
agent = CodeAgent(
|
60 |
model=model,
|
61 |
-
tools=[final_answer, image_generation_tool, visit_webpage], ## add your tools here (don't remove final answer)
|
62 |
max_steps=6,
|
63 |
verbosity_level=1,
|
64 |
grammar=None,
|
|
|
49 |
custom_role_conversions=None,
|
50 |
)
|
51 |
|
52 |
+
@tool
|
53 |
+
def summarize_text_tool(text:str)-> str:
|
54 |
+
#Keep this format for the description / args / args description but feel free to modify the tool
|
55 |
+
"""A tool that summarizes the specified text
|
56 |
+
Args:
|
57 |
+
text: the text to be summaried
|
58 |
+
"""
|
59 |
+
try:
|
60 |
+
from transformers import pipeline
|
61 |
+
summarizer = pipeline("summarization", model=model)
|
62 |
+
summary = summarizer(text, max_length=150, min_length=50, do_sample=False)
|
63 |
+
return summary[0]['summary_text']
|
64 |
+
except Exception as e:
|
65 |
+
return f"OH noes, something went wrong...:-/ {str(e)}"
|
66 |
+
|
67 |
|
68 |
# Import tool from Hub
|
69 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
|
|
73 |
|
74 |
agent = CodeAgent(
|
75 |
model=model,
|
76 |
+
tools=[final_answer, image_generation_tool, visit_webpage, summarize_text_tool], ## add your tools here (don't remove final answer)
|
77 |
max_steps=6,
|
78 |
verbosity_level=1,
|
79 |
grammar=None,
|