Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse files- app.py +4 -4
- test_api.py +2 -2
app.py
CHANGED
|
@@ -43,7 +43,7 @@ def extract_persona_parameters(business_description: str, customer_profile: str)
|
|
| 43 |
- `custom_life_attitude` (str): The life attitude of the persona.
|
| 44 |
- `life_story` (str): A brief life story of the persona.
|
| 45 |
- `interests_hobbies` (str): Interests and hobbies of the persona.
|
| 46 |
-
- `attribute_count` (float): Attribute richness, default to
|
| 47 |
|
| 48 |
You must return a valid JSON object containing exactly these keys.
|
| 49 |
"""
|
|
@@ -76,7 +76,7 @@ def extract_persona_parameters(business_description: str, customer_profile: str)
|
|
| 76 |
if key not in extracted_json:
|
| 77 |
# provide defaults for missing ones
|
| 78 |
if key in ['age', 'attribute_count']:
|
| 79 |
-
extracted_json[key] =
|
| 80 |
else:
|
| 81 |
extracted_json[key] = "Unknown"
|
| 82 |
|
|
@@ -96,7 +96,7 @@ def extract_persona_parameters(business_description: str, customer_profile: str)
|
|
| 96 |
"custom_life_attitude": "Optimistic",
|
| 97 |
"life_story": "A standard professional background with a passion for their field.",
|
| 98 |
"interests_hobbies": "Technology, Reading",
|
| 99 |
-
"attribute_count":
|
| 100 |
}
|
| 101 |
|
| 102 |
def generate_personas(business_description, customer_profile, num_personas, blablador_api_key=None):
|
|
@@ -148,7 +148,7 @@ def generate_personas(business_description, customer_profile, num_personas, blab
|
|
| 148 |
custom_life_attitude=str(params.get("custom_life_attitude", "Optimistic")),
|
| 149 |
life_story=str(params.get("life_story", "A standard professional background with a passion for their field.")),
|
| 150 |
interests_hobbies=str(params.get("interests_hobbies", "Technology, Reading")),
|
| 151 |
-
attribute_count=float(params.get("attribute_count",
|
| 152 |
api_name="/generate_persona"
|
| 153 |
)
|
| 154 |
|
|
|
|
| 43 |
- `custom_life_attitude` (str): The life attitude of the persona.
|
| 44 |
- `life_story` (str): A brief life story of the persona.
|
| 45 |
- `interests_hobbies` (str): Interests and hobbies of the persona.
|
| 46 |
+
- `attribute_count` (float): Attribute richness, default to 350.
|
| 47 |
|
| 48 |
You must return a valid JSON object containing exactly these keys.
|
| 49 |
"""
|
|
|
|
| 76 |
if key not in extracted_json:
|
| 77 |
# provide defaults for missing ones
|
| 78 |
if key in ['age', 'attribute_count']:
|
| 79 |
+
extracted_json[key] = 350 if key == 'attribute_count' else 30
|
| 80 |
else:
|
| 81 |
extracted_json[key] = "Unknown"
|
| 82 |
|
|
|
|
| 96 |
"custom_life_attitude": "Optimistic",
|
| 97 |
"life_story": "A standard professional background with a passion for their field.",
|
| 98 |
"interests_hobbies": "Technology, Reading",
|
| 99 |
+
"attribute_count": 350
|
| 100 |
}
|
| 101 |
|
| 102 |
def generate_personas(business_description, customer_profile, num_personas, blablador_api_key=None):
|
|
|
|
| 148 |
custom_life_attitude=str(params.get("custom_life_attitude", "Optimistic")),
|
| 149 |
life_story=str(params.get("life_story", "A standard professional background with a passion for their field.")),
|
| 150 |
interests_hobbies=str(params.get("interests_hobbies", "Technology, Reading")),
|
| 151 |
+
attribute_count=float(params.get("attribute_count", 350)),
|
| 152 |
api_name="/generate_persona"
|
| 153 |
)
|
| 154 |
|
test_api.py
CHANGED
|
@@ -25,7 +25,7 @@ def test_extract_persona_parameters_success():
|
|
| 25 |
with patch('tinytroupe.openai_utils.client') as mock_client:
|
| 26 |
mock_instance = MagicMock()
|
| 27 |
mock_instance.send_message.return_value = {
|
| 28 |
-
"content": '{"age": 25, "gender": "Female", "occupation": "Engineer", "city": "NYC", "country": "USA", "custom_values": "Innovation", "custom_life_attitude": "Positive", "life_story": "A story", "interests_hobbies": "Coding", "attribute_count":
|
| 29 |
}
|
| 30 |
mock_client.return_value = mock_instance
|
| 31 |
|
|
@@ -45,7 +45,7 @@ def test_generate_personas(mock_client_class):
|
|
| 45 |
"age": 25, "gender": "Female", "occupation": "Engineer",
|
| 46 |
"city": "NYC", "country": "USA", "custom_values": "Innovation",
|
| 47 |
"custom_life_attitude": "Positive", "life_story": "A story",
|
| 48 |
-
"interests_hobbies": "Coding", "attribute_count":
|
| 49 |
}
|
| 50 |
|
| 51 |
# We need an API key to pass the check
|
|
|
|
| 25 |
with patch('tinytroupe.openai_utils.client') as mock_client:
|
| 26 |
mock_instance = MagicMock()
|
| 27 |
mock_instance.send_message.return_value = {
|
| 28 |
+
"content": '{"age": 25, "gender": "Female", "occupation": "Engineer", "city": "NYC", "country": "USA", "custom_values": "Innovation", "custom_life_attitude": "Positive", "life_story": "A story", "interests_hobbies": "Coding", "attribute_count": 350}'
|
| 29 |
}
|
| 30 |
mock_client.return_value = mock_instance
|
| 31 |
|
|
|
|
| 45 |
"age": 25, "gender": "Female", "occupation": "Engineer",
|
| 46 |
"city": "NYC", "country": "USA", "custom_values": "Innovation",
|
| 47 |
"custom_life_attitude": "Positive", "life_story": "A story",
|
| 48 |
+
"interests_hobbies": "Coding", "attribute_count": 350
|
| 49 |
}
|
| 50 |
|
| 51 |
# We need an API key to pass the check
|