Spaces:
Sleeping
Sleeping
| from flask import Flask, jsonify, request | |
| from gameload import upload_game_docs | |
| import chat | |
| import os | |
| import dotenv | |
| import os | |
| app = Flask(__name__) | |
| dotenv.load_dotenv('.env') | |
| host = os.getenv('HOST') | |
| port = os.getenv('PORT') | |
| def initialize_game(): | |
| 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 jsonify(response) | |
| def start_game(): | |
| 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 jsonify(response) | |
| def health_check(): | |
| response = {'message': 'Site is healthy'} | |
| return jsonify(response) | |
| def load_game(): | |
| upload_game_docs() | |
| response = {'message': 'Game loaded'} | |
| return jsonify(response) | |
| if __name__ == '__main__': | |
| host = '0.0.0.0' # Replace with your desired host IP | |
| port = 8080 # Replace with your desired port number | |
| app.run(host=host, port=port) | |