basillicus commited on
Commit
f291e6d
·
verified ·
1 Parent(s): 8c5c24b

Add tool brief_text_in_n_sentences

Browse files
Files changed (1) hide show
  1. app.py +24 -1
app.py CHANGED
@@ -18,6 +18,29 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
18
  """
19
  return "What magic will you build ?"
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
23
  """A tool that fetches the current local time in a specified timezone.
@@ -55,7 +78,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
18
  """
19
  return "What magic will you build ?"
20
 
21
+ @tool
22
+ def brief_text_in_n_sentences(text:str, n:int)-> str: #it's import to specify the return type
23
+ #Keep this format for the description / args / args description but feel free to modify the tool
24
+ """A tool that succintly briefs a given text in 'n' number of sentences
25
+ Args:
26
+ text: the text to be resumed into the given number of sentences
27
+ n: the number of sentences to use to brief the text
28
+ """
29
+
30
+ if not text.strip():
31
+ return "No text provided to summarize."
32
+
33
+ prompt = (
34
+ f"Please summarize the following text in exactly {n} sentence{'s' if n > 1 else ''}:\n\n{text}\n\n"
35
+ "Summary:"
36
+ )
37
+
38
+ try:
39
+ response = model(prompt)
40
+ return response
41
+ except Exception as e:
42
+ return f"LLM summarization failed: {str(e)}"
43
+
44
  @tool
45
  def get_current_time_in_timezone(timezone: str) -> str:
46
  """A tool that fetches the current local time in a specified timezone.
 
78
 
79
  agent = CodeAgent(
80
  model=model,
81
+ tools=[final_answer, brief_text_in_n_sentences, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
82
  max_steps=6,
83
  verbosity_level=1,
84
  grammar=None,