Skip to content
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
31 changes: 16 additions & 15 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ jobs:
packages: write

environment:
name: ghcr
url: https://github.com/cssnr/chat-server/pkgs/container/chat-server
name: docker
url: https://hub.docker.com/r/cssnr/chat-server

steps:
- name: "Checkout"
uses: actions/checkout@v6

- name: "Debug event.json"
continue-on-error: true
run: cat "${GITHUB_EVENT_PATH}"
- name: "Debug CTX github"
if: ${{ !github.event.act }}
continue-on-error: true
env:
GITHUB_CTX: ${{ toJSON(github) }}
Expand All @@ -46,9 +51,6 @@ jobs:
echo "inputs.dev: ${{ inputs.dev }}"
echo "env.dev: ${{ env.dev }}"

- name: "Checkout"
uses: actions/checkout@v6

- name: "Update Package Version"
uses: cssnr/update-json-value-action@v2
with:
Expand All @@ -65,11 +67,11 @@ jobs:
username: ${{ vars.GHCR_USER }}
password: ${{ secrets.GHCR_PASS }}

#- name: "Docker Login - Hub"
# uses: docker/login-action@v4
# with:
# username: ${{ vars.DOCKER_HUB_USER }}
# password: ${{ secrets.DOCKER_HUB_PASS }}
- name: "Docker Login - Hub"
uses: docker/login-action@v4
with:
username: ${{ vars.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASS }}

- name: "Setup QEMU"
uses: docker/setup-qemu-action@v4
Expand Down Expand Up @@ -100,10 +102,9 @@ jobs:
id: tags
uses: cssnr/docker-tags-action@v2
with:
images: "ghcr.io/${{ github.repository }}"
#images: |
# ${{ github.repository }}
# ghcr.io/${{ github.repository }}
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
tags: |
${{ env.dev }}
${{ steps.version.outputs.tags }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ env:
traefik-host: ${{ secrets.TRAEFIK_HOST }}
stack-name: ${{ github.repository_owner }}-${{ github.event.repository.name }}
version: ${{ inputs.version || github.event.workflow_run.head_branch || github.ref_name }}
tokens: "2048"
origins: "*.cssnr.com,cssnr.github.io,smashedr.github.io,django-files.github.io"
options: '{"openai":{"serviceTier":"flex","reasoningEffort":"low"}}'
tokens: "2048"

jobs:
deploy:
Expand Down Expand Up @@ -77,9 +77,9 @@ jobs:
GOOGLE_GENERATIVE_AI_API_KEY: "${{ secrets.GOOGLE_GENERATIVE_AI_API_KEY }}"
OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}"
MODEL: "${{ secrets.MODEL }}"
MAX_TOKENS: "${{ env.tokens }}"
CORS_ORIGINS: "${{ env.origins }}"
PROVIDER_OPTIONS: '${{ env.options }}'
MAX_TOKENS: "${{ env.tokens }}"

## https://render.com/docs/deploy-hooks#deploying-from-an-image-registry
#- name: "Deploy Image"
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@ jobs:
- name: "Checkout"
uses: actions/checkout@v6

- name: "Debug event.json"
continue-on-error: true
run: cat "${GITHUB_EVENT_PATH}"
- name: "Debug CTX github"
continue-on-error: true
env:
GITHUB_CTX: ${{ toJSON(github) }}
run: echo "$GITHUB_CTX"

- name: "Setup Node"
uses: actions/setup-node@v6
with:
node-version: 24

- name: "install"
id: install
- name: "Install"
run: npm ci

- name: "Debug"
Expand All @@ -36,8 +44,7 @@ jobs:

- name: "eslint"
if: ${{ !cancelled() }}
run: |
npm run lint
run: npm run lint

- name: "prettier"
if: ${{ !cancelled() }}
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/render.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,13 @@ jobs:

steps:
- name: "Debug event.json"
if: ${{ !github.event.act }}
continue-on-error: true
run: cat "${GITHUB_EVENT_PATH}"
- name: "Debug CTX github"
if: ${{ !github.event.act }}
continue-on-error: true
env:
GITHUB_CTX: ${{ toJSON(github) }}
run: echo "$GITHUB_CTX"
- name: "Debug Environment"
if: ${{ !github.event.act }}
continue-on-error: true
run: env

