pgurazada1 commited on
Commit
1a3009e
·
verified ·
1 Parent(s): fa5b83b

Update chat.py

Browse files
Files changed (1) hide show
  1. chat.py +11 -22
chat.py CHANGED
@@ -123,33 +123,22 @@ def predict(input: str, history: List[Message]):
123
 
124
  response = make_completion(input, history)
125
 
126
- return response
 
127
 
128
- # history.append({"role": "user", "content": input})
129
- # history.append({"role": "assistant", "content": response})
 
 
130
 
131
- # messages = [
132
- # (history[i]["content"], history[i+1]["content"])
133
- # for i in range(0, len(history)-1, 2)
134
- # ]
135
-
136
- # return messages, history
137
 
138
 
139
  with gr.Blocks() as demo:
140
  chatbot = gr.Chatbot(label="CHAT", layout="bubble", likeable=True, show_copy_button=True)
141
- # state = gr.State([])
142
- # with gr.Row():
143
- # txt = gr.Textbox(show_label=True, placeholder="Enter text and press enter")
144
- # txt.submit(predict, [txt, state], [chatbot, state])
145
-
146
- gr.ChatInterface(
147
- fn=predict, chatbot=chatbot,
148
- title="Chat with information about your insurance policy",
149
- textbox=gr.Textbox(show_label=True, placeholder="Enter text and press enter"),
150
- examples=["What is my policy number?", "Are dental expenses covered in my policy?"],
151
- show_progress="full",
152
- concurrency_limit=8
153
- )
154
 
155
  demo.launch(auth=("demouser", os.getenv('PASSWD')))
 
123
 
124
  response = make_completion(input, history)
125
 
126
+ history.append({"role": "user", "content": input})
127
+ history.append({"role": "assistant", "content": response})
128
 
129
+ messages = [
130
+ (history[i]["content"], history[i+1]["content"])
131
+ for i in range(0, len(history)-1, 2)
132
+ ]
133
 
134
+ return messages, history
 
 
 
 
 
135
 
136
 
137
  with gr.Blocks() as demo:
138
  chatbot = gr.Chatbot(label="CHAT", layout="bubble", likeable=True, show_copy_button=True)
139
+ state = gr.State([])
140
+ with gr.Row():
141
+ txt = gr.Textbox(show_label=True, placeholder="Enter text and press enter")
142
+ txt.submit(predict, [txt, state], [chatbot, state])
 
 
 
 
 
 
 
 
 
143
 
144
  demo.launch(auth=("demouser", os.getenv('PASSWD')))