Skip to content

Commit

Permalink
UP2DATE with GPT repo: Add .pylintrc rules file; add live data by fun…
Browse files Browse the repository at this point in the history
…ction calling for ECB exchange rates, cryptocurrency data and stock data; use defusedxml, add timed lru cache; switch from local RAG helper file to pymupdf4llm pypi, work around some rare FlareSolverr issue
  • Loading branch information
Elehiggle committed May 24, 2024
1 parent 6bcec73 commit 5aa754f
Show file tree
Hide file tree
Showing 6 changed files with 350 additions and 379 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
paths-ignore:
- 'README.md'
- '**.png'
pull_request:
paths-ignore:
- 'README.md'
- '**.png'

jobs:
build-and-push:
Expand Down Expand Up @@ -52,9 +56,10 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
push: true
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
provenance: false
platforms: linux/amd64,linux/arm64
platforms: linux/amd64,linux/arm64/v8
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
Expand Down
15 changes: 15 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[MASTER]
disable=
C0114, # missing-module-docstring
C0116, # missing-function-docstring
W0703, # broad-exception-caught
W1203, # logging-fstring-interpolation
W0613, # unused-argument
W0719, # broad-exception-raised
W0603, # global-statement
C0301, # line-too-long
R0915, # too-many-statements
R0912, # too-many-branches
R0914, # too-many-locals
R1702, # too-many-nested-blocks
C0302, # too-many-lines
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ This project is a chatbot for Mattermost that integrates with the Anthropic API
- 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** (
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))
- 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 @@ -55,7 +59,7 @@ This project is a chatbot for Mattermost that integrates with the Anthropic API
```
_or alternatively:_
```bash
python3.12 -m pip install anthropic mattermostdriver certifi beautifulsoup4 pillow httpx youtube-transcript-api yt-dlp PyMuPDF
python3 -m pip install anthropic mattermostdriver certifi beautifulsoup4 pillow httpx youtube-transcript-api yt-dlp PyMuPDF defusedxml yfinance pymupdf4llm
```

4. Set the following environment variables with your own values:
Expand All @@ -74,19 +78,19 @@ This project is a chatbot for Mattermost that integrates with the Anthropic API
| Parameter | Description |
|-------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `AI_SYSTEM_PROMPT` | The system prompt/instructions. Default: [click](https://github.com/Elehiggle/Claude3MattermostChatbot/blob/f709433ac05996992a7cb13a9c4a77472161772e/chatbot.py#L64) (Subject to change. current_time and chatbot_username variables inside the prompt will be auto-formatted and substituted. |
| `AI_SYSTEM_PROMPT` | The system prompt/instructions. Default: [click](https://github.com/Elehiggle/Claude3MattermostChatbot/blob/f709433ac05996992a7cb13a9c4a77472161772e/chatbot.py#L64) (Subject to change. current_time and CHATBOT_USERNAME variables inside the prompt will be auto-formatted and substituted. |
| `AI_TIMEOUT` | The timeout for the AI API call in seconds. Default: "120" |
| `MAX_TOKENS` | The maximum number of tokens to generate in the response. Default: "4096" (max) |
| `TEMPERATURE` | The temperature value for controlling the randomness of the generated responses (0.0 = analytical, 1.0 = fully random). Default: "0.15" |
| `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 |
| `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 |
| `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" |
| `MATTERMOST_SCHEME` | The scheme of the connection. Default: "https" |
| `MATTERMOST_BASEPATH` | The basepath of your Mattermost server. Default: "/api/v4" |
| `MATTERMOST_CERT_VERIFY` | Cert verification. Default: True (also: string path to your certificate file) |
| `AI_API_BASEURL` | AI API Base URL. Default: None (which will use "https://api.anthropic.com"). Useful if you want to use a different AI with Anthropic compatible endpoint |
| `AI_API_BASEURL` | AI API Base URL. Default: None (which will use "<https://api.anthropic.com>"). Useful if you want to use a different AI with Anthropic compatible endpoint |
| `LOG_LEVEL` | The log level. Default: "INFO" |
| `LOG_LEVEL_ROOT` | The root log level (for other modules than this chatbot). Default: "INFO" |

Expand Down Expand Up @@ -138,7 +142,7 @@ Also there is:

While the official plugin certainly will improve over time, this bot here will too and there will be certain features
that will absolutely never make it into the official plugin, due to it primarily focusing on features for developers
like function calling and retrieving GitHub issues, for example.
like function calling to retrieve GitHub issues, for example.

## Known Issues

Expand Down
Loading

0 comments on commit 5aa754f

Please sign in to comment.