Skip to content

Commit

Permalink
refactor(chat): move chat options
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa committed Feb 26, 2025
1 parent 7aaa22b commit 4cd7ecd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
10 changes: 0 additions & 10 deletions packages/shared-chat/src/types/chat-options.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/shared-chat/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export type * from './chat-options'
export type * from './finish-reason'
export type * from './message'
export type * from './message-part'
Expand Down
10 changes: 9 additions & 1 deletion packages/shared-chat/src/utils/chat.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import type { CommonRequestOptions } from '@xsai/shared'

import { requestBody, requestHeaders, requestURL, responseCatch } from '@xsai/shared'

import type { ChatOptions, Tool } from '../types'
import type { Message, Tool, ToolChoice } from '../types'

export interface ChatOptions extends CommonRequestOptions {
[key: string]: unknown
messages: Message[]
toolChoice?: ToolChoice
}

export const chat = async <T extends ChatOptions>(options: T) =>
(options.fetch ?? globalThis.fetch)(requestURL('chat/completions', options.baseURL), {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared-chat/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { chat } from './chat'
export { chat, type ChatOptions } from './chat'

0 comments on commit 4cd7ecd

Please sign in to comment.