Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,28 +15,32 @@ def name_generator(mom: str, dad: str) -> list:
|
|
| 15 |
"""
|
| 16 |
Generate baby names based on parental preferences.
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
"""
|
| 25 |
prompt = f"""
|
| 26 |
You are an AI that suggests baby names based on parental preferences.
|
| 27 |
The mother prefers: {mom}.
|
| 28 |
The father prefers: {dad}.
|
| 29 |
-
|
| 30 |
Suggest as many baby names as possible.
|
| 31 |
Just return the names, separated by commas, nothing else.
|
| 32 |
"""
|
| 33 |
|
|
|
|
| 34 |
response = model.generate(prompt)
|
| 35 |
-
baby_names =
|
|
|
|
|
|
|
| 36 |
return baby_names if baby_names else ["No names generated. Try different preferences."]
|
| 37 |
|
| 38 |
|
| 39 |
|
|
|
|
| 40 |
@tool
|
| 41 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 42 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 15 |
"""
|
| 16 |
Generate baby names based on parental preferences.
|
| 17 |
|
| 18 |
+
:param mom: The mother's preferences for the name (e.g., "classic", "modern").
|
| 19 |
+
:type mom: str
|
| 20 |
+
:param dad: The father's preferences for the name (e.g., "hero names", "short names").
|
| 21 |
+
:type dad: str
|
| 22 |
+
:return: A list of baby names that match the given preferences
|
| 23 |
+
:rtype: list
|
| 24 |
"""
|
| 25 |
prompt = f"""
|
| 26 |
You are an AI that suggests baby names based on parental preferences.
|
| 27 |
The mother prefers: {mom}.
|
| 28 |
The father prefers: {dad}.
|
| 29 |
+
|
| 30 |
Suggest as many baby names as possible.
|
| 31 |
Just return the names, separated by commas, nothing else.
|
| 32 |
"""
|
| 33 |
|
| 34 |
+
# Ton code pour générer la réponse via 'model'
|
| 35 |
response = model.generate(prompt)
|
| 36 |
+
baby_names = response.strip().split(",")
|
| 37 |
+
baby_names = [name.strip() for name in baby_names if name.strip()]
|
| 38 |
+
|
| 39 |
return baby_names if baby_names else ["No names generated. Try different preferences."]
|
| 40 |
|
| 41 |
|
| 42 |
|
| 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.
|