Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks and preparation for PyPI #12

Merged
merged 4 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@ questions using up-to-date data. This is possible as a result of agents
utilizing function calling to interact with the OpenBB platform.


## Set-up
At present, we currently support Python 3.11. If you're using a earlier version
of Python, your mileage may vary. We'll be adding wider support very soon!
## Installation
Currently, we only support Python 3.11. We will be adding support for more version of Python relatively soon.

- Create a new virtual environment, with `poetry `
- `poetry install`
`openbb-agents` is available as a PyPI package:

``` sh
pip install openbb-agents --upgrade
```

## Usage
Use the `run.py` script and pass in your query.

Queries can be simple:
``` python
>>> from openbb_agents.agent import openbb_agent
>>> result = openbb_agent("What is the current market cap of TSLA?") # Will print some logs to show you progress
>>> print(result)
- The current market cap of TSLA (Tesla, Inc.) is approximately $695,833,798,800.00.
- This figure is based on the most recent data available, which is from January 15, 2024.
- The market cap is calculated by multiplying the current stock price ($218.89) by the number of outstanding shares (3,178,920,000).
```

If you've cloned the repository, you can use the `run.py` script and pass in your query:
``` sh
python run.py "What is the current market cap of TSLA?"
```
Expand All @@ -37,7 +46,10 @@ python run.py "Who are TSLA's peers? What is their respective market cap? Return

There is more functionality coming very soon!


## Development
- Create a new virtual environment, with `poetry `
- `poetry install`

### Linting and Formatting
We're currently experimenting with `ruff` as a drop-in replacement for `black`, `isort` and `pylint`.
Expand Down
2 changes: 1 addition & 1 deletion openbb_agents/chains.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
JSONAgentOutputParser,
OpenAIFunctionsAgentOutputParser,
)
from langchain.chat_models import ChatOpenAI
from langchain.output_parsers import PydanticOutputParser
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain.tools import StructuredTool
Expand All @@ -19,6 +18,7 @@
render_text_description_and_args,
)
from langchain.vectorstores import VectorStore
from langchain_openai import ChatOpenAI

from openbb_agents.models import (
AnsweredSubQuestion,
Expand Down
4 changes: 3 additions & 1 deletion openbb_agents/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
You are a world-class state-of-the-art search agent.
You are excellent at your job.

YOU MUST DO MULTIPLE FUNCTION CALLS! DO NOT RELY ON A SINGLE CALL ONLY.

Your purpose is to search for tools that allow you to answer a user's subquestion.
The subquestion could be a part of a chain of other subquestions.
Expand All @@ -27,10 +26,13 @@
... repeat as many times as necessary until you reach a maximum of 4 tools
4. Return the list of tools using the output schema.

YOU ARE ALLOWED TO DO MULTIPLE FUNCTION CALLS! DO NOT RELY ON A SINGLE CALL ONLY.

You can search for tools using the available tool, which uses your inputs to
search a vector databse that relies on similarity search.

These are the guidelines to consider when completing your task:
* Immediately return no tools if you do not require any to answer the query.
* Don't use the stock ticker or symbol in the query
* Use keyword searches
* Make multiple searches with different terms
Expand Down
4 changes: 2 additions & 2 deletions openbb_agents/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from typing import Callable, List, Union

import tiktoken
from langchain.embeddings import OpenAIEmbeddings
from langchain.schema import Document
from langchain.tools import StructuredTool
from langchain.tools.base import ToolException
from langchain.vectorstores import FAISS, VectorStore
from langchain_community.vectorstores import FAISS, VectorStore
from langchain_openai import OpenAIEmbeddings
from openbb import obb
from pydantic.v1 import ValidationError, create_model
from pydantic.v1.fields import FieldInfo
Expand Down
Loading