Shrikrishna commited on
Commit
d2f12bd
1 Parent(s): 0b80076

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +76 -4
app.py CHANGED
@@ -1,4 +1,76 @@
1
- user_query = """
2
- which stock in the market has the highest price movement today?
3
- Summarise the latest news to analyse the potential cause and add it to my airtable data.
4
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #user_query = """
2
+ #which stock in the market has the highest price movement today?
3
+ #Summarise the latest news to analyse the potential cause and add it to my airtable data.
4
+ #"""
5
+
6
+ import openai
7
+ import os
8
+ import json
9
+ from dotenv import load_dotenv
10
+ from pyairtable import Table
11
+ import requests
12
+
13
+ load_dotenv()
14
+ openai.api_key = os.getenv("OPENAI_API_KEY")
15
+ #rapid_api_key = os.getenv("X-RapidAPI-Key")
16
+ #airtable_api_key = os.getenv("AIRTABLE_API_KEY")
17
+ #table = Table(airtable_api_key, "appHojHIE4y8gVBgc", "tbldUUKZFngr78ogg")
18
+
19
+ function_descriptions = [
20
+ {
21
+ "name": "get_stock_movers",
22
+ "description": "Get the stocks that has biggest price/volume moves, e.g. actives, gainers, losers, etc.",
23
+ "parameters": {
24
+ "type": "object",
25
+ "properties": {
26
+ },
27
+ }
28
+ },
29
+ {
30
+ "name": "get_stock_news",
31
+ "description": "Get the latest news for a stock",
32
+ "parameters": {
33
+ "type": "object",
34
+ "properties": {
35
+ "performanceId": {
36
+ "type": "string",
37
+ "description": "id of the stock, which is referred as performanceID in the API"
38
+ },
39
+ },
40
+ "required": ["performanceId"]
41
+ }
42
+ },
43
+ {
44
+ "name": "add_stock_news_airtable",
45
+ "description": "Add the stock, news summary & price move to Airtable",
46
+ "parameters": {
47
+ "type": "object",
48
+ "properties": {
49
+ "stock": {
50
+ "type": "string",
51
+ "description": "stock ticker"
52
+ },
53
+ "move": {
54
+ "type": "string",
55
+ "description": "price move in %"
56
+ },
57
+ "news_summary": {
58
+ "type": "string",
59
+ "description": "news summary of the stock"
60
+ },
61
+ }
62
+ }
63
+ },
64
+ ]
65
+
66
+ query = "Give me a summary of what happend to the tesla stock today?"
67
+ messages = [{"role":"user", "content":query}]
68
+
69
+ response = openai.ChatCompletion.create(
70
+ model="gpt-3.5-turbo",
71
+ messages=messages,
72
+ functions = function_descriptions,
73
+ function_call="auto"
74
+ )
75
+
76
+ print(response)