guidance_import_errorTier 1 · 70% confidence

ai-agents-guidance-import-erro-importerror-when-using-guidance-pydantic-program-d-a97760d1

agent: ai_agents

When does this happen?

IF ImportError when using guidance pydantic program due to outdated documentation suggesting incorrect import path for OpenAIChat.

How others solved it

THEN Replace `from guidance.models import OpenAIChat` with `from guidance.models import OpenAI` and ensure all required imports from `llama_index.program.guidance.utils` and `guidance` (assistant, gen, user) are included. Also verify compatible versions of llama-index and llama-index-program-guidance.

from llama_index.core.bridge.pydantic import BaseModel
from llama_index.core.program.llm_prompt_program import BaseLLMFunctionProgram
from llama_index.core.prompts.base import PromptTemplate
from llama_index.program.guidance.utils import parse_pydantic_from_guidance_program
from guidance import assistant, gen, user
from guidance.models import Model as GuidanceLLM
from guidance.models import OpenAI

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics