alisamak commited on
Commit
f11ae3d
·
verified ·
1 Parent(s): 3829cf9
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -66,26 +66,26 @@ def get_current_time_in_timezone(timezone: str) -> str:
66
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
67
 
68
  @tool
69
- def generate_subject_post(subject: str, max_length: int = 280) -> str:
70
- """Generates a concise and engaging post about a specific subject.
71
 
72
  Args:
73
  subject: The topic to generate a post about.
74
- max_length: The maximum length of the post in characters (default: 280).
75
 
76
  Returns:
77
- A concise, engaging post about the given subject.
78
  """
79
- prompt = f"Write a concise and engaging social media post about the subject: {subject}. Limit it to {max_length} characters."
80
-
81
  try:
82
- global model
83
- response = model.generate_text(prompt)
84
 
85
- # Ensure the response respects the maximum length
86
- return response[:max_length].strip()
87
  except Exception as e:
88
- return f"Error generating post for subject '{subject}': {str(e)}"
 
89
 
90
  @tool
91
  def generate_image(description: str) -> str:
 
66
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
67
 
68
  @tool
69
+ def generate_post(subject: str, max_length: int = 200) -> str:
70
+ """Generates a concise and well-structured post about a given subject.
71
 
72
  Args:
73
  subject: The topic to generate a post about.
74
+ max_length: The maximum length of the post in characters (default: 200).
75
 
76
  Returns:
77
+ A well-structured, engaging post about the subject.
78
  """
79
+ prompt = f"Write a concise and engaging social media post about {subject}. Limit the response to {max_length} characters."
80
+
81
  try:
82
+ global model # Ensure the model is accessible
83
+ response = model.run(prompt) # Use .run() instead of .generate_text()
84
 
85
+ return response[:max_length] # Trim response if needed
 
86
  except Exception as e:
87
+ return f"Error generating post about '{subject}': {str(e)}"
88
+
89
 
90
  @tool
91
  def generate_image(description: str) -> str: