sahanes commited on
Commit
14f778e
1 Parent(s): 449ee66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -20
app.py CHANGED
@@ -1,12 +1,8 @@
1
- # # You can find this code for Chainlit python streaming here (https://docs.chainlit.io/concepts/streaming/python)
2
-
3
  import chainlit as cl
4
- # Define a dictionary to keep track of user states
5
- from openai import AsyncOpenAI # importing openai for API usage
6
 
7
  client = AsyncOpenAI()
8
 
9
-
10
  settings = {
11
  "model": "gpt-3.5-turbo",
12
  "temperature": 0.7,
@@ -18,36 +14,32 @@ settings = {
18
 
19
  @cl.set_starters
20
  async def set_starters():
21
-
22
  return [
23
  cl.Starter(
24
  label="Morning routine ideation",
25
  message="Can you help me create a personalized morning routine that would help increase my productivity throughout the day? Start by asking me about my current habits and what activities energize me in the morning.",
26
  icon="/public/idea.svg",
27
- ),
28
-
29
  cl.Starter(
30
  label="Explain superconductors",
31
  message="Explain superconductors like I'm five years old.",
32
  icon="/public/learn.svg",
33
- ),
34
-
35
  cl.Starter(
36
  label="Python script for daily email reports",
37
  message="Write a script to automate sending daily email reports in Python, and walk me through how I would set it up.",
38
  icon="/public/terminal.svg",
39
- ),
40
-
41
  cl.Starter(
42
  label="Text inviting friend to wedding",
43
  message="Write a text asking a friend to be my plus-one at a wedding next month. I want to keep it super short and casual, and offer an out.",
44
  icon="/public/write.svg",
45
- )
46
- ]
 
47
  @cl.on_message
48
  async def on_message(message):
49
-
50
- content=message.content
51
  if "morning routine" in content:
52
  await cl.Message(content="Sure! Let's start with your current habits. What time do you usually wake up, and what are the first things you do after waking up?").send()
53
  elif "superconductors" in content:
@@ -79,11 +71,10 @@ async def on_message(message):
79
  server.quit()
80
 
81
  send_email("Daily Report", "Here is the daily report...", "recipient@example.com")
82
-
83
- """).send()
84
  elif "Text inviting friend to wedding" in content:
85
  await cl.Message("Hey! I have a wedding to attend next month and I'd love for you to be my plus-one. No worries if you can't make it, just thought I'd ask!").send()
86
-
87
  #**********************************
88
  prompt_messages = [
89
  {"role": "user", "content": content}
@@ -100,4 +91,4 @@ async def on_message(message):
100
  await msg.stream_token(token)
101
 
102
  # Send the final message
103
- await msg.send()
 
 
 
1
  import chainlit as cl
2
+ from openai import AsyncOpenAI
 
3
 
4
  client = AsyncOpenAI()
5
 
 
6
  settings = {
7
  "model": "gpt-3.5-turbo",
8
  "temperature": 0.7,
 
14
 
15
  @cl.set_starters
16
  async def set_starters():
 
17
  return [
18
  cl.Starter(
19
  label="Morning routine ideation",
20
  message="Can you help me create a personalized morning routine that would help increase my productivity throughout the day? Start by asking me about my current habits and what activities energize me in the morning.",
21
  icon="/public/idea.svg",
22
+ ),
 
23
  cl.Starter(
24
  label="Explain superconductors",
25
  message="Explain superconductors like I'm five years old.",
26
  icon="/public/learn.svg",
27
+ ),
 
28
  cl.Starter(
29
  label="Python script for daily email reports",
30
  message="Write a script to automate sending daily email reports in Python, and walk me through how I would set it up.",
31
  icon="/public/terminal.svg",
32
+ ),
 
33
  cl.Starter(
34
  label="Text inviting friend to wedding",
35
  message="Write a text asking a friend to be my plus-one at a wedding next month. I want to keep it super short and casual, and offer an out.",
36
  icon="/public/write.svg",
37
+ )
38
+ ]
39
+
40
  @cl.on_message
41
  async def on_message(message):
42
+ content = message.content
 
43
  if "morning routine" in content:
44
  await cl.Message(content="Sure! Let's start with your current habits. What time do you usually wake up, and what are the first things you do after waking up?").send()
45
  elif "superconductors" in content:
 
71
  server.quit()
72
 
73
  send_email("Daily Report", "Here is the daily report...", "recipient@example.com")
74
+ """).send()
 
75
  elif "Text inviting friend to wedding" in content:
76
  await cl.Message("Hey! I have a wedding to attend next month and I'd love for you to be my plus-one. No worries if you can't make it, just thought I'd ask!").send()
77
+
78
  #**********************************
79
  prompt_messages = [
80
  {"role": "user", "content": content}
 
91
  await msg.stream_token(token)
92
 
93
  # Send the final message
94
+ await msg.send()