feat: update openai
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "@kevisual/ai",
 | 
					  "name": "@kevisual/ai",
 | 
				
			||||||
  "version": "0.0.10",
 | 
					  "version": "0.0.11",
 | 
				
			||||||
  "description": "AI Center Services",
 | 
					  "description": "AI Center Services",
 | 
				
			||||||
  "main": "index.js",
 | 
					  "main": "index.js",
 | 
				
			||||||
  "basename": "/root/ai-center-services",
 | 
					  "basename": "/root/ai-center-services",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
import { SiliconFlowKnowledge } from './knowledge-adapter/siliconflow.ts';
 | 
					import { SiliconFlowKnowledge } from './knowledge-adapter/siliconflow.ts';
 | 
				
			||||||
import { KnowledgeBase, KnowledgeOptions } from './knowledge-adapter/knowledge-base.ts';
 | 
					import { KnowledgeBase, } from './knowledge-adapter/knowledge-base.ts';
 | 
				
			||||||
import { RerankOptions } from './knowledge-adapter/siliconflow.ts';
 | 
					export type { KnowledgeOptions } from './knowledge-adapter/knowledge-base.ts';
 | 
				
			||||||
export { KnowledgeBase, KnowledgeOptions, RerankOptions };
 | 
					export type { RerankOptions } from './knowledge-adapter/siliconflow.ts';
 | 
				
			||||||
 | 
					export { KnowledgeBase, };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export { SiliconFlowKnowledge };
 | 
					export { SiliconFlowKnowledge };
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										26
									
								
								src/test/aliyun/test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/test/aliyun/test.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
				
			|||||||
 | 
					import { BailianProvider } from '../../provider/index.ts'
 | 
				
			||||||
 | 
					import dotenv from 'dotenv';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					dotenv.config();
 | 
				
			||||||
 | 
					import { App } from '@kevisual/router'
 | 
				
			||||||
 | 
					import util from 'node:util';
 | 
				
			||||||
 | 
					const ai = new BailianProvider({
 | 
				
			||||||
 | 
					  apiKey: process.env.BAILIAN_API_KEY || '',
 | 
				
			||||||
 | 
					  model: 'qwen-turbo-latest',
 | 
				
			||||||
 | 
					  baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1'
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const res = await ai.chat([
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    role: 'user',
 | 
				
			||||||
 | 
					    content: `1+1等于多少?`
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					console.log('AI Response:', res);
 | 
				
			||||||
 | 
					const content = res.choices[0].message?.content || ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					console.log(util.inspect(res, { depth: null }))
 | 
				
			||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
import { SiliconFlow } from '../..//provider/chat-adapter/siliconflow.ts';
 | 
					import { SiliconFlow } from '../../provider/chat-adapter/siliconflow.ts';
 | 
				
			||||||
import { Ollama } from '../..//provider/chat-adapter/ollama.ts';
 | 
					import { Ollama } from '../../provider/chat-adapter/ollama.ts';
 | 
				
			||||||
import dotenv from 'dotenv';
 | 
					import dotenv from 'dotenv';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dotenv.config();
 | 
					dotenv.config();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
import { ModelScope } from '../..//provider/chat-adapter/model-scope.ts';
 | 
					import { ModelScope } from '../../provider/chat-adapter/model-scope.ts';
 | 
				
			||||||
import { log } from '../..//logger/index.ts';
 | 
					import { logger } from '../../modules/logger.ts';
 | 
				
			||||||
import util from 'util';
 | 
					import util from 'util';
 | 
				
			||||||
import { config } from 'dotenv';
 | 
					import { config } from 'dotenv';
 | 
				
			||||||
config();
 | 
					config();
 | 
				
			||||||
@@ -14,13 +14,13 @@ const chatMessage = [{ role: 'user', content: 'Hello, world! 1 + 1 equals ?' }];
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const main = async () => {
 | 
					const main = async () => {
 | 
				
			||||||
  const res = await chat.test();
 | 
					  const res = await chat.test();
 | 
				
			||||||
  log.info('test', res);
 | 
					  logger.info('test', res);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
main();
 | 
					main();
 | 
				
			||||||
const mainChat = async () => {
 | 
					const mainChat = async () => {
 | 
				
			||||||
  const res = await chat.chat(chatMessage as any);
 | 
					  const res = await chat.chat(chatMessage as any);
 | 
				
			||||||
  log.info('chat', res);
 | 
					  logger.info('chat', res);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// mainChat();
 | 
					// mainChat();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user