Spaces:
Sleeping
Sleeping
justalphie
commited on
Commit
·
1e4dce5
1
Parent(s):
92ba8ca
Add doc strings
Browse files
app.py
CHANGED
@@ -8,6 +8,10 @@ co = cohere.Client(COHERE_KEY)
|
|
8 |
|
9 |
#list_history = [["question", "answer"], ["how", "how what..."]]
|
10 |
def convert_history(list_history):
|
|
|
|
|
|
|
|
|
11 |
chat_history = [
|
12 |
{"role": "SYSTEM", "text": open("prompt.md","r",encoding="UTF-8").read()}
|
13 |
]
|
@@ -22,6 +26,9 @@ def convert_history(list_history):
|
|
22 |
|
23 |
|
24 |
def reply(message:str, history:list):
|
|
|
|
|
|
|
25 |
chat_history = convert_history(history)
|
26 |
response = co.chat_stream(
|
27 |
message=message,
|
|
|
8 |
|
9 |
#list_history = [["question", "answer"], ["how", "how what..."]]
|
10 |
def convert_history(list_history):
|
11 |
+
"""
|
12 |
+
Applies the prompt.
|
13 |
+
Converts the chat history structure taken by Gradio to the structure suitable for Cohere.
|
14 |
+
"""
|
15 |
chat_history = [
|
16 |
{"role": "SYSTEM", "text": open("prompt.md","r",encoding="UTF-8").read()}
|
17 |
]
|
|
|
26 |
|
27 |
|
28 |
def reply(message:str, history:list):
|
29 |
+
"""
|
30 |
+
Takes the input message of the user and chat history and streams the reply of the chatbot.
|
31 |
+
"""
|
32 |
chat_history = convert_history(history)
|
33 |
response = co.chat_stream(
|
34 |
message=message,
|