Spaces:
Sleeping
Sleeping
Add descriptions and examples for each aspect
Browse files
app.py
CHANGED
@@ -10,6 +10,58 @@ from dotenv import load_dotenv
|
|
10 |
|
11 |
load_dotenv()
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
# Aspect-specific system templates
|
14 |
ASPECT_TEMPLATES = {
|
15 |
"Concept Simplification": """You are an expert at breaking down complex concepts into simple, understandable terms.
|
@@ -72,16 +124,26 @@ USER_TEMPLATES = {
|
|
72 |
|
73 |
@cl.on_chat_start
|
74 |
async def start_chat():
|
75 |
-
# Create aspect selection buttons
|
76 |
aspects = list(ASPECT_TEMPLATES.keys())
|
77 |
-
actions = [
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
# Send welcome message with aspect selection
|
83 |
await cl.Message(
|
84 |
-
content="Welcome! Please select an aspect for our conversation:",
|
85 |
actions=actions
|
86 |
).send()
|
87 |
|
@@ -95,9 +157,18 @@ async def on_action(action):
|
|
95 |
# Store the selected aspect in the user session
|
96 |
cl.user_session.set("selected_aspect", action.value)
|
97 |
|
98 |
-
#
|
|
|
|
|
|
|
|
|
99 |
await cl.Message(
|
100 |
-
content=f"You've selected: {action.value}
|
|
|
|
|
|
|
|
|
|
|
101 |
).send()
|
102 |
|
103 |
@cl.on_message
|
|
|
10 |
|
11 |
load_dotenv()
|
12 |
|
13 |
+
# Aspect descriptions and examples
|
14 |
+
ASPECT_INFO = {
|
15 |
+
"Concept Simplification": {
|
16 |
+
"description": "Break down complex topics into simple, understandable terms",
|
17 |
+
"examples": [
|
18 |
+
"Explain quantum computing in simple terms",
|
19 |
+
"How does blockchain work?",
|
20 |
+
"What is machine learning?"
|
21 |
+
]
|
22 |
+
},
|
23 |
+
"Summarization": {
|
24 |
+
"description": "Extract and present key information concisely",
|
25 |
+
"examples": [
|
26 |
+
"Summarize the key points of climate change",
|
27 |
+
"Give me a brief overview of the internet's history",
|
28 |
+
"What are the main ideas in this article?"
|
29 |
+
]
|
30 |
+
},
|
31 |
+
"Creativity": {
|
32 |
+
"description": "Generate innovative ideas and unique perspectives",
|
33 |
+
"examples": [
|
34 |
+
"Generate ideas for a sustainable city",
|
35 |
+
"How could we improve remote work?",
|
36 |
+
"What are some creative solutions to reduce plastic waste?"
|
37 |
+
]
|
38 |
+
},
|
39 |
+
"Narrative Structure": {
|
40 |
+
"description": "Organize information into compelling stories",
|
41 |
+
"examples": [
|
42 |
+
"Help me structure a story about time travel",
|
43 |
+
"Organize the history of AI as a narrative",
|
44 |
+
"How can I make this presentation more engaging?"
|
45 |
+
]
|
46 |
+
},
|
47 |
+
"Arithmetic Reasoning": {
|
48 |
+
"description": "Solve mathematical problems step by step",
|
49 |
+
"examples": [
|
50 |
+
"Calculate compound interest on $1000 at 5% for 3 years",
|
51 |
+
"If a train travels at 60 mph for 2.5 hours, how far does it go?",
|
52 |
+
"What's the probability of getting three heads in a row?"
|
53 |
+
]
|
54 |
+
},
|
55 |
+
"Conversational Tone": {
|
56 |
+
"description": "Engage in natural, friendly discussions",
|
57 |
+
"examples": [
|
58 |
+
"Tell me about your favorite book",
|
59 |
+
"What's your opinion on artificial intelligence?",
|
60 |
+
"How do you feel about remote work?"
|
61 |
+
]
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
# Aspect-specific system templates
|
66 |
ASPECT_TEMPLATES = {
|
67 |
"Concept Simplification": """You are an expert at breaking down complex concepts into simple, understandable terms.
|
|
|
124 |
|
125 |
@cl.on_chat_start
|
126 |
async def start_chat():
|
127 |
+
# Create aspect selection buttons with descriptions
|
128 |
aspects = list(ASPECT_TEMPLATES.keys())
|
129 |
+
actions = []
|
130 |
+
|
131 |
+
for aspect in aspects:
|
132 |
+
info = ASPECT_INFO[aspect]
|
133 |
+
description = f"{info['description']}\n\nExample tasks:\n" + "\n".join(f"• {example}" for example in info['examples'])
|
134 |
+
|
135 |
+
actions.append(
|
136 |
+
cl.Action(
|
137 |
+
name=aspect,
|
138 |
+
value=aspect,
|
139 |
+
label=aspect,
|
140 |
+
description=description
|
141 |
+
)
|
142 |
+
)
|
143 |
|
144 |
# Send welcome message with aspect selection
|
145 |
await cl.Message(
|
146 |
+
content="Welcome! Please select an aspect for our conversation. Hover over each option to see examples and descriptions:",
|
147 |
actions=actions
|
148 |
).send()
|
149 |
|
|
|
157 |
# Store the selected aspect in the user session
|
158 |
cl.user_session.set("selected_aspect", action.value)
|
159 |
|
160 |
+
# Get aspect info for the confirmation message
|
161 |
+
info = ASPECT_INFO[action.value]
|
162 |
+
examples = "\n".join(f"• {example}" for example in info['examples'][:2]) # Show first two examples
|
163 |
+
|
164 |
+
# Send confirmation message with examples
|
165 |
await cl.Message(
|
166 |
+
content=f"""You've selected: {action.value}
|
167 |
+
|
168 |
+
{info['description']}
|
169 |
+
|
170 |
+
Try asking something like:
|
171 |
+
{examples}"""
|
172 |
).send()
|
173 |
|
174 |
@cl.on_message
|