alisamak commited on
Commit
f7a68bd
·
verified ·
1 Parent(s): b6d3913

tools update

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -34,25 +34,27 @@ def get_current_time_in_timezone(timezone: str) -> str:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
  @tool
37
- def generate_post(subject: str, max_length: int = 200) -> str:
38
- """Generates a concise and well-structured post about a given subject.
39
 
40
  Args:
41
  subject: The topic to generate a post about.
42
- max_length: The maximum length of the post in characters (default: 200).
43
 
44
  Returns:
45
- A well-structured, engaging post about the subject.
46
  """
47
- prompt = f"Write a concise and engaging social media post about {subject}. Limit the response to {max_length} characters."
48
-
49
  try:
50
  global model
51
- response = model.generate_text(prompt)
52
 
53
- return response[:max_length]
 
54
  except Exception as e:
55
- return f"Error generating post: {str(e)}"
 
56
 
57
 
58
 
@@ -77,7 +79,7 @@ with open("prompts.yaml", 'r') as stream:
77
 
78
  agent = CodeAgent(
79
  model=model,
80
- tools=[final_answer,get_current_time_in_timezone,generate_post], ## add your tools here (don't remove final answer)
81
  max_steps=6,
82
  verbosity_level=1,
83
  grammar=None,
 
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
  @tool
37
+ def generate_subject_post(subject: str, max_length: int = 280) -> str:
38
+ """Generates a concise and engaging post about a specific subject.
39
 
40
  Args:
41
  subject: The topic to generate a post about.
42
+ max_length: The maximum length of the post in characters (default: 280).
43
 
44
  Returns:
45
+ A concise, engaging post about the given subject.
46
  """
47
+ prompt = f"Write a concise and engaging social media post about the subject: {subject}. Limit it to {max_length} characters."
48
+
49
  try:
50
  global model
51
+ response = model.generate_text(prompt)
52
 
53
+ # Ensure the response respects the maximum length
54
+ return response[:max_length].strip()
55
  except Exception as e:
56
+ return f"Error generating post for subject '{subject}': {str(e)}"
57
+
58
 
59
 
60
 
 
79
 
80
  agent = CodeAgent(
81
  model=model,
82
+ tools=[final_answer,get_current_time_in_timezone,generate_subject_post], ## add your tools here (don't remove final answer)
83
  max_steps=6,
84
  verbosity_level=1,
85
  grammar=None,