- name: "Debug ref"
continue-on-error: true
Expand Down
33 changes: 25 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![GitHub Release Version](https://img.shields.io/github/v/release/cssnr/chat-server?logo=github)](https://github.com/cssnr/chat-server/releases/latest)
[![Image Latest](https://badges.cssnr.com/ghcr/tags/cssnr/chat-server/latest)](https://github.com/cssnr/chat-server/pkgs/container/chat-server)
[![Image Size](https://badges.cssnr.com/ghcr/size/cssnr/chat-server)](https://github.com/cssnr/chat-server/pkgs/container/chat-server)
[![Deployment GHCR](https://img.shields.io/github/deployments/cssnr/chat-server/ghcr?logo=docker&logoColor=white&label=ghcr)](https://github.com/cssnr/chat-server/deployments/ghcr)
[![Deployment Docker](https://img.shields.io/github/deployments/cssnr/chat-server/docker?logo=docker&logoColor=white&label=docker)](https://github.com/cssnr/chat-server/deployments/docker)
[![Workflow Release](https://img.shields.io/github/actions/workflow/status/cssnr/chat-server/release.yaml?logo=norton&logoColor=white&label=release)](https://github.com/cssnr/chat-server/actions/workflows/release.yaml)
[![Workflow Lint](https://img.shields.io/github/actions/workflow/status/cssnr/chat-server/lint.yaml?logo=norton&logoColor=white&label=lint)](https://github.com/cssnr/chat-server/actions/workflows/lint.yaml)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/cssnr/chat-server?logo=listenhub&label=updated)](https://github.com/cssnr/chat-server/pulse)
Expand Down Expand Up @@ -57,6 +57,8 @@ Built with the [AI SDK](https://ai-sdk.dev/).

## Setup

💡 The server works out-of-the box with NO environment variables.

[![Deploy to Render](https://img.shields.io/badge/Deploy_to_Render-4351E8?style=for-the-badge&logo=render)](https://render.com/deploy?repo=https://github.com/cssnr/chat-server)

With Docker.
Expand Down Expand Up @@ -93,19 +95,19 @@ For a Portainer Deploy workflow see the [.github/workflows/deploy.yaml](https://

### Configure

💡 The default `big-pickle` model works out-of-the box with NO API Key.
💡 All variables are optional. The default `big-pickle` model works with NO API Key.

Environment Variables.

| Variable | Default | Description |
| :------------------------------------ | :--------------------------- | :---------------------------------- |
| `MODEL` | `big-pickle` | Model to Use |
| `MAX_TOKENS` | - | Max Output Tokens |
| `BASE_URL` | `https://opencode.ai/zen/v1` | OpenAI Compatible Provider Base URL |
| [PROVIDER_OPTIONS](#PROVIDER_OPTIONS) | - | Provider Options JSON String |
| `MAX_TOKENS` | - | Max Output Tokens |
| `INSTRUCTIONS` | - | Fallback System Instructions |
| `AI_SDK_LOG_WARNINGS` | - | Disable SDK Warnings |
| `CORS_ORIGINS` | - | Allowed CORS Origins (supports \*) |
| `BASE_URL` | `https://opencode.ai/zen/v1` | OpenAI Compatible Provider Base URL |
| `PORT` | `3000` | Server Port |

You must also set the API key for the `MODEL` you select.
Expand All @@ -121,14 +123,23 @@ The `PROVIDER_API_KEY` is optional for free-tier models like `big-pickle`.

#### PROVIDER_OPTIONS

Provider Specific Options: <https://vercel.com/docs/ai-gateway/models-and-providers/provider-options>
Provider Options: <https://vercel.com/docs/ai-gateway/models-and-providers/provider-options>

For example, to disable "Reasoning" on `big-pickle` model.

```json
{ "zen": { "thinking": { "type": "disabled" } } }
```

You may need to wrap the variable in single quotes.

```text
{"openai":{"serviceTier":"flex","reasoningEffort":"low"}}
PROVIDER_OPTIONS='{"openai":{"serviceTier":"flex","reasoningEffort":"low"}}'
```

You are responsible for providing valid options for the chosen model.
It is only checked to be valid JSON at startup and will fail at runtime if invalid.
The SDK supports providing provider options for multiple provider simultaneously.
The value is only checked for valid JSON at startup and will fail at runtime if it contains invalid options.

## Client

Expand Down Expand Up @@ -156,6 +167,12 @@ The client is currently available as a VitePress Plugin.

This works with no configuration using the `big-pickle` model.
You can set your environment variables in the `settings.env` file.
If using `big-pickle` for testing it is much faster to disable reasoning.

```text
PROVIDER_OPTIONS='{"zen":{"thinking":{"type":"disabled"}}}'
```

In all cases you can set the `PORT` environment variable.

With Node run.
Expand All @@ -166,7 +183,7 @@ npm run dev

Point your client to: http://localhost:3000/

With Docker compose (you may need to `touch settings.env`).
With Docker compose _(you may need to `touch settings.env`)_.

```shell
docker compose -f docker-compose-dev.yaml up --watch --build --remove-orphans
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-swarm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ services:
STACK_NAME: ${STACK_NAME}
TRAEFIK_HOST: ${TRAEFIK_HOST}
MODEL: ${MODEL}
BASE_URL: ${BASE_URL}
PROVIDER_OPTIONS: ${PROVIDER_OPTIONS}
MAX_TOKENS: ${MAX_TOKENS}
INSTRUCTIONS: ${INSTRUCTIONS}
AI_SDK_LOG_WARNINGS: ${AI_SDK_LOG_WARNINGS}
Expand All @@ -47,8 +49,6 @@ services:
OPENAI_API_KEY: ${OPENAI_API_KEY}
GOOGLE_GENERATIVE_AI_API_KEY: ${GOOGLE_GENERATIVE_AI_API_KEY}
PROVIDER_API_KEY: ${PROVIDER_API_KEY}
BASE_URL: ${BASE_URL}
PROVIDER_OPTIONS: ${PROVIDER_OPTIONS}
deploy:
replicas: 1
resources:
Expand Down
Loading