Spaces:
Runtime error
Runtime error
Commit ·
b0da33a
1
Parent(s): 8438112
Create app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172import openaiimport jsonimport osfrom dotenv import load_dotenv#from pyairtable import Tableimport requestsimport streamlit as st
load_dotenv()openai.api_key = os.getenv("OPENAI_API_KEY")rapid_api_key = os.getenv("X-RapidAPI-Key")#airtable_api_key = os.getenv("AIRTABLE_API_KEY")#table = Table(airtable_api_key, "appHojHIE4y8gVBgc", "tbldUUKZFngr78ogg")
function_descriptions = [ { "name": "get_stock_movers", "description": "Get the stocks that has biggest price/volume moves, e.g. actives, gainers, losers, etc.", "parameters": { "type": "object", "properties": { }, } }, { "name": "get_stock_news", "description": "Get the latest news for a stock", "parameters": { "type": "object", "properties": { "performanceId": { "type": "string", "description": "id of the stock, which is referred as performanceID in the API" }, }, "required": ["performanceId"] } }, { "name": "add_stock_news_airtable", "description": "Add the stock, news summary & price move to Airtable", "parameters": { "type": "object", "properties": { "stock": { "type": "string", "description": "stock ticker" }, "move": { "type": "string", "description": "price move in %" }, "news_summary": { "type": "string", "description": "news summary of the stock" }, } } },]
query = "Give me a summary of what happend to the tesla stocks today?"messages = [{"role":"user","content":query}]
response = openai.ChatCompletion.create( model="gpt-3.5-turbo-0613", messages=messages, functions = function_descriptions, function_call="auto" )
st.subheader(response)app.pyAdded+72