keenthinker commited on
Commit
08b5adc
·
verified ·
1 Parent(s): 5988809

Update app.py

Browse files

Update with a general summarizer and analyzer.

Files changed (1) hide show
  1. app.py +28 -2
app.py CHANGED
@@ -63,6 +63,32 @@ def summarize_text_tool(text:str)-> str:
63
  except Exception as e:
64
  return f"OH noes, something went wrong...:-/ {str(e)}"
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  final_answer = FinalAnswerTool()
67
  visit_webpage = VisitWebpageTool()
68
 
@@ -83,8 +109,8 @@ with open("prompts.yaml", 'r') as stream:
83
 
84
  agent = CodeAgent(
85
  model=model,
86
- tools=[final_answer, image_generation_tool, visit_webpage, summarize_text_tool], ## add your tools here (don't remove final answer)
87
- max_steps=6,
88
  verbosity_level=1,
89
  grammar=None,
90
  planning_interval=None,
 
63
  except Exception as e:
64
  return f"OH noes, something went wrong...:-/ {str(e)}"
65
 
66
+ @tool
67
+ def helper_text_tool(text:str)-> str:
68
+ #Keep this format for the description / args / args description but feel free to modify the tool
69
+ """A tool that helps analyze a text including following web links
70
+ Args:
71
+ text: the text to be analyzed
72
+ """
73
+ try:
74
+ hf_token = os.getenv('hf_token')
75
+ client = InferenceClient(api_key=hf_token)
76
+ messages = [
77
+ {
78
+ "role": "user",
79
+ "content": f"Your are an experienced requirements, tasks and process analyzer. Your are very skilled in analyzing and summarizing texts and creating prompts from the content for LLM's to generate solutions. Summarize the following text and give a meaningful answer to the question or questions: {text}"
80
+ }
81
+ ]
82
+ response = client.chat.completions.create(
83
+ model="Qwen/Qwen2.5-Coder-32B-Instruct",
84
+ messages=messages,
85
+ max_tokens=500
86
+ )
87
+ summarized_text = response.choices[0].message.content
88
+ return summarized_text
89
+ except Exception as e:
90
+ return f"OH noes, something went wrong...:-/ {str(e)}"
91
+
92
  final_answer = FinalAnswerTool()
93
  visit_webpage = VisitWebpageTool()
94
 
 
109
 
110
  agent = CodeAgent(
111
  model=model,
112
+ tools=[final_answer, image_generation_tool, visit_webpage, summarize_text_tool, helper_text_tool], ## add your tools here (don't remove final answer)
113
+ max_steps=10,
114
  verbosity_level=1,
115
  grammar=None,
116
  planning_interval=None,