apisforgenesis / app.py
laxsvips's picture
Update app.py
5b8333f
raw
history blame
2.17 kB
import chat
import gradio
import audio
def initialize_game(game_id, user_id, user_input):
result = chat.initialize_game(game_id, user_id, user_input)
return result
def play_game(game_id, user_id, user_input):
result = chat.start_game(game_id, user_id, user_input)
return result
def health_check(name):
result = {"role": "assistant", "content": "Hello " + name + "! The site is up"}
return result
def generate_image_prompt(game_id, user_id, user_input):
result = chat.generate_image_prompt(game_id, user_id, user_input)
return result
def generate_audio(input_text):
result = audio.generate_audio(input_text)
return result
# @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="DEVELOPERS ONLY - 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", "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"
)
generate_image_prompt_gr = gradio.Interface(
fn=generate_image_prompt,
inputs=["text","text", "text"],
outputs="text",
title="Generate prompt for image",
description="An API for the user to generate a prompt to input to Leo"
)
generate_audio_gr = gradio.Interface(
fn=generate_audio,
inputs=["text"],
outputs="audio",
title="Convert text to audio",
description="An API for the user to convert text to audio"
)
genesis_app = gradio.TabbedInterface([health_check_gr, initialize_game_gr, play_game_gr, generate_image_prompt_gr, generate_audio_gr], ["Developers - Health Check", "Initialize game", "Play Game", "Generate Prompt for Leo", "Convert text to audio"])
genesis_app.launch()