SoSa123456 commited on
Commit
8af9560
·
1 Parent(s): 9cdeb41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -55
app.py CHANGED
@@ -8,61 +8,15 @@ import os
8
  # Initialize the language model
9
  llm = HuggingFaceHub(repo_id="tiiuae/falcon-7b-instruct", model_kwargs={"temperature":0.6})
10
 
11
- def generate_emotional_report(user_emotion_goals, user_emotional_spaces=None, user_communication_method=None, user_listening_practices=None, user_reflection_methods=None, user_design_principles=None, user_understanding_of_principles=None, user_application_of_principles=None, user_review_and_adjustment=None, user_finalizing_emotional_report=None):
12
- # Check if user_emotion_goals is not None
13
- if user_emotion_goals is not None:
14
- # Generate the other variables based on user_emotion_goals
15
- user_emotional_spaces = llm(f"Generate emotional spaces based on {user_emotion_goals}")
16
- user_communication_method = llm(f"Generate communication method based on {user_emotion_goals}")
17
- user_listening_practices = llm(f"Generate listening practices based on {user_emotion_goals}")
18
- user_reflection_methods = llm(f"Generate reflection methods based on {user_emotion_goals}")
19
- user_design_principles = llm(f"Generate design principles based on {user_emotion_goals}")
20
- user_understanding_of_principles = llm(f"Generate understanding of principles based on {user_emotion_goals}")
21
- user_application_of_principles = llm(f"Generate application of principles based on {user_emotion_goals}")
22
- user_review_and_adjustment = llm(f"Generate review and adjustment based on {user_emotion_goals}")
23
- user_finalizing_emotional_report = llm(f"Generate finalizing emotional report based on {user_emotion_goals}")
24
 
25
- # Define your chat template here
26
- chat_template = f"""
27
- # Step 1: Identify the Emotional Goals
28
- [ASSISTANT] What kind of emotions would you like to evoke in your partner? The user's response is: {user_emotion_goals}
29
-
30
- # Step 2: Create Emotional Spaces
31
- [ASSISTANT] What environments or activities can we design to elicit these emotions? The user's response is: {user_emotional_spaces}
32
-
33
- # Step 3: Communicate Openly
34
- [ASSISTANT] How can we express feelings and desires openly? The user's response is: {user_communication_method}
35
-
36
- # Step 4: Listen Actively
37
- [ASSISTANT] How can we pay attention to our partner's feelings and needs? The user's response is: {user_listening_practices}
38
-
39
- # Step 5: Reflect on Emotions
40
- [ASSISTANT] How can we encourage reflection on the emotions experienced during shared activities? The user's response is: {user_reflection_methods}
41
-
42
- # Step 6: Implement Emotional Design Principles
43
- [ASSISTANT] How can we integrate aesthetics, usability, and storytelling in our relationship? The user's response is: {user_design_principles}
44
-
45
- # Step 7: Understand Emotional Design Principles
46
- [ASSISTANT] What principles of emotional design are applicable to our relationship? The user's response is: {user_understanding_of_principles}
47
-
48
- # Step 8: Apply Emotional Design Principles
49
- [ASSISTANT] How can we apply these principles to our relationship? The user's response is: {user_application_of_principles}
50
-
51
- # Step 9: Review Emotional Design Principles
52
- [ASSISTANT] How can we review and adjust our application of these principles? The user's response is: {user_review_and_adjustment}
53
-
54
- # Step 10: Finalize Emotional Report
55
- [ASSISTANT] Let's finalize our emotional report. The user's response is: {user_finalizing_emotional_report}
56
- """
57
- # Pass the chat template to the language model
58
- response = llm(chat_template)
59
-
60
- # Return the response
61
- return response
62
-
63
- # Create a Gradio ChatInterface
64
- iface = gr.ChatInterface(fn=generate_emotional_report, inputs="text", outputs="text", title="Emotional Design Report Generator", description="Enter your emotional goals and let the assistant generate an emotional design report.")
65
 
66
  # Launch the interface
67
- iface.launch()
68
-
 
8
  # Initialize the language model
9
  llm = HuggingFaceHub(repo_id="tiiuae/falcon-7b-instruct", model_kwargs={"temperature":0.6})
10
 
11
+ def chat(user_message):
12
+ # Generate a response from the language model
13
+ response = llm(user_message)
14
+
15
+ # Return the response
16
+ return response
 
 
 
 
 
 
 
17
 
18
+ # Create a Gradio interface
19
+ iface = gr.Interface(fn=chat, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  # Launch the interface
22
+ iface.launch()