Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ from flask import jsonify
|
|
| 4 |
# import os
|
| 5 |
# import dotenv
|
| 6 |
# import os
|
|
|
|
| 7 |
import gradio
|
| 8 |
|
| 9 |
# app = Flask(__name__)
|
|
@@ -21,30 +22,38 @@ import gradio
|
|
| 21 |
# return jsonify(response)
|
| 22 |
|
| 23 |
# @app.route('/start_game', methods=['GET'])
|
| 24 |
-
|
| 25 |
-
#
|
| 26 |
-
#
|
| 27 |
-
#
|
| 28 |
-
#
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
# @app.route('/health_check', methods=['GET'])
|
| 34 |
def health_check(name):
|
| 35 |
-
response = {"
|
| 36 |
-
return
|
| 37 |
-
|
| 38 |
# @app.route('/load_game', methods=['GET'])
|
| 39 |
# def load_game():
|
| 40 |
# upload_game_docs()
|
| 41 |
# response = {'message': 'Game loaded'}
|
| 42 |
# return jsonify(response)
|
| 43 |
|
| 44 |
-
|
| 45 |
fn=health_check,
|
| 46 |
inputs="text",
|
| 47 |
outputs="text"
|
| 48 |
)
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
|
|
|
| 4 |
# import os
|
| 5 |
# import dotenv
|
| 6 |
# import os
|
| 7 |
+
from chat import start_game
|
| 8 |
import gradio
|
| 9 |
|
| 10 |
# app = Flask(__name__)
|
|
|
|
| 22 |
# return jsonify(response)
|
| 23 |
|
| 24 |
# @app.route('/start_game', methods=['GET'])
|
| 25 |
+
def play_game(game_id, user_id, user_input):
|
| 26 |
+
# inputs = request.args.to_dict()
|
| 27 |
+
# user_id = inputs['user_id']
|
| 28 |
+
# game_id = inputs['game_id']
|
| 29 |
+
# user_input = inputs['user_input']
|
| 30 |
+
gpt_output = chat.start_game(game_id, user_id, user_input)
|
| 31 |
+
response = {'role': 'assistant', 'content': gpt_output}
|
| 32 |
+
return response
|
| 33 |
|
| 34 |
# @app.route('/health_check', methods=['GET'])
|
| 35 |
def health_check(name):
|
| 36 |
+
response = {"role": "assistant", "content": "Hello " + name + "! The site is up"}
|
| 37 |
+
return response)
|
| 38 |
+
|
| 39 |
# @app.route('/load_game', methods=['GET'])
|
| 40 |
# def load_game():
|
| 41 |
# upload_game_docs()
|
| 42 |
# response = {'message': 'Game loaded'}
|
| 43 |
# return jsonify(response)
|
| 44 |
|
| 45 |
+
health_check_gr = gradio.Interface(
|
| 46 |
fn=health_check,
|
| 47 |
inputs="text",
|
| 48 |
outputs="text"
|
| 49 |
)
|
| 50 |
+
|
| 51 |
+
play_game_gr = gradio.Interface(
|
| 52 |
+
fn=play_game,
|
| 53 |
+
inputs="text",
|
| 54 |
+
outputs="text"
|
| 55 |
+
)
|
| 56 |
+
demo = gradio.TabbedInterface([health_check_gr, play_game_gr], ["Health Check", "Play Game"])
|
| 57 |
+
|
| 58 |
+
demo.launch()
|
| 59 |
|