deadshot2003 commited on
Commit
397ce09
·
verified ·
1 Parent(s): 1d979ff

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+ from fastapi import FastAPI
4
+ from gradio_client import Client
5
+ from typing import Union
6
+
7
+
8
+ app = FastAPI()
9
+
10
+ chatbot = pipeline(model="facebook/blenderbot-400M-distill")
11
+
12
+ def DS_chatbot(message,history):
13
+ conversation = chatbot(message)
14
+ return conversation[0]['generated_text']
15
+
16
+ io = gr.ChatInterface(DS_chatbot, title=" DS Chatbot", description="Enter text to start chatting.")
17
+ @app.get("/")
18
+ def read_main():
19
+ return {"message": "Append /gradio to the url to see gradio the interface"}
20
+
21
+ @app.get("/hello/{name}")
22
+ def read_name(name: Union[str, None] = None):
23
+ return { "Hey!": name}
24
+
25
+ # Mount the Gradio app onto the FastAPI app
26
+ app = gr.mount_gradio_app(app, io, path='/gradio')