laxsvips commited on
Commit
790d42f
·
1 Parent(s): dbf4055

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -13
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
- # def start_game():
25
- # inputs = request.args.to_dict()
26
- # user_id = inputs['user_id']
27
- # game_id = inputs['game_id']
28
- # user_input = inputs['user_input']
29
- # gpt_output = chat.start_game(game_id, user_id, user_input)
30
- # response = {'role': 'assistant', 'content': gpt_output}
31
- # return jsonify(response)
32
 
33
  # @app.route('/health_check', methods=['GET'])
34
  def health_check(name):
35
- response = {"message": "Hello " + name + "!"}
36
- return jsonify(response)
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
- gradio_interface = gradio.Interface(
45
  fn=health_check,
46
  inputs="text",
47
  outputs="text"
48
  )
49
- gradio_interface.launch()
 
 
 
 
 
 
 
 
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