Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,47 +10,14 @@ app = FastAPI()
|
|
10 |
|
11 |
chatbot = pipeline(model="Kaludi/Customer-Support-Assistant-V2")
|
12 |
|
13 |
-
def print_like_dislike(x: gr.LikeData):
|
14 |
-
print(x.index, x.value, x.liked)
|
15 |
-
def add_message(history, message):
|
16 |
-
for x in message["files"]:
|
17 |
-
history.append(((x,), None))
|
18 |
-
if message["text"] is not None:
|
19 |
-
history.append((message["text"], None))
|
20 |
-
return history, gr.MultimodalTextbox(value=None, interactive=False)
|
21 |
-
|
22 |
def DS_chatbot(message,history):
|
23 |
conversation = chatbot(message)
|
24 |
return conversation[0]['generated_text']
|
25 |
|
26 |
-
|
27 |
-
with gr.Blocks() as demo:
|
28 |
-
chat_bot = gr.Chatbot(
|
29 |
-
[],
|
30 |
-
elem_id="Customer Service Bot",
|
31 |
-
bubble_full_width=False,
|
32 |
-
)
|
33 |
-
|
34 |
-
chat_input = gr.MultimodalTextbox(interactive=True, file_types=["image"], placeholder="Enter message or upload file...", show_label=False)
|
35 |
-
|
36 |
-
chat_msg = chat_input.submit(add_message, [chat_bot, chat_input], [chat_bot, chat_input])
|
37 |
-
bot_msg = chat_msg.then(DS_chatbot, chat_bot, chat_bot, api_name="bot_response")
|
38 |
-
bot_msg.then(lambda: gr.MultimodalTextbox(interactive=True), None, [chat_input])
|
39 |
-
|
40 |
-
chat_bot.like(print_like_dislike, None, None)
|
41 |
-
|
42 |
-
@app.get("/")
|
43 |
-
async def read_main():
|
44 |
-
return {"message": "Append /gradio to the url to see gradio the interface"
|
45 |
-
,"message2": "Append /hello/{any_name} to get a greeting"}
|
46 |
-
|
47 |
-
'''@app.get("/hello/{name}")
|
48 |
-
async def read_name(name: Union[str, None] = None):
|
49 |
-
return { "Hey!": name}'''
|
50 |
|
51 |
|
52 |
# Mount the Gradio app onto the FastAPI app
|
53 |
-
app = gr.mount_gradio_app(app,
|
54 |
if __name__ == "__main__":
|
55 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
56 |
-
|
|
|
10 |
|
11 |
chatbot = pipeline(model="Kaludi/Customer-Support-Assistant-V2")
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
def DS_chatbot(message,history):
|
14 |
conversation = chatbot(message)
|
15 |
return conversation[0]['generated_text']
|
16 |
|
17 |
+
io = gr.ChatInterface(DS_chatbot, title="Customer Service Bot", description="Enter your query.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
|
20 |
# Mount the Gradio app onto the FastAPI app
|
21 |
+
app = gr.mount_gradio_app(app, io, path='/')
|
22 |
if __name__ == "__main__":
|
23 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|