fix: update reasoning_content type and remove empty bind options
This commit is contained in:
parent
7180ea8146
commit
b3307dd3bd
@ -8,11 +8,14 @@ import {
|
|||||||
FunctionMessageChunk,
|
FunctionMessageChunk,
|
||||||
HumanMessageChunk,
|
HumanMessageChunk,
|
||||||
SystemMessageChunk,
|
SystemMessageChunk,
|
||||||
ToolMessageChunk,
|
ToolMessageChunk
|
||||||
} from "@langchain/core/messages"
|
} from "@langchain/core/messages"
|
||||||
import { ChatGenerationChunk, ChatResult } from "@langchain/core/outputs"
|
import { ChatGenerationChunk, ChatResult } from "@langchain/core/outputs"
|
||||||
import { getEnvironmentVariable } from "@langchain/core/utils/env"
|
import { getEnvironmentVariable } from "@langchain/core/utils/env"
|
||||||
import { BaseChatModel, BaseChatModelParams } from "@langchain/core/language_models/chat_models"
|
import {
|
||||||
|
BaseChatModel,
|
||||||
|
BaseChatModelParams
|
||||||
|
} from "@langchain/core/language_models/chat_models"
|
||||||
import { convertToOpenAITool } from "@langchain/core/utils/function_calling"
|
import { convertToOpenAITool } from "@langchain/core/utils/function_calling"
|
||||||
import {
|
import {
|
||||||
RunnablePassthrough,
|
RunnablePassthrough,
|
||||||
@ -92,7 +95,8 @@ function _convertDeltaToMessageChunk(
|
|||||||
) {
|
) {
|
||||||
const role = delta.role ?? defaultRole
|
const role = delta.role ?? defaultRole
|
||||||
const content = delta.content ?? ""
|
const content = delta.content ?? ""
|
||||||
const reasoning_content: string | null = delta.reasoning_content ?? null
|
const reasoning_content: string | undefined | null =
|
||||||
|
delta?.reasoning_content ?? undefined
|
||||||
let additional_kwargs
|
let additional_kwargs
|
||||||
if (delta.function_call) {
|
if (delta.function_call) {
|
||||||
additional_kwargs = {
|
additional_kwargs = {
|
||||||
@ -246,7 +250,7 @@ export class CustomChatOpenAI<
|
|||||||
constructor(
|
constructor(
|
||||||
fields?: Partial<OpenAIChatInput> &
|
fields?: Partial<OpenAIChatInput> &
|
||||||
BaseChatModelParams & {
|
BaseChatModelParams & {
|
||||||
configuration?: ClientOptions & LegacyOpenAIInput;
|
configuration?: ClientOptions & LegacyOpenAIInput
|
||||||
},
|
},
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
configuration?: ClientOptions & LegacyOpenAIInput
|
configuration?: ClientOptions & LegacyOpenAIInput
|
||||||
@ -840,8 +844,7 @@ export class CustomChatOpenAI<
|
|||||||
let llm
|
let llm
|
||||||
let outputParser
|
let outputParser
|
||||||
if (method === "jsonMode") {
|
if (method === "jsonMode") {
|
||||||
llm = this.bind({
|
llm = this.bind({})
|
||||||
})
|
|
||||||
if (isZodSchema(schema)) {
|
if (isZodSchema(schema)) {
|
||||||
outputParser = StructuredOutputParser.fromZodSchema(schema)
|
outputParser = StructuredOutputParser.fromZodSchema(schema)
|
||||||
} else {
|
} else {
|
||||||
@ -866,9 +869,7 @@ export class CustomChatOpenAI<
|
|||||||
parameters: schema
|
parameters: schema
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
llm = this.bind({
|
llm = this.bind({})
|
||||||
|
|
||||||
})
|
|
||||||
outputParser = new JsonOutputKeyToolsParser({
|
outputParser = new JsonOutputKeyToolsParser({
|
||||||
returnSingle: true,
|
returnSingle: true,
|
||||||
keyName: functionName
|
keyName: functionName
|
||||||
|
Loading…
x
Reference in New Issue
Block a user