Spaces:
Runtime error
Runtime error
Commit
·
9813972
1
Parent(s):
038b907
Update app.py
Browse files
app.py
CHANGED
@@ -22,27 +22,6 @@ from langchain.schema import (
|
|
22 |
from langchain.utilities import WikipediaAPIWrapper
|
23 |
from langchain.tools import AIPluginTool
|
24 |
|
25 |
-
# Question- how can one set up a system message for their Chatbot while using ChatInterface
|
26 |
-
# Example system message : system = SystemMessage(content = "You are a helpful AI assistant")
|
27 |
-
|
28 |
-
# driver
|
29 |
-
def predict(user_input, chatbot):
|
30 |
-
|
31 |
-
chat = ChatOpenAI(temperature=1.0, streaming=True, model='gpt-3.5-turbo-0613')
|
32 |
-
messages=[]
|
33 |
-
|
34 |
-
for conv in chatbot:
|
35 |
-
human = HumanMessage(content=conv[0])
|
36 |
-
ai = AIMessage(content=conv[1])
|
37 |
-
messages.append(human)
|
38 |
-
messages.append(ai)
|
39 |
-
|
40 |
-
messages.append(HumanMessage(content=user_input))
|
41 |
-
|
42 |
-
# getting gpt3.5's response
|
43 |
-
gpt_response = chat(messages)
|
44 |
-
return gpt_response.content
|
45 |
-
|
46 |
def predict(inputs, chatbot):
|
47 |
|
48 |
messages = []
|
@@ -69,6 +48,4 @@ def predict(inputs, chatbot):
|
|
69 |
partial_message = partial_message + chunk['choices'][0]['delta']['content']
|
70 |
yield partial_message
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
gr.ChatInterface(predict, delete_last_btn="del").queue().launch(share=False, debug=True) #examples=["How are you?", "What's up?"],
|
|
|
22 |
from langchain.utilities import WikipediaAPIWrapper
|
23 |
from langchain.tools import AIPluginTool
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
def predict(inputs, chatbot):
|
26 |
|
27 |
messages = []
|
|
|
48 |
partial_message = partial_message + chunk['choices'][0]['delta']['content']
|
49 |
yield partial_message
|
50 |
|
51 |
+
gr.ChatInterface(predict).queue().launch()
|
|
|
|