Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,8 @@ Human: {input}
|
|
44 |
AI:"""
|
45 |
prompt = PromptTemplate(template=template, input_variables=["history", "input"])
|
46 |
|
47 |
-
|
|
|
48 |
|
49 |
with gr.Blocks() as demo:
|
50 |
chatbot = gr.Chatbot()
|
@@ -57,7 +58,7 @@ with gr.Blocks() as demo:
|
|
57 |
@spaces.GPU
|
58 |
def bot(history):
|
59 |
print("Question: ", history[-1][0])
|
60 |
-
bot_message = llm_chain.
|
61 |
print("Response: ", bot_message)
|
62 |
history[-1][1] = ""
|
63 |
history[-1][1] += bot_message
|
|
|
44 |
AI:"""
|
45 |
prompt = PromptTemplate(template=template, input_variables=["history", "input"])
|
46 |
|
47 |
+
memory = ConversationBufferMemory(memory_key="history", llm = llm, prompt = prompt)
|
48 |
+
llm_chain = ConversationChain(prompt=prompt, llm=llm, memory = memory)
|
49 |
|
50 |
with gr.Blocks() as demo:
|
51 |
chatbot = gr.Chatbot()
|
|
|
58 |
@spaces.GPU
|
59 |
def bot(history):
|
60 |
print("Question: ", history[-1][0])
|
61 |
+
bot_message = llm_chain.invoke(question=history[-1][0])
|
62 |
print("Response: ", bot_message)
|
63 |
history[-1][1] = ""
|
64 |
history[-1][1] += bot_message
|