Skip to content

Instantly share code, notes, and snippets.

View Andrey862's full-sized avatar
🗿

Andrey Feigelman Andrey862

🗿
View GitHub Profile
@Andrey862
Andrey862 / reasoning_with_structured_output_langchain.py
Last active September 26, 2025 14:47
Example of using reasoning model with structured output with langchain
# ollama library version here: https://gist.github.com/Andrey862/94c5760d79fe3674f4294a26bab5fdfb
from typing import cast
from langchain_core.messages.ai import AIMessage
from langchain_core.messages.base import BaseMessage
from langchain_core.messages.system import SystemMessage
from langchain_ollama.chat_models import ChatOllama
from pydantic import BaseModel
model = ChatOllama(model="qwen3:8b", temperature=0.1, top_k=2)
@Andrey862
Andrey862 / reasoning_with_structured_output_ollama.py
Last active September 26, 2025 14:47
Example of using reasoning model with structured output with ollama library
# langchain version here https://gist.github.com/Andrey862/4bb795b3301572f979baa04edff44fa6
from typing import Any, Literal, Mapping, Sequence
from ollama import chat
from pydantic import BaseModel
model = "qwen3:8b"
options = {"temperature": 0.1, "top_k": 2}