GPTStonks Chat Community Edition official API
1.6K
Welcome to the GPTStonks Chatbot API documentation! This API allows you to interact with a powerful financial chatbot built on top of the openbb framework. Whether you're a developer looking to integrate financial chat capabilities into your application or a trader seeking automated financial insights, this API is designed to provide you with a seamless and customizable experience.
GPTStonks is a financial chatbot powered by LLMs and enhanced with the openbb framework. It provides natural language conversation capabilities for financial topics, making it an ideal choice for a wide range of financial applications, including:
This API allows you to integrate the GPTStonks financial chatbot into your projects, enabling real-time financial chat interactions with users.
instruct versions are supported, such as gpt-3.5-turbo-instruct. Chat versions will be added soon.Before you begin, make sure you have Dockerโ installed on your system.
git clone https://github.com/gptstonks/api.git
Check the .env.template file for the required environment variables. Modify the values as desired and save the file.
Run the docker-compose file:
docker-compose up
If you didn't change any port configuration, navigate to http://localhost:3000 to access the frontend.
(optional) If you want to use your OpenBB PAT to access resources, you can set it from the API Keys section (sidebar) in the frontend.
Set up environment variables by creating a .env file in the project directory with the contents specified in .env.template.
[Highly Recommended] Option 1: use the latest Docker image in ghcr.ioโ .
docker run -it -p 8000:8000 --env-file .env ghcr.io/gptstonks/api:main
Option 2: build from source.
Install PDMโ for a faster install.
Clone this repository to your local machine:
git clone https://github.com/GPTStonks/api.git
cd gptstonks_api
pdm install --no-editable --no-self
openssl.cnf to allow legacy TLS renegotiation, needed for OECD data in OpenBB.echo 'openssl_conf = openssl_init\n\
\n\
[openssl_init]\n\
ssl_conf = ssl_sect\n\
\n\
[ssl_sect]\n\
system_default = system_default_sect\n\
\n\
[system_default_sect]\n\
Options = UnsafeLegacyRenegotiation'\
> openssl.cnf
uvicorn gptstonks_api.main:app --host 0.0.0.0 --port 8000
Now your GPTStonks Financial Chatbot API is up and running!
For production environments, additional steps are necessary to ensure security and stability:
Ensure that uvicorn is configured with SSL certificates for secure HTTPS communication.
Build the Docker image from source:
docker build -t gptstonks-api:v0.1_pro -f Dockerfile.pro .
Now you can run the Docker image with the following command:
docker run -it -p 443:8000 \
-v /etc/letsencrypt/live/api.gptstonks.net/fullchain.pem:/api/cert.pem \
-v /etc/letsencrypt/live/api.gptstonks.net/privkey.pem:/api/key.pem \
--env-file .env gptstonks-api:v0.1_pro
To use the GPTStonks Financial Chatbot API, send HTTP requests to the provided endpoints. You can interact with the chatbot by sending messages and receiving responses in real-time.
Check http://localhost:8000/docs once the API is started to access the endpoints' documentation.
| Env variable | Required | Default | Description |
|---|---|---|---|
| MONGO_URI | Yes | - | MongoDB's URI to connect. |
| MONGO_DBNAME | Yes | - | MongoDB's database to use. |
| AUTOLLAMAINDEX_VSI_GDRIVE_URI | No | None (Not downloaded) | Google Drive's URL to download Vector Store Index (VSI). |
| AUTOLLAMAINDEX_EMBEDDING_MODEL_ID | No | "local:BAAI/bge-large-en-v1.5" | Embedding model ID to use with AutoLlamaIndex (must match with VSI). |
| AUTOLLAMAINDEX_SIMILARITY_POSTPROCESSOR_CUTOFF | No | 0.5 | Minimum similarity required when retrieving similar documents. |
| AUTOLLAMAINDEX_REMOVE_METADATA_POSTPROCESSOR | No | None (Postprocessor used) | Whether or not to use a metadata postprocessor. |
| AUTOLLAMAINDEX_VSI_PATH | Yes | - | Path to the downloaded VSI. If AUTOLLAMAINDEX_VSI_GDRIVE_URI is given, they will match automatically. |
| AUTOLLAMAINDEX_LLM_CONTEXT_WINDOW | No | 4096 | Context window to use when a Hugging Face model is loaded in AutoLlamaIndex. |
| AUTOLLAMAINDEX_QA_TEMPLATE | No | None (LlamaIndex's Default QA Template) | Template to use with LlamaIndex question answering step. |
| AUTOLLAMAINDEX_REFINE_TEMPLATE | No | None (LlamaIndex's Default Refine Template) | Template to use with AutoLlamaIndex refine step. |
| AUTOLLAMAINDEX_VIR_SIMILARITY_TOP_K | No | 3 | K most similar elements are retrieved with vector search. |
| AUTOLLAMAINDEX_NOT_USE_HYBRID_RETRIEVER | No | None (Hybrid retrieved used) | Whether or not to use BM25 with vector search (hybrid) or only vector search. |
| AGENT_REQUEST_TIMEOUT | No | 20 | No. seconds to wait before timeout when an API LLM is used (e.g., OpenAI). |
| AGENT_EARLY_STOPPING_METHOD | No | "generate" | How the model should return its final output when early stopping is applied. |
| LLM_TEMPERATURE | No | 0.1 | Temperature to use when sampling. |
| LLM_MAX_TOKENS | No | 256 | No. max. tokens to sample. |
| LLM_TOP_P | No | 1.0 | Top-p parameter to apply when sampling. |
| LLM_MODEL_ID | Yes | - | ID of the model to use. See tutorials in GPTStonks' blog for more details. |
| LLM_CHAT_MODEL_SYSTEM_MESSAGE | No | "You write concise and complete answers." | System message when using chat models (e.g., GPT-4). |
| LLM_VERTEXAI_CLOUD_LOCATION | No | None | Google Cloud location to use with VertexAI. |
| LLM_LLAMACPP_CONTEXT_WINDOW | No | 4000 | Context window to apply when a model is loaded with Llama.cpp. |
| LLM_HF_DEVICE | No | -1 | Device to use with Hugging Face's models. |
| LLM_HF_DISABLE_SAMPLING | No | False | Whether or not to disable sampling when generating with Hugging Face's models. |
| LLM_HF_DEVICE_MAP | No | None (HuggingFacePipeline default) | Device map to use with Hugging Face's models. |
| LLM_HF_BITS | No | 4 | No. bits of quantized Hugging Face's model. |
| LLM_HF_DISABLE_EXLLAMA | No | False | Whether or not to disable ExLlama with Hugging Face's models. |
| LLM_HF_TRUST_REMOTE_CODE | No | False | Whether or not to trust remote code with Hugging Face's models. |
| OPENBBCHAT_TOOL_DESCRIPTION | Yes | - | OpenBB Platform's tool description for the LLM agent. |
| SEARCH_TOOL_DESCRIPTION | No | None (Default DDG Search description) | DDG's search tool description for the LLM agent. |
| CUSTOM_GPTSTONKS_PREFIX | No | None (Default LangChain agent prefix) | Prefix to use with LLM agent. |
| CUSTOM_GPTSTONKS_SUFFIX | No | None (Default LangChain agent suffix) | Suffix to use with LLm agent. |
| CUSTOM_GPTSTONKS_QA (DEPRECATED) | No | None (LlamaIndex's Default QA Template) | QA template to use with LLM agent QA tools. |
We welcome contributions from the community! If you have any suggestions, bug reports, or want to contribute to the project, feel free to open issues or propose changes.
This project is licensed under the MIT License.
Content type
Image
Digest
sha256:71e81e55cโฆ
Size
3.3 GB
Last updated
over 2 years ago
docker pull gptstonks/api