This is a stock expert agent that can help you to make decisions on stock trading. It has abilities to access the stock data, analyze the stock data, news, and provide recommendation. It is built on OpenAI Assistant API.
Function calling allow user to use natural language to call task/function correctly. It also allows user to pass parameters to the function.
OpenAI Assistant API is a powerful tool that can help you to build a conversational AI. Source: OPENAI - How Assistants work
OBJECT | WHAT IT REPRESENTS |
---|---|
Assistant | Purpose-built AI that uses OpenAI’s models and calls tools |
Thread | A conversation session between an Assistant and a user. Threads store Messages and automatically handle truncation to fit content into a model’s context. |
Message | A message created by an Assistant or a user. Messages can include text, images, and other files. Messages stored as a list on the Thread. |
Run | An invocation of an Assistant on a Thread. The Assistant uses its configuration and the Thread’s Messages to perform tasks by calling models and tools. As part of a Run, the Assistant appends Messages to the Thread. |
Run Step | A detailed list of steps the Assistant took as part of a Run. An Assistant can call tools or create Messages during its run. Examining Run Steps allows you to introspect how the Assistant is getting to its final results. |
Run is asynchrounous. So we need to wait for the run to complete before we can get the result. We can get the result when status is completed
.
- Go to OpenAI. Login or create an account.
- Navigate to the
Assistants
tab. - Click on
+ Create
to start creating a new assistant. - Fill in the details for the assistant. Name, prompt, function, code interpreter, and files.
4.1 for Function calling, we need to specify schema. e.g.
{ "name": "get_news", "description": "Get latest news on specified stock name or symbol. Return headline and links.", "parameters": { "type": "object", "properties": { "ticker": { "type": "string", "description": "Symbol of stock or company name. Used as a query for stock data API calling" } }, "required": ["ticker"] } }
- to use the assistant, grab assistant id from the settings.
FMP API provides the stock data and news. Docs
gnews API provides the news data. Docs
- create repository on github with requirements.txt
- go to https://www.streamlit.io/
- login and create New App
- connect to github
- select the repository
- make sure you specify the right file to run the app e.g.
app.py
- deploy the app
Appendix: