Skip to content

Commit

Permalink
feat(ollama): Switch Ollama default withStructuredOutput method to js…
Browse files Browse the repository at this point in the history
…onSchema (#7681)
  • Loading branch information
jacoblee93 authored Feb 10, 2025
1 parent 193d1e9 commit 850819a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions libs/langchain-ollama/src/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,7 @@ export class ChatOllama
parsed: RunOutput;
}
> {
// TODO: Make this method the default in a minor bump
if (config?.method === "jsonSchema") {
if (config?.method === undefined || config?.method === "jsonSchema") {
const outputSchemaIsZod = isZodSchema(outputSchema);
const jsonSchema = outputSchemaIsZod
? zodToJsonSchema(outputSchema)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ test("Ollama can call withStructuredOutput includeRaw JSON Schema", async () =>
}).withStructuredOutput(weatherTool.schema, {
name: weatherTool.name,
includeRaw: true,
method: "jsonSchema",
});

const result = await model.invoke(messageHistory);
Expand All @@ -113,6 +112,7 @@ test("Ollama can call withStructuredOutput includeRaw with tool calling", async
}).withStructuredOutput(weatherTool.schema, {
name: weatherTool.name,
includeRaw: true,
method: "functionCalling",
});

const result = await model.invoke(messageHistory);
Expand Down

0 comments on commit 850819a

Please sign in to comment.