-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
129 lines (106 loc) · 4.14 KB
/
app.py
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
from flask import Flask, request, jsonify
from gpt import chat_gpt_request
from emotion_detect import *
app = Flask(__name__)
@app.route('/process_input', methods=['POST'])
def process_input():
data = request.get_json()
image_url = data.get('image_url')
user_text = data.get('user_text')
face_api_key = "your-face-api-key"
face_api_endpoint = "your-face-api-endpoint"
emotion = detect_emotion(image_url, face_api_key, face_api_endpoint)
chatgpt_response = chat_gpt_request(emotion, user_text)
return jsonify({"response": chatgpt_response})
# from flask import Flask, jsonify, request, Response
# from flask_cors import CORS
# import requests
# ai_plugin_data = {
# "schema_version": "v1",
# "name_for_human": "BART Real-Time Plugin",
# "name_for_model": "bart_realtime",
# "description_for_human": "Plugin for getting real-time BART information for a specified origination station and direction.",
# "description_for_model": "Plugin for getting real-time BART information for a specified origination station and direction.",
# "auth": {
# "type": "none"
# },
# "api": {
# "type": "openapi",
# "url": "http://localhost:4444/openapi.yaml",
# "is_user_authenticated": False
# },
# "logo_url": "https://d1yjjnpx0p53s8.cloudfront.net/styles/logo-original-577x577/s3/0016/4231/brand.gif?itok=cOeuUIp-",
# "contact_email": "[email protected]",
# "legal_info_url": "http://www.example.com/legal"
# }
# openapi_yaml_content = """
# openapi: 3.0.1
# info:
# title: BART Real-Time Plugin
# description: A plugin that allows the user to get real-time BART information for a specified origination station and direction using ChatGPT.
# version: 'v1'
# servers:
# - url: http://localhost:4444
# paths:
# /bart/realtime:
# get:
# operationId: getBartRealTime
# summary: Get real-time BART information
# parameters:
# - name: origination_station
# in: query
# description: The abbreviation for the origination station (e.g., '12th' for 12th Street Station).
# required: true
# schema:
# type: string
# - name: direction
# in: query
# description: The direction of travel ('n' for northbound, 's' for southbound).
# required: true
# schema:
# type: string
# responses:
# "200":
# description: OK
# content:
# application/json:
# schema:
# type: object
# properties:
# data:
# type: object
# description: The JSON response from the BART real-time API containing real-time BART information.
# """
# app = Flask(__name__)
# CORS(app, origins=["http://127.0.0.1:4444", "https://chat.openai.com"])
# @app.route('/bart/realtime')
# def bart_realtime():
# # Get the origination_station and direction parameters from the request
# origination_station = request.args.get('origination_station')
# direction = request.args.get('direction')
# bart_api_params = {
# 'cmd': 'etd',
# 'orig': origination_station,
# 'key': 'MW9S-E7SL-26DU-VV8V',
# 'dir': direction,
# 'json': 'y'
# }
# try:
# # Make a request to the BART API
# response = requests.get('https://api.bart.gov/api/etd.aspx', params=bart_api_params)
# response.raise_for_status() # Raise an exception if the response contains an HTTP error status code
# # Parse the JSON response
# data = response.json()
# # Return the JSON response to the client
# return jsonify(data)
# except requests.exceptions.RequestException as e:
# # Handle any errors that occurred during the request
# return jsonify({'error': str(e)}), 500
# @app.route('/.well-known/ai-plugin.json')
# def ai_plugin_json():
# return jsonify(ai_plugin_data)
# @app.route('/openapi.yaml')
# def openapi_yaml():
# return Response(openapi_yaml_content, mimetype='application/x-yaml')
# if __name__ == '__main__':
# app.run(port=4444)