Update all examples to use the new Pydantic integration #162

Closed
opened 2026-02-15 16:28:23 -05:00 by yindo · 6 comments
Owner

Originally created by @ParthSareen on GitHub (Nov 6, 2024).

Originally assigned to: @ParthSareen on GitHub.

With the introduction of https://github.com/ollama/ollama-python/pull/276, examples must be updated.

Add appropriate readme updates and create best practices through examples.

Originally created by @ParthSareen on GitHub (Nov 6, 2024). Originally assigned to: @ParthSareen on GitHub. With the introduction of https://github.com/ollama/ollama-python/pull/276, examples must be updated. Add appropriate readme updates and create best practices through examples.
yindo closed this issue 2026-02-15 16:28:23 -05:00
Author
Owner

@sprior commented on GitHub (Nov 22, 2024):

Is this why I'm getting "Object of type function is not JSON serializable" on the call to chat() in the tools.py example?

@sprior commented on GitHub (Nov 22, 2024): Is this why I'm getting "Object of type function is not JSON serializable" on the call to chat() in the tools.py example?
Author
Owner

@ParthSareen commented on GitHub (Nov 22, 2024):

Hey! Could you drop what version of ollama-python you're on? pip show ollama @sprior

@ParthSareen commented on GitHub (Nov 22, 2024): Hey! Could you drop what version of ollama-python you're on? `pip show ollama` @sprior
Author
Owner

@sprior commented on GitHub (Nov 22, 2024):

Name: ollama
Version: 0.3.3
Summary: The official Python client for Ollama.
Home-page: https://ollama.ai
Author: Ollama
Author-email: hello@ollama.com
License: MIT
Location: c:\Users\sprio\Documents\Python\ollama-client.venv\Lib\site-packages
Requires: httpx
Required-by:

@sprior commented on GitHub (Nov 22, 2024): Name: ollama Version: 0.3.3 Summary: The official Python client for Ollama. Home-page: https://ollama.ai Author: Ollama Author-email: hello@ollama.com License: MIT Location: c:\Users\sprio\Documents\Python\ollama-client\.venv\Lib\site-packages Requires: httpx Required-by:
Author
Owner

@ParthSareen commented on GitHub (Nov 22, 2024):

Got it. @sprior Could you upgrade to the newest version of the sdk? It's 0.4.0.

@ParthSareen commented on GitHub (Nov 22, 2024): Got it. @sprior Could you upgrade to the newest version of the sdk? It's 0.4.0.
Author
Owner

@sprior commented on GitHub (Nov 22, 2024):

@ParthSareen ok thanks, working now. Just FYI when I run your examples I seem to have to add client=Client(host='') or else it can't connect, I'm running Windows Ollama and the Python example in VSCode. I'm guessing somehow there the default localhost isn't working. I don't know how common this issue is but maybe make the examples a bit more universal.

@sprior commented on GitHub (Nov 22, 2024): @ParthSareen ok thanks, working now. Just FYI when I run your examples I seem to have to add client=Client(host='<my host>') or else it can't connect, I'm running Windows Ollama and the Python example in VSCode. I'm guessing somehow there the default localhost isn't working. I don't know how common this issue is but maybe make the examples a bit more universal.
Author
Owner

@ParthSareen commented on GitHub (Nov 22, 2024):

Thanks for letting me know! Will try to repro :) @sprior

@ParthSareen commented on GitHub (Nov 22, 2024): Thanks for letting me know! Will try to repro :) @sprior
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#162