Srinivasulu kethanaboina commited on
Commit
4682aeb
·
verified ·
1 Parent(s): 0b40cdf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -3,18 +3,23 @@ from fastapi import FastAPI
3
  from fastapi.staticfiles import StaticFiles
4
  import uvicorn
5
 
6
-
7
  app = FastAPI()
8
 
 
 
 
 
9
 
10
- block = gr.Blocks().queue()
11
- with block:
12
- prompt = gr.Text()
13
- output = gr.Text()
14
-
15
- btn = gr.Button("Generate")
16
- btn.click(lambda x:x, inputs=[prompt], outputs=[output])
17
 
 
18
  app.mount("/static", StaticFiles(directory="static", html=True), name="static")
19
- app = gr.mount_gradio_app(app, block, "/", gradio_api_url="http://localhost:7860/")
20
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
 
 
 
 
 
3
  from fastapi.staticfiles import StaticFiles
4
  import uvicorn
5
 
6
+ # Initialize FastAPI app
7
  app = FastAPI()
8
 
9
+ # Define a function for the chat interface
10
+ def respond_to_chat(history, message):
11
+ response = f"Hello, {message}!"
12
+ return response, history
13
 
14
+ # Create Gradio ChatInterface
15
+ chat = gr.ChatInterface(fn=respond_to_chat, title="Chat with AI")
 
 
 
 
 
16
 
17
+ # Mount static files
18
  app.mount("/static", StaticFiles(directory="static", html=True), name="static")
19
+
20
+ # Mount Gradio ChatInterface to FastAPI app
21
+ app = gr.mount_gradio_app(app, chat, "/", gradio_api_url="http://localhost:7860/")
22
+
23
+ # Run the app with uvicorn
24
+ if __name__ == "__main__":
25
+ uvicorn.run(app, host="0.0.0.0", port=7860)