Openbb chat qa
fix_frequent_code_errors(prev_code, openbb_pat=None) ¶
Fix common errors in the LLM-generated code.
It also adds OpenBB Personal Access Token (PAT) to authenticate the OpenBB Platform calls and use the user's data providers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prev_code | `str` | code generated by the LLM. | required |
openbb_pat | `Optional[str]` | user's OpenBB PAT. | None |
Returns:
| Type | Description |
|---|---|
str |
|
Source code in projects/gptstonks_api/gptstonks/api/utils/openbb_chat_qa.py
get_openbb_chat_output(query_str, auto_rag, node_postprocessors=None) async ¶
Get OpenBB tool output using RAG.
The output is obtained by:
- Retrieving similar nodes with hybrid search from OpenBB's documentation.
- Applying the defined postprocessors.
- Generating the response given the information in the retrieved and postprocessed nodes to the LLM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_str | `str` | input to OpenBB's tool, given by the agent's LLM. | required |
auto_rag | `AutoRag` | contains all the necessary tools to perform the RAG. | required |
node_postprocessors | `Optional[List[BaseNodePostprocessor]]` | postprocessors to apply to the retrieved nodes. | None |
Returns:
| Type | Description |
|---|---|
str |
|
Source code in projects/gptstonks_api/gptstonks/api/utils/openbb_chat_qa.py
run_repl_over_openbb(openbb_chat_output, python_repl_utility, openbb_pat=None) ¶
Run REPL over the code generated by the LLM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
openbb_chat_output | `str` | output generated by the LLM in the agent's OpenBB Tool. | required |
python_repl_utility | `PythonREPL` | REPL to run the generated code with. | required |
openbb_pat | `Optional[str]` | user's OpenBB PAT. | None |
Returns:
| Type | Description |
|---|---|
str |
|