ai-api-test / main.py
Rupnil's picture
Update main.py
fa7383f
raw
history blame contribute delete
904 Bytes
from flask import Flask
from gradio_client import Client
import time
from multiprocessing import Process
from flask_cors import CORS, cross_origin
app = Flask(__name__)
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
@app.route('/')
def hello():
return '{"status": {"details": {"code": 200, "message": "working"}}}'
@app.route('/api/<string:query>')
def api(query):
client = Client("https://theblueberry-ai-mist-chat.hf.space/")
result = client.predict(
"You are AmeuChat, a helpful intelligent bot created by Rupnil Mondal. You were created in Rupnil's Computer." + query, # str in 'Message' Textbox component
api_name = "/chat"
)
return result
def record_loop():
while True:
print("loop running")
time.sleep(5)
if __name__ == "__main__":
p = Process(target=record_loop)
p.start()
app.run(debug=True, use_reloader=False)
p.join()