CodeWiki
CodeWiki copied to clipboard
ImportError: cannot import name 'OpenAIModel' from pydantic_ai.models.openai (broken by pydantic-ai 2.0.0)
Summary
codewiki generate crashes on import with a fresh install, because pydantic-ai 2.0.0 (released 2026-06-23) removed the deprecated OpenAIModel name in favor of OpenAIChatModel, and codewiki/src/be/llm_services.py still imports the old name. pyproject.toml pins pydantic-ai>=1.0.6 with no upper bound, so any fresh install now resolves pydantic-ai 2.x and breaks.
Traceback
Traceback (most recent call last):
File ".../bin/codewiki", line 3, in <module>
from codewiki.cli.main import cli
File ".../codewiki/cli/main.py", line 35, in <module>
from codewiki.cli.commands.generate import generate_command
File ".../codewiki/cli/commands/generate.py", line 30, in <module>
from codewiki.cli.adapters.doc_generator import CLIDocumentationGenerator
File ".../codewiki/cli/adapters/doc_generator.py", line 22, in <module>
from codewiki.src.be.documentation_generator import DocumentationGenerator
File ".../codewiki/src/be/documentation_generator.py", line 18, in <module>
from codewiki.src.be.cluster_modules import (
File ".../codewiki/src/be/cluster_modules.py", line 8, in <module>
from codewiki.src.be.llm_services import call_llm
File ".../codewiki/src/be/llm_services.py", line 12, in <module>
from pydantic_ai.models.openai import OpenAIModel
ImportError: cannot import name 'OpenAIModel' from 'pydantic_ai.models.openai' (.../site-packages/pydantic_ai/models/openai.py). Did you mean: 'OpenAIChatModel'?
Reproduction
pip install git+https://github.com/FSoft-AI4Code/CodeWiki.git
codewiki generate --main-model claude-haiku-4-5-20251001 --update --verbose
Any fresh install pulls in pydantic-ai 2.x since the dependency spec has no upper bound.
Root cause
pyproject.tomlline 46:pydantic-ai>=1.0.6(no upper bound)codewiki/src/be/llm_services.pyline 12:from pydantic_ai.models.openai import OpenAIModelOpenAIModelwas deprecated inpydantic-aiin favor ofOpenAIChatModelaround Aug 2025, and appears to have been removed entirely inpydantic-ai2.0.0 (2026-06-23).
Suggested fix
Either:
- Update
llm_services.py(and any other usages) to importOpenAIChatModelinstead ofOpenAIModel, or - Cap the dependency, e.g.
pydantic-ai>=1.0.6,<2.0.0, until the migration to the new name is done.
Happy to open a PR for option 1 if useful — flagging first since it's a hard crash on every fresh install right now.
Thanks for the report. Confirmed and fixed at 311f017