Skip to content

Commit

Permalink
Make tool use optional, defaulting to true; introduce raw_html_to_image
Browse files Browse the repository at this point in the history
  • Loading branch information
Elehiggle committed May 26, 2024
1 parent 5302627 commit 34bfb4c
Show file tree
Hide file tree
Showing 4 changed files with 305 additions and 153 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ FROM python:3.12.3-slim

WORKDIR /app

# Install Chromium
RUN apt-get update && \
apt-get install -y chromium --no-install-recommends && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* && \
mkdir -p /etc/chromium.d/ && \
echo -e 'export GOOGLE_API_KEY="AIzaSyCkfPOPZXDKNn8hhgu3JrA62wIgC93d44k"\nexport GOOGLE_DEFAULT_CLIENT_ID="811574891467.apps.googleusercontent.com"\nexport GOOGLE_DEFAULT_CLIENT_SECRET="kdloedMFGdGla2P1zacGjAQh"' > /etc/chromium.d/googleapikeys

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ This project is a chatbot for Mattermost that integrates with the OpenAI API to
- Supports the **Vision API** for describing images. Images from PDFs will also be sent here.
- **Gets transcripts of YouTube videos** for easy tl;dw summarizations. Title, description and uploader are also
provided
- Accesses additional live information via function calling. Currently supported: **stock data** (via Yahoo Finance, eg.
ask about AAPL), **cryptocurrency data**
(
- Accesses additional live information via function calling (requires TOOL_USE_ENABLED="TRUE"). Currently supported: *
*stock data** (via Yahoo Finance, eg. ask about AAPL), **cryptocurrency data** (
via [Coingecko](https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=500&page=1&sparkline=false&price_change_percentage=24h%2C7d)),
**fiat currency exchange rates** (via [ECB](https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml))
**fiat currency exchange rates** (via [ECB](https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml)). It can
also take screenshots of rendered raw HTML code or from URLs.
- Maintains context of the conversation within a thread
- Sends typing indicators to show that the chatbot is processing the message
- Utilizes a thread pool to handle multiple requests concurrently (due to `mattermostdriver-asyncio` being outdated)
Expand Down Expand Up @@ -75,6 +75,7 @@ This project is a chatbot for Mattermost that integrates with the OpenAI API to
| `MATTERMOST_USERNAME` | Required if not using token. The username of the dedicated Mattermost user account for the chatbot (if using username/password login) |
| `MATTERMOST_PASSWORD` | Required if not using token. The password of the dedicated Mattermost user account for the chatbot (if using username/password login) |
| `MATTERMOST_MFA_TOKEN` | The MFA token of the dedicated Mattermost user account for the chatbot (if using MFA) |
| `TOOL_USE_ENABLED` | Allows tool function calling for live data. Slightly increased cost because input is filled with function definitions. Default: "TRUE" |
### Extended optional configuration variables
Expand All @@ -89,6 +90,7 @@ This project is a chatbot for Mattermost that integrates with the OpenAI API to
| `IMAGE_STYLE` | The image style for image generation. Default: "vivid" (also: "natural") |
| `MAX_RESPONSE_SIZE_MB` | The maximum size of the website or file content to extract (in megabytes, per URL/file). Default: "100" |
| `FLARESOLVERR_ENDPOINT` | Endpoint URL to your [FlareSolverr](https://github.com/FlareSolverr/FlareSolverr) instance (eg. "<http://192.168.1.55:8191/v1>"). If you use this, MAX_RESPONSE_SIZE_MB won't be honored since it can't stream content. For most effectiveness, use a residential IP endpoint |
| `BROWSER_EXECUTABLE_PATH` | Path to a chromium binary which is used for the raw_html_to_image function call capability. Not necessary. Chromium is auto installed on the docker image. Default: "/usr/bin/chromium" |
| `KEEP_ALL_URL_CONTENT` | Whether to feed the AI all URL content from the whole conversation thread. The website result is cached in memory. If you only want it to know about the current message's URL content (due to context size or cost), set to "FALSE". Default: "TRUE" |
| `MATTERMOST_IGNORE_SENDER_ID` | The user ID of a user to ignore (optional, useful if you have multiple chatbots that are not real bot accounts to prevent endless loops). Supports multiple, separated by comma |
| `MATTERMOST_PORT` | The port of your Mattermost server. Default: "443" |
Expand All @@ -104,7 +106,7 @@ This project is a chatbot for Mattermost that integrates with the OpenAI API to
Run the script:

```bash
python3.12 chatbot.py
python3 chatbot.py
```

The chatbot will connect to the Mattermost server and start listening for messages.
Expand Down
Loading

0 comments on commit 34bfb4c

Please sign in to comment.