Skip to content

Commit

Permalink
chore: lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Jun 28, 2024
1 parent 0a60008 commit 85184a6
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions libs/langchain-anthropic/src/tests/chat_models-tools.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,19 +364,25 @@ test("bindTools accepts openai formatted tool", async () => {
});

test("withStructuredOutput will always force tool usage", async () => {
const weatherTool = z.object({
location: z.string().describe("The name of city to get the weather for."),
}).describe("Get the weather of a specific location and return the temperature in Celsius.")
const weatherTool = z
.object({
location: z.string().describe("The name of city to get the weather for."),
})
.describe(
"Get the weather of a specific location and return the temperature in Celsius."
);
const modelWithTools = model.withStructuredOutput(weatherTool, {
name: "get_weather",
includeRaw: true
includeRaw: true,
});
const response = await modelWithTools.invoke("What is the sum of 271623 and 281623? It is VERY important you use a calculator tool to give me the answer.");
const response = await modelWithTools.invoke(
"What is the sum of 271623 and 281623? It is VERY important you use a calculator tool to give me the answer."
);

if (!("tool_calls" in response.raw)) {
throw new Error("Tool call not found in response")
throw new Error("Tool call not found in response");
}
const castMessage = response.raw as AIMessage;
expect(castMessage.tool_calls).toHaveLength(1);
expect(castMessage.tool_calls?.[0].name).toBe("get_weather");
})
});

0 comments on commit 85184a6

Please sign in to comment.