Skip to content

Commit

Permalink
Merge pull request TBXark#268 from TBXark/dev
Browse files Browse the repository at this point in the history
fix: prompt插入位置错误BUG
  • Loading branch information
TBXark authored Jul 31, 2024
2 parents 47b87b1 + 9d65a4a commit cf36483
Show file tree
Hide file tree
Showing 32 changed files with 955 additions and 661 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You can customize the system initialization information so that your debugged pe
## Features

- Serverless deployment
- Multi-platform deployment support (Cloudflare Workers, Vercel, Render[...](doc/en/DEPLOY.md))
- Multi-platform deployment support (Cloudflare Workers, Vercel, Render[...](doc/en/PLATFORM.md))
- Adaptation to multiple AI service providers (OpenAI, Azure OpenAI, Cloudflare AI, Cohere, Anthropic, Mistral...)
- Custom commands (can achieve quick switching of models, switching of robot presets)
- Support for multiple Telegram bots
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ChatGPT-Telegram-Workers
## 特性

- 无服务器部署
- 多平台部署支持(Cloudflare Workers, Vercel, Render[...](doc/cn/DEPLOY.md))
- 多平台部署支持(Cloudflare Workers, Vercel, Render[...](doc/cn/PLATFORM.md))
- 适配多种AI服务商(OpenAI, Azure OpenAI, Cloudflare AI, Cohere, Anthropic, Mistral...)
- 自定义指令(可以实现快速切换模型,切换机器人预设)
- 支持多个Telegram机器人
Expand Down
1 change: 0 additions & 1 deletion adapter/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ WORKDIR /app
COPY package*.json index.js ./
RUN npm install
RUN apt-get update && apt-get install -y sqlite3
ENV DOMAIN "http://localhost"
VOLUME /app/config
EXPOSE 8787

Expand Down
38 changes: 33 additions & 5 deletions adapter/docker/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,42 @@
import adapter from 'cloudflare-worker-adapter';
import {SqliteCache} from 'cloudflare-worker-adapter/cache/sqlite.js';
import worker from 'cloudflare-worker-adapter';
import {default as worker} from '../../main.js';
import fs from 'fs';

const cache = new SqliteCache('./config/cache.sqlite');

const config = JSON.parse(fs.readFileSync('./config/config.json', 'utf-8'));

// 配置数据库
let cache;
switch (config?.database?.type) {
case 'local':
// eslint-disable-next-line no-case-declarations
const {LocalCache} = await import('cloudflare-worker-adapter/cache/local.js');
cache = new LocalCache(config.database.uri);
break;
case 'sqlite':
// eslint-disable-next-line no-case-declarations
const {SqliteCache} = await import('cloudflare-worker-adapter/cache/sqlite.js');
cache = new SqliteCache(config.database.uri);
break;
case 'redis':
// eslint-disable-next-line no-case-declarations
const {RedisCache} = await import('cloudflare-worker-adapter/cache/redis.js');
cache = new RedisCache(config.database.uri);
break;
default:
// eslint-disable-next-line no-case-declarations
const {MemoryCache} = await import('cloudflare-worker-adapter/cache/memory.js');
cache = new MemoryCache();
break;
}

console.log(`database: ${config?.database?.type} is ready`);

adapter.startServer(
8787,
'localhost',
'127.0.0.1',
'./config/config.toml',
{DATABASE: cache},
{server: process.env.DOMAIN},
{server: config.server},
worker.fetch,
);
2 changes: 1 addition & 1 deletion dist/buildinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"sha": "8aa40ac", "timestamp": 1721280807}
{"sha": "de66f3b", "timestamp": 1722427564}
Loading

0 comments on commit cf36483

Please sign in to comment.