Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,13 +16,12 @@ def name_generator(mom: str, dad: str) -> list:
|
|
| 16 |
Generate baby names based on parental preferences.
|
| 17 |
|
| 18 |
Args:
|
| 19 |
-
mom (
|
| 20 |
-
dad (
|
| 21 |
|
| 22 |
Returns:
|
| 23 |
list: A list of baby names that match the given preferences.
|
| 24 |
"""
|
| 25 |
-
# Création du prompt pour générer plusieurs prénoms
|
| 26 |
prompt = f"""
|
| 27 |
You are an AI that suggests baby names based on parental preferences.
|
| 28 |
The mother prefers: {mom}.
|
|
@@ -32,17 +31,12 @@ def name_generator(mom: str, dad: str) -> list:
|
|
| 32 |
Just return the names, separated by commas, nothing else.
|
| 33 |
"""
|
| 34 |
|
| 35 |
-
# Envoi de la requête au modèle
|
| 36 |
-
# Assure-toi que la méthode 'generate' existe bien pour l'objet model
|
| 37 |
response = model.generate(prompt)
|
| 38 |
-
|
| 39 |
-
# Nettoyage et transformation en liste
|
| 40 |
-
baby_names = response.strip().split(",") # Sépare les prénoms par virgule
|
| 41 |
-
baby_names = [name.strip() for name in baby_names if name.strip()]
|
| 42 |
-
|
| 43 |
return baby_names if baby_names else ["No names generated. Try different preferences."]
|
| 44 |
|
| 45 |
|
|
|
|
| 46 |
@tool
|
| 47 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 48 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 16 |
Generate baby names based on parental preferences.
|
| 17 |
|
| 18 |
Args:
|
| 19 |
+
mom (str): The mother's preferences for the name (e.g., "classic", "modern", "French names").
|
| 20 |
+
dad (str): The father's preferences for the name (e.g., "hero names", "Corsican names", "short names").
|
| 21 |
|
| 22 |
Returns:
|
| 23 |
list: A list of baby names that match the given preferences.
|
| 24 |
"""
|
|
|
|
| 25 |
prompt = f"""
|
| 26 |
You are an AI that suggests baby names based on parental preferences.
|
| 27 |
The mother prefers: {mom}.
|
|
|
|
| 31 |
Just return the names, separated by commas, nothing else.
|
| 32 |
"""
|
| 33 |
|
|
|
|
|
|
|
| 34 |
response = model.generate(prompt)
|
| 35 |
+
baby_names = [name.strip() for name in response.strip().split(",") if name.strip()]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|