File size: 1,786 Bytes
6ffbca0
b91e12a
24a12b5
b91e12a
 
 
790d42f
b91e12a
8504cf9
b91e12a
 
 
 
8504cf9
b91e12a
f84784f
 
 
 
 
 
 
7d9d14f
b91e12a
790d42f
 
 
 
 
 
 
 
7d9d14f
b91e12a
 
790d42f
9604998
790d42f
b91e12a
 
 
 
 
7d9d14f
790d42f
b91e12a
6ffbca0
f84784f
 
 
 
 
 
6ee45eb
b91e12a
790d42f
 
 
6ffbca0
790d42f
 
7d9d14f
24a12b5
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#from flask import jsonify
# from gameload import upload_game_docs
import chat
# import os
# import dotenv
# import os
from chat import start_game
import gradio

# app = Flask(__name__)
# dotenv.load_dotenv('.env')
# host = os.getenv('HOST')
# port = os.getenv('PORT')

# @app.route('/initialize_game', methods=['GET'])
def initialize_game(game_id, user_id):
    # inputs = request.args.to_dict()
    # user_id = inputs['user_id']
    # game_id = inputs['game_id']  
    result = chat.initialize_game(user_id, game_id)
    response = {'role': 'assistant', 'content': result}
    return response

# @app.route('/start_game', methods=['GET'])
def play_game(game_id, user_id, user_input):
    # inputs = request.args.to_dict()
    # user_id = inputs['user_id']
    # game_id = inputs['game_id']  
    # user_input = inputs['user_input']
    gpt_output = chat.start_game(game_id, user_id, user_input)
    response = {'role': 'assistant', 'content': gpt_output}
    return response

# @app.route('/health_check', methods=['GET'])
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"
)

initialize_game_gr = gradio.Interface(
  fn=initialize_game,
  inputs=["text","text"],
  outputs="text"
)

play_game_gr = gradio.Interface(
  fn=play_game,
  inputs=["text","text", "text"],
  outputs="text"
)

genesis_app = gradio.TabbedInterface([health_check_gr, play_game_gr, initialize_game_gr], ["Health Check", "Play Game", "Initialize game"])
genesis_app.launch()