Skip to content

Commit

Permalink
feat: 添加MarkdownV2版本支持
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Jan 16, 2025
1 parent f9144b4 commit 97141b6
Show file tree
Hide file tree
Showing 8 changed files with 766 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"build:dist": "pnpm run version && pnpm run build:workers && cp -r packages/apps/workers/dist/index.js dist/",
"deploy:dist": "pnpm run build:dist && wrangler deploy",
"deploy:workers": "pnpm run build:workers && TOML_PATH=$INIT_CWD/wrangler.toml pnpm run --filter @chatgpt-telegram-workers/workers deploy",
"deploy:workersmk2": "pnpm run build:workers && TOML_PATH=$INIT_CWD/wrangler.toml pnpm run --filter @chatgpt-telegram-workers/workers-mk2 deploy",
"deploy:workersnext": "pnpm run build:workersnext && TOML_PATH=$INIT_CWD/wrangler.toml pnpm run --filter @chatgpt-telegram-workers/workers-next deploy",
"deploy:vercel": "pnpm run build:vercel && vercel --prod",
"start:local": "pnpm run build:local && CONFIG_PATH=$INIT_CWD/config.json TOML_PATH=$INIT_CWD/wrangler.toml pnpm run --filter @chatgpt-telegram-workers/local start",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/local/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from 'node:fs';
import * as process from "node:process";
import * as process from 'node:process';
import { CHAT_AGENTS, createRouter, ENV, handleUpdate } from '@chatgpt-telegram-workers/core';
import { injectNextChatAgent } from '@chatgpt-telegram-workers/next';
import { createCache, defaultRequestBuilder, initEnv, installFetchProxy, startServerV2 } from 'cloudflare-worker-adapter';
Expand Down
16 changes: 16 additions & 0 deletions packages/apps/workers-mk2/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@chatgpt-telegram-workers/workers-mk2",
"type": "module",
"version": "1.10.3",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "pnpm vite build",
"clean": "rm -rf dist && rm -rf node_modules",
"deploy": "wrangler deploy --config ${TOML_PATH}"
},
"dependencies": {
"@chatgpt-telegram-workers/core": "workspace:*",
"telegramify-markdown": "^1.2.2"
}
}
10 changes: 10 additions & 0 deletions packages/apps/workers-mk2/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ENV, Workers } from '@chatgpt-telegram-workers/core';
import convert from 'telegramify-markdown';

ENV.CUSTOM_MESSAGE_RENDER = (parse_mode, message) => {
if (parse_mode === 'MarkdownV2') {
return convert(message, 'remove');
}
return message;
};
export default Workers;
11 changes: 11 additions & 0 deletions packages/apps/workers-mk2/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
},
"references": [
{ "path": "../../lib/core" }
],
"include": ["src/**/*"]
}
7 changes: 7 additions & 0 deletions packages/apps/workers-mk2/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createShareConfig } from '../../../vite.config.shared';

export default createShareConfig({
root: __dirname,
nodeExternals: true,
excludeMonoRepoPackages: true,
});
2 changes: 1 addition & 1 deletion packages/lib/core/src/agent/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
} from './types';
import { ImageSupportFormat, loadOpenAIModelList, renderOpenAIMessages } from '#/agent/openai_compatibility';
import { requestChatCompletions } from './request';
import {bearerHeader, convertStringToResponseMessages, getAgentUserConfigFieldName, loadModelsList} from './utils';
import { bearerHeader, convertStringToResponseMessages, getAgentUserConfigFieldName, loadModelsList } from './utils';

function openAIApiKey(context: AgentUserConfig): string {
const length = context.OPENAI_API_KEY.length;
Expand Down
719 changes: 719 additions & 0 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

0 comments on commit 97141b6

Please sign in to comment.