Spaces:
Sleeping
Sleeping
fix
Browse files
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
|
| 70 |
-
"""Generates a concise and
|
| 71 |
|
| 72 |
Args:
|
| 73 |
subject: The topic to generate a post about.
|
| 74 |
-
max_length: The maximum length of the post in characters (default:
|
| 75 |
|
| 76 |
Returns:
|
| 77 |
-
A
|
| 78 |
"""
|
| 79 |
-
prompt = f"Write a concise and engaging social media post about
|
| 80 |
-
|
| 81 |
try:
|
| 82 |
-
global model
|
| 83 |
-
response = model.
|
| 84 |
|
| 85 |
-
#
|
| 86 |
-
return response[:max_length].strip()
|
| 87 |
except Exception as e:
|
| 88 |
-
return f"Error generating post
|
|
|
|
| 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:
|