Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
|
10 |
DEFAULT_MAX_TOKENS = 512
|
11 |
DEFAULT_TEMPERATURE = 0.7
|
12 |
DEFAULT_TOP_P = 0.95
|
13 |
-
DEFAULT_SYSTEM_MESSAGE = "You are an expert in environmental psychology. Provide expert recommendations."
|
14 |
|
15 |
def generate_recommendations(comfort, social_interaction, stressors, privacy, open_question, max_tokens=DEFAULT_MAX_TOKENS, temperature=DEFAULT_TEMPERATURE, top_p=DEFAULT_TOP_P, system_message=DEFAULT_SYSTEM_MESSAGE):
|
16 |
# Construct the input message for the model with context
|
@@ -21,7 +21,7 @@ def generate_recommendations(comfort, social_interaction, stressors, privacy, op
|
|
21 |
f"Environmental Stressors: {stressors}\n"
|
22 |
f"Privacy and Personal Space: {privacy}\n"
|
23 |
f"Open-ended Question: {open_question}\n"
|
24 |
-
f"
|
25 |
|
26 |
# Generate recommendations using the Hugging Face model
|
27 |
response = client.chat_completion(
|
@@ -32,6 +32,8 @@ def generate_recommendations(comfort, social_interaction, stressors, privacy, op
|
|
32 |
)
|
33 |
|
34 |
recommendations = response.choices[0].message['content']
|
|
|
|
|
35 |
return recommendations
|
36 |
|
37 |
def analyze_environmental_concerns(comfort, social_interaction, stressors, privacy, open_question):
|
|
|
10 |
DEFAULT_MAX_TOKENS = 512
|
11 |
DEFAULT_TEMPERATURE = 0.7
|
12 |
DEFAULT_TOP_P = 0.95
|
13 |
+
DEFAULT_SYSTEM_MESSAGE = "You are an expert in environmental psychology. Provide expert recommendations addressing the user directly."
|
14 |
|
15 |
def generate_recommendations(comfort, social_interaction, stressors, privacy, open_question, max_tokens=DEFAULT_MAX_TOKENS, temperature=DEFAULT_TEMPERATURE, top_p=DEFAULT_TOP_P, system_message=DEFAULT_SYSTEM_MESSAGE):
|
16 |
# Construct the input message for the model with context
|
|
|
21 |
f"Environmental Stressors: {stressors}\n"
|
22 |
f"Privacy and Personal Space: {privacy}\n"
|
23 |
f"Open-ended Question: {open_question}\n"
|
24 |
+
f"Please provide personalized recommendations addressing the user directly.")
|
25 |
|
26 |
# Generate recommendations using the Hugging Face model
|
27 |
response = client.chat_completion(
|
|
|
32 |
)
|
33 |
|
34 |
recommendations = response.choices[0].message['content']
|
35 |
+
# Convert the recommendations to address the user in first person
|
36 |
+
recommendations = recommendations.replace("You should", "I recommend that you")
|
37 |
return recommendations
|
38 |
|
39 |
def analyze_environmental_concerns(comfort, social_interaction, stressors, privacy, open_question):
|