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

update tools

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -35,20 +35,25 @@ def get_current_time_in_timezone(timezone: str) -> str:
35
 
36
  @tool
37
  def generate_post(subject: str, max_length: int = 200) -> str:
38
- """Generates a well-structured post about a given subject with a length limit.
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 concise, engaging post about the subject.
46
  """
47
- prompt = f"Write a concise and engaging social media post about {subject}. Keep it within {max_length} characters."
48
-
49
- response = model.generate_text(prompt, max_tokens=max_length // 4) # Approx. 4 chars per token
50
-
51
- return response[:max_length] # Ensure it doesn't exceed max_length
 
 
 
 
 
52
 
53
 
54
  final_answer = FinalAnswerTool()
 
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
 
59
  final_answer = FinalAnswerTool()