Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,10 +8,19 @@ OPENAI_API_KEY=os.getenv('OPENAI_API_KEY')
|
|
8 |
USER=os.getenv('USER')
|
9 |
PASS=os.getenv('PASS')
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
def predict(message, history):
|
13 |
history_openai_format = []
|
14 |
for human, assistant in history:
|
|
|
15 |
history_openai_format.append({"role": "user", "content": human })
|
16 |
history_openai_format.append({"role": "assistant", "content":assistant})
|
17 |
history_openai_format.append({"role": "user", "content": message})
|
|
|
8 |
USER=os.getenv('USER')
|
9 |
PASS=os.getenv('PASS')
|
10 |
|
11 |
+
template = """You are a helpful assistant to answer all user queries.
|
12 |
+
{history}
|
13 |
+
User: {message}
|
14 |
+
Chatbot:"""
|
15 |
+
|
16 |
+
prompt = PromptTemplate(
|
17 |
+
input_variables=["history", "message"], template=template
|
18 |
+
)
|
19 |
|
20 |
def predict(message, history):
|
21 |
history_openai_format = []
|
22 |
for human, assistant in history:
|
23 |
+
history_openai_format.append({"role": "system", "content": prompt })
|
24 |
history_openai_format.append({"role": "user", "content": human })
|
25 |
history_openai_format.append({"role": "assistant", "content":assistant})
|
26 |
history_openai_format.append({"role": "user", "content": message})
|