40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { JimengService } from './services/jimeng.service.ts';
|
|
import { OSSService } from './services/oss.service.ts';
|
|
import { PBService } from './services/pb.service.ts';
|
|
import { useConfig } from '@kevisual/use-config';
|
|
|
|
import { App } from '@kevisual/router'
|
|
import { useContextKey } from '@kevisual/context';
|
|
import { getRedisConnection } from './module/redis.ts';
|
|
import { Kevisual } from '@kevisual/ai';
|
|
export const config = useConfig();
|
|
export const redis = useContextKey('redis', () => getRedisConnection());
|
|
export const jimengService = useContextKey('jimeng', new JimengService({
|
|
apiKey: config.JIMENG_API_KEY,
|
|
baseUrl: config.JIMENG_API_URL,
|
|
timeout: parseInt(config.JIMENG_TIMEOUT || '300000'),
|
|
}));
|
|
export {
|
|
getRedisConnection
|
|
}
|
|
export const ossService = useContextKey('oss', new OSSService({
|
|
accessKeyId: config.S3_ACCESS_KEY_ID,
|
|
accessKeySecret: config.S3_SECRET_ACCESS_KEY,
|
|
bucketName: config.S3_BUCKET_NAME,
|
|
region: config.S3_REGION,
|
|
endpoint: config.S3_ENDPOINT,
|
|
prefix: 'projects/horse/',
|
|
}));
|
|
export const pbService = useContextKey('pb', new PBService({
|
|
url: config.POCKETBASE_URL,
|
|
token: config.POCKETBASE_TOKEN,
|
|
}));
|
|
|
|
export const app = useContextKey('app', new App());
|
|
|
|
export const ai = useContextKey('ai', new Kevisual({
|
|
apiKey: config.KEVISUAL_NEW_API_KEY,
|
|
model: 'qwen-plus',
|
|
}));
|
|
|
|
export const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)); |