Skip to content

Commit

Permalink
🎨 chore: handle payload support options (lobehub#3331)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx authored Jul 26, 2024
1 parent 9b4c39c commit afce281
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ interface OpenAICompatibleFactoryOptions<T extends Record<string, any> = any> {
error: any,
options: ConstructorOptions<T>,
) => Omit<ChatCompletionErrorPayload, 'provider'> | undefined;
handlePayload?: (payload: ChatStreamPayload) => OpenAI.ChatCompletionCreateParamsStreaming;
handlePayload?: (
payload: ChatStreamPayload,
options: ConstructorOptions<T>,
) => OpenAI.ChatCompletionCreateParamsStreaming;
};
constructorOptions?: ConstructorOptions<T>;
debug?: {
Expand Down Expand Up @@ -141,7 +144,7 @@ export const LobeOpenAICompatibleFactory = <T extends Record<string, any> = any>
async chat(payload: ChatStreamPayload, options?: ChatCompetitionOptions) {
try {
const postPayload = chatCompletion?.handlePayload
? chatCompletion.handlePayload(payload)
? chatCompletion.handlePayload(payload, this._options)
: ({
...payload,
stream: payload.stream ?? true,
Expand Down

0 comments on commit afce281

Please sign in to comment.