updated code
Browse files
app.py
CHANGED
@@ -2,6 +2,10 @@
|
|
2 |
"""
|
3 |
IMPORTS HERE
|
4 |
"""
|
|
|
|
|
|
|
|
|
5 |
|
6 |
### Global Section ###
|
7 |
"""
|
@@ -23,11 +27,20 @@ async def on_chat_start():
|
|
23 |
### Rename Chains ###
|
24 |
@cl.author_rename
|
25 |
def rename(orig_author: str):
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
|
28 |
### On Message Section ###
|
29 |
@cl.on_message
|
30 |
async def main(message: cl.Message):
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
2 |
"""
|
3 |
IMPORTS HERE
|
4 |
"""
|
5 |
+
# Example Imports (adjust based on actual needs)
|
6 |
+
import chainlit as cl
|
7 |
+
from langchain.chat_models import ChatOpenAI
|
8 |
+
from langchain.chains import ConversationChain
|
9 |
|
10 |
### Global Section ###
|
11 |
"""
|
|
|
27 |
### Rename Chains ###
|
28 |
@cl.author_rename
|
29 |
def rename(orig_author: str):
|
30 |
+
if orig_author == "user":
|
31 |
+
return "You"
|
32 |
+
elif orig_author == "system":
|
33 |
+
return "Assistant"
|
34 |
+
return orig_author
|
35 |
|
36 |
### On Message Section ###
|
37 |
@cl.on_message
|
38 |
async def main(message: cl.Message):
|
39 |
+
# Get the user input message
|
40 |
+
user_message = message.content
|
41 |
+
|
42 |
+
# Interact with a pre-built LLM conversation chain or other models
|
43 |
+
response = conversation_chain.run(input=user_message)
|
44 |
+
|
45 |
+
# Send the response back to the user
|
46 |
+
await cl.Message(content=response).send()
|