- Add agent-run module to handle AI interactions with tools and messages. - Create routes for proxying requests to OpenAI and Anthropic APIs. - Implement flowme-life chat route for user queries and task management. - Add services for retrieving and updating life records in the database. - Implement logic for fetching today's tasks and marking tasks as done with next execution time calculation. - Introduce tests for flowme-life functionalities.
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
import { App } from '@kevisual/router';
|
|
import * as redisLib from './modules/redis.ts';
|
|
import { useContextKey } from '@kevisual/context';
|
|
import { SimpleRouter } from '@kevisual/router/simple';
|
|
import { s3Client, oss as s3Oss } from './modules/s3.ts';
|
|
import { BailianProvider } from '@kevisual/ai';
|
|
import * as schema from './db/schema.ts';
|
|
import { config } from './modules/config.ts'
|
|
import { db } from './modules/db.ts'
|
|
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
|
|
|
|
|
|
export const router = useContextKey('router', () => new SimpleRouter());
|
|
export const runtime = useContextKey('runtime', () => {
|
|
return {
|
|
env: config.NODE_ENV || 'development',
|
|
type: 'server',
|
|
};
|
|
});
|
|
export const oss = useContextKey(
|
|
'oss',
|
|
() => s3Oss,
|
|
);
|
|
export { s3Client }
|
|
export const redis = useContextKey('redis', () => redisLib.redis);
|
|
export const subscriber = useContextKey('subscriber', () => redisLib.subscriber);
|
|
export { db };
|
|
const init = () => {
|
|
return new App({
|
|
serverOptions: {
|
|
cors: {
|
|
origin: '*',
|
|
},
|
|
io: true,
|
|
}
|
|
});
|
|
};
|
|
export const app = useContextKey('app', init);
|
|
|
|
export const ai = useContextKey('ai', () => {
|
|
return new BailianProvider({
|
|
apiKey: config.BAILIAN_API_KEY || '',
|
|
model: 'qwen-plus',
|
|
});
|
|
});
|
|
|
|
export { schema };
|
|
|
|
export const bailian = createOpenAICompatible({
|
|
baseURL: 'https://coding.dashscope.aliyuncs.com/v1',
|
|
name: 'custom-bailian',
|
|
apiKey: process.env.BAILIAN_CODE_API_KEY!,
|
|
});
|
|
|
|
export const cnb = createOpenAICompatible({
|
|
baseURL: 'https://api.cnb.cool/kevisual/kevisual/-/ai/',
|
|
name: 'custom-cnb',
|
|
apiKey: process.env.CNB_API_KEY!,
|
|
});
|
|
|
|
export const models = {
|
|
'doubao-ark-code-latest': 'doubao-ark-code-latest',
|
|
'GLM-4.7': 'GLM-4.7',
|
|
'MiniMax-M2.1': 'MiniMax-M2.1',
|
|
'qwen3-coder-plus': 'qwen3-coder-plus',
|
|
'hunyuan-a13b': 'hunyuan-a13b',
|
|
'qwen-plus': 'qwen-plus',
|
|
'auto': 'auto',
|
|
} |