Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,8 +3,12 @@ import google.generativeai as genai
|
|
| 3 |
import logging
|
| 4 |
import gradio as gr
|
| 5 |
from dotenv import load_dotenv
|
|
|
|
| 6 |
import os
|
| 7 |
|
|
|
|
|
|
|
|
|
|
| 8 |
# Load environment variables from .env file
|
| 9 |
load_dotenv()
|
| 10 |
|
|
@@ -57,6 +61,12 @@ chat_session = model.start_chat(
|
|
| 57 |
]
|
| 58 |
)
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
def generate_response(user_input):
|
| 61 |
"""Generate a response using Google Generative AI."""
|
| 62 |
try:
|
|
@@ -80,4 +90,9 @@ iface = gr.Interface(
|
|
| 80 |
)
|
| 81 |
|
| 82 |
if __name__ == "__main__":
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import logging
|
| 4 |
import gradio as gr
|
| 5 |
from dotenv import load_dotenv
|
| 6 |
+
from flask import Flask, send_from_directory
|
| 7 |
import os
|
| 8 |
|
| 9 |
+
# Initialize Flask app
|
| 10 |
+
app = Flask(__name__
|
| 11 |
+
|
| 12 |
# Load environment variables from .env file
|
| 13 |
load_dotenv()
|
| 14 |
|
|
|
|
| 61 |
]
|
| 62 |
)
|
| 63 |
|
| 64 |
+
@app.route('/')
|
| 65 |
+
def index():
|
| 66 |
+
# Serve HTML content
|
| 67 |
+
return send_from_directory(directory='.', path='index.html')
|
| 68 |
+
|
| 69 |
+
|
| 70 |
def generate_response(user_input):
|
| 71 |
"""Generate a response using Google Generative AI."""
|
| 72 |
try:
|
|
|
|
| 90 |
)
|
| 91 |
|
| 92 |
if __name__ == "__main__":
|
| 93 |
+
# Run Gradio in a separate thread
|
| 94 |
+
gradio_thread = threading.Thread(target=run_gradio)
|
| 95 |
+
gradio_thread.start()
|
| 96 |
+
|
| 97 |
+
# Run Flask app
|
| 98 |
+
app.run(debug=True)
|