Spaces:
Sleeping
Sleeping
import chat | |
from chat import start_game | |
import gradio | |
def initialize_game(game_id, user_id): | |
result = chat.initialize_game(user_id, game_id) | |
response = {'role': 'assistant', 'content': result} | |
return response | |
def play_game(game_id, user_id, user_input): | |
gpt_output = chat.start_game(game_id, user_id, user_input) | |
response = {'role': 'assistant', 'content': gpt_output} | |
return response | |
def health_check(name): | |
response = {"role": "assistant", "content": "Hello " + name + "! The site is up"} | |
return response | |
# @app.route('/load_game', methods=['GET']) | |
# def load_game(): | |
# upload_game_docs() | |
# response = {'message': 'Game loaded'} | |
# return jsonify(response) | |
health_check_gr = gradio.Interface( | |
fn=health_check, | |
inputs="text", | |
outputs="text", | |
title="Health Check for Genesis APIs", | |
description="An API to check if the API is working" | |
) | |
initialize_game_gr = gradio.Interface( | |
fn=initialize_game, | |
inputs=["text","text"], | |
outputs="text", | |
title="Initialize Game", | |
description="An API to initialize the game. This is executed ONLY when a user starts a game" | |
) | |
play_game_gr = gradio.Interface( | |
fn=play_game, | |
inputs=["text","text", "text"], | |
outputs="text", | |
title="Play Game", | |
description="An API for the user to interact with the LLM" | |
) | |
genesis_app = gradio.TabbedInterface([health_check_gr, initialize_game_gr, play_game_gr], ["Health Check", "Initialize game", "Play Game"]) | |
genesis_app.launch() |