SavirD commited on
Commit
2d0f413
·
verified ·
1 Parent(s): ac8e2e4

Upload 3 files

Browse files
Files changed (3) hide show
  1. ai-plugin.json +17 -0
  2. main.py +39 -0
  3. openapi.yaml +21 -0
ai-plugin.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": "v1",
3
+ "name_for_human": "Stock Quote",
4
+ "name_for_model": "StockQuote",
5
+ "description_for_human": "Get price and volume information for a given stock.",
6
+ "description_for_model": "Get price and volume information for a given stock. Always display results using markdown tables.",
7
+ "auth": {
8
+ "type": "none"
9
+ },
10
+ "api": {
11
+ "type": "openapi",
12
+ "url": "[YOUR_DOMAIN, must be HTTPS]/openapi.yaml"
13
+ },
14
+ "logo_url": "[YOUR_DOMAIN, must be HTTPS]/logo.png",
15
+ "contact_email": "support@example.com",
16
+ "legal_info_url": "https://example.com/legal"
17
+ }
main.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ from flask import Flask, request, send_from_directory
3
+
4
+ # Replace "YOUR_API_KEY_HERE" with your actual API key.
5
+ API_KEY = "IA1B54WDCZD5GQJU"
6
+ BASE_URL = "https://www.alphavantage.co/query"
7
+
8
+ app = Flask(__name__)
9
+
10
+
11
+ @app.route("/")
12
+ def index():
13
+ return "Hello world! Your web application is working!"
14
+
15
+
16
+ @app.route('/stock', methods=['GET'])
17
+ def get_stock_data():
18
+ symbol = request.args.get('symbol')
19
+
20
+ params = {"function": "GLOBAL_QUOTE", "symbol": symbol, "apikey": API_KEY}
21
+
22
+ response = requests.get(BASE_URL, params=params)
23
+ return response.json()
24
+
25
+
26
+ @app.route('/.well-known/ai-plugin.json')
27
+ def serve_ai_plugin():
28
+ return send_from_directory('.',
29
+ 'ai-plugin.json',
30
+ mimetype='application/json')
31
+
32
+
33
+ @app.route('/openapi.yaml')
34
+ def serve_openapi_yaml():
35
+ return send_from_directory('.', 'openapi.yaml', mimetype='text/yaml')
36
+
37
+
38
+ if __name__ == "__main__":
39
+ app.run(host='0.0.0.0', port=81)
openapi.yaml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ openapi: 3.0.1
2
+ info:
3
+ title: Stock Quote
4
+ description: Get price and volume information for a given stock.
5
+ version: "v1"
6
+ servers:
7
+ - url: [YOUR_DOMAIN, must be HTTPS]
8
+ paths:
9
+ /stock:
10
+ get:
11
+ operationId: getStockData
12
+ summary: Retrieves the price and volume information for a given stock symbol.
13
+ parameters:
14
+ - in: query
15
+ name: symbol
16
+ schema:
17
+ type: string
18
+ description: The symbol of the stock to get a quote for. For example, the stock symbol MSFT represents the company Microsoft.
19
+ responses:
20
+ "200":
21
+ description: OK