deadshot2003 commited on
Commit
106132f
1 Parent(s): b498123

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ import uvicorn
7
+
8
+
9
+ app = FastAPI()
10
+
11
+ chatbot = pipeline(model="google/gemma-7b")
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=" DS Chatbot", description="Enter text to start chatting.")
18
+ @app.get("/")
19
+ async def read_main():
20
+ return {"message": "Append /gradio to the url to see gradio the interface"
21
+ ,"message2": "Append /hello/{any_name} to get a greeting"}
22
+
23
+ @app.get("/hello/{name}")
24
+ async def read_name(name: Union[str, None] = None):
25
+ return { "Hey!": name}
26
+
27
+ # Mount the Gradio app onto the FastAPI app
28
+ app = gr.mount_gradio_app(app, io, path='/gradio')
29
+ if __name__ == "__main__":
30
+ uvicorn.run(app, host="0.0.0.0", port=7860)
31
+