diff --git a/packages/neuri/src/openai-xsai/messages.ts b/packages/neuri/src/openai-xsai/messages.ts index 788e1e6..cdb2671 100644 --- a/packages/neuri/src/openai-xsai/messages.ts +++ b/packages/neuri/src/openai-xsai/messages.ts @@ -21,34 +21,10 @@ export function imagePart(imageUrl: string): ImagePart { return { type: 'image_url', image_url: { url: imageUrl } } } -// TODO: AssistantMessage -// interface ToolCallMessage { -// function: { -// arguments: string -// name: string -// } -// id: string -// type: 'function' -// } -// export function assistant(toolCall: ToolCallMessage | undefined): { role: 'assistant', tool_calls: ToolCallMessage[], name?: string } -// export function assistant(message: string): { role: 'assistant', content: string, name?: string } -// export function assistant(body: string | ToolCallMessage | undefined): AssistantMessage { -// if (body == null) -// return { role: 'assistant', content: '' } -// if (typeof body === 'string') -// return { role: 'assistant', content: body } - -// return { role: 'assistant', tool_calls: [body] } -// } - -// export function tool
(message: string, toolCall: ResolvedToolCall
): OpenAI.ChatCompletionToolMessageParam { -// return { -// role: 'tool', -// content: message, -// tool_call_id: toolCall.toolCall.id, -// } -// } - export function messages(...messages: Message[]): Message[] { return messages } + +export function assistant(message: string): AssistantMessage { + return { role: 'assistant', content: message } +} diff --git a/packages/neuri/src/openai-xsai/stream.test.ts b/packages/neuri/src/openai-xsai/stream.test.ts index b92f7ba..5d21543 100644 --- a/packages/neuri/src/openai-xsai/stream.test.ts +++ b/packages/neuri/src/openai-xsai/stream.test.ts @@ -1,5 +1,4 @@ import { env } from 'node:process' -import { createOpenAI } from '@xsai/providers' import { describe, expect, it } from 'vitest' import { messages, system, user } from './messages' import { createOpenAIProvider } from './provider' @@ -40,16 +39,11 @@ describe('stream', () => { // TODO: auto tee? it('should stream chunkStream', async () => { const apiKey = env.OPENAI_API_KEY || env.VITE_OPENAI_API_KEY - let baseURL = env.OPENAI_API_BASEURL || env.VITE_OPENAI_API_BASEURL + const baseURL = env.OPENAI_API_BASEURL || env.VITE_OPENAI_API_BASEURL expect(apiKey).toBeDefined() expect(baseURL).toBeDefined() - if (!baseURL?.endsWith('/')) { - baseURL += '/' - } - - // TODO: fix baseURL - const openAI = createOpenAI({ + const openAI = createOpenAIProvider({ apiKey: apiKey!, baseURL: baseURL!, })