-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ollama + streamText + tool issue #4700
Comments
With [email protected] and @ai-sdk/[email protected] I have reworked the resubmit mechanism. Please check if those new versions work for you (and also consider using message parts). Details can be found here: #4670 |
When you use |
Still the same @lgrammel I used newly added consumeStream() feature. No tool call is being made and response is empty text ![]() |
Can you check for errors? https://sdk.vercel.ai/docs/ai-sdk-core/generating-text#onerror-callback If that does not resolve it. pls file with the ollama provider https://github.com/sgomez/ollama-ai-provider |
Do you get anything when you log in |
Description
Hi, I've been going through seemingly a strange issue
When I try to call a tool using generateText it is working fine but same code with streamText fails to generate same response.
I tried adding onFinishStep, forced by providing system text as well.
Code example
import { streamText, tool } from "ai";
import { createOllama } from "ollama-ai-provider";
import { z } from "zod";
import { MODELS } from "./constant.js";
const ollama = createOllama();
const getWeatherTool = tool({
description: "Get the current weather in the specified city",
parameters: z.object({
city: z.string().describe("The city to get the weather for"),
}),
execute: async ({ city }) => {
return
The weather in ${city} is 25°C and sunny.
;},
});
const askAQuestion = async (prompt: string) => {
const { textStream, text, steps } = await streamText({
model: ollama(MODELS.GRANITE_3_1_DENSE),
prompt,
tools: {
getWeather: getWeatherTool,
},
maxSteps: 2,
});
// for await (const text of textStream) {
// process.stdout.write(text);
// }
console.dir(await steps, { depth: null });
};
askAQuestion(
What's the weather in London?
).catch(console.error);AI provider
ollama-ai-provider v1.2.0
Additional context
Package.json
"devDependencies": {
"tsx": "^4.19.2",
"typescript": "^5.7.3"
},
"dependencies": {
"@types/node": "^22.13.1",
"ai": "^4.1.17",
"dotenv": "^16.4.7",
"ollama": "^0.5.12",
"ollama-ai-provider": "^1.2.0",
"zod": "^3.24.1"
}
The text was updated successfully, but these errors were encountered: