forked from ayushsubedi/newsbot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.py
More file actions
31 lines (25 loc) · 738 Bytes
/
run.py
File metadata and controls
31 lines (25 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import gradio as gr
from threading import Thread
from app.chatbot import generate_response
from app.routes import app
# Gradio interface for the chatbot
def gradio_chatbot(input_text):
response = generate_response(input_text)
return response
# Initialize Gradio interface
gradio_interface = gr.Interface(
fn=gradio_chatbot,
inputs="text",
outputs="text"
)
# Function to run Flask app
def run_flask():
app.run(port=5000, debug=True, threaded=False)
def run_gradio():
# Set share=True for public access
gradio_interface.launch(share=False)
if __name__ == "__main__":
# Start Flask and Gradio in separate threads
flask_thread = Thread(target=run_flask)
flask_thread.start()
run_gradio()