Chris Alexiuk
commited on
Commit
·
7540eba
1
Parent(s):
6724098
Update app.py
Browse files
app.py
CHANGED
@@ -4,21 +4,16 @@
|
|
4 |
|
5 |
import openai #importing openai for API usage
|
6 |
import chainlit as cl #importing chainlit for our app
|
|
|
7 |
|
8 |
# You only need the api key inserted here if it's not in your .env file
|
9 |
#openai.api_key = "YOUR_API_KEY"
|
10 |
|
11 |
-
|
|
|
|
|
|
|
12 |
|
13 |
-
model_name = "gpt-3.5-turbo"
|
14 |
-
# model_name = "gpt-4"
|
15 |
-
settings = {
|
16 |
-
"temperature": 0.7, # higher value increases output diveresity/randomness
|
17 |
-
"max_tokens": 500, # maximum length of output response
|
18 |
-
"top_p": 1, # choose only the top x% of possible words to return
|
19 |
-
"frequency_penalty": 0, # higher value will result in the model being more conservative in its use of repeated tokens.
|
20 |
-
"presence_penalty": 0, # higher value will result in the model being more likely to generate tokens that have not yet been included in the generated text
|
21 |
-
}
|
22 |
|
23 |
@cl.on_chat_start # marks a function that will be executed at the start of a user session
|
24 |
async def start_chat():
|
@@ -40,12 +35,7 @@ async def start_chat():
|
|
40 |
step=0.1,
|
41 |
)
|
42 |
]
|
43 |
-
)
|
44 |
-
|
45 |
-
cl.user_session.set(
|
46 |
-
"message_history",
|
47 |
-
[{"role": "system", "content": "You are a helpful assistant."}],
|
48 |
-
)
|
49 |
|
50 |
@cl.on_settings_update
|
51 |
async def setup_agent(settings):
|
|
|
4 |
|
5 |
import openai #importing openai for API usage
|
6 |
import chainlit as cl #importing chainlit for our app
|
7 |
+
from chainlit.input_widget import Select, Switch, Slider #importing chainlit settings selection tools
|
8 |
|
9 |
# You only need the api key inserted here if it's not in your .env file
|
10 |
#openai.api_key = "YOUR_API_KEY"
|
11 |
|
12 |
+
system_template = """
|
13 |
+
You are a helpful assistant who always speaks in a pleasant tone!
|
14 |
+
"""
|
15 |
+
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
@cl.on_chat_start # marks a function that will be executed at the start of a user session
|
19 |
async def start_chat():
|
|
|
35 |
step=0.1,
|
36 |
)
|
37 |
]
|
38 |
+
).send()
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
@cl.on_settings_update
|
41 |
async def setup_agent(settings):
|