oas2mcp.agent.base¶
Thin LangChain v1 agent factory helpers for oas2mcp.
- Purpose:
Provide shared helpers for constructing LangChain v1 agents and the default OpenAI-backed chat model used by
oas2mcpworkflows.- Design:
Keep the wrapper intentionally thin.
Centralize common defaults such as runtime context schema and state schema.
Centralize default model construction, reasoning configuration, and environment loading.
Leave workflow-specific prompts, middleware, and structured outputs to submodules like
summarizerandenhancer.
Examples
model = build_default_chat_model()
agent = build_base_agent(
model=model,
response_format=MyOutputModel,
)
Attributes¶
Functions¶
|
Build a stateful LangChain v1 agent for |
|
Build the default OpenAI chat model. |
|
Load likely project-local environment files. |
|
Return the OpenAI API key from the environment. |
Module Contents¶
- oas2mcp.agent.base.build_base_agent(*, response_format: Any, tools: list[Any] | None = None, middleware: list[Any] | None = None, system_prompt: str | None = None, model: Any | None = None, model_name: str = DEFAULT_MODEL_NAME, reasoning_effort: str = DEFAULT_REASONING_EFFORT, model_kwargs: dict[str, Any] | None = None)[source][source]¶
Build a stateful LangChain v1 agent for
oas2mcp.- Parameters:
response_format – Structured output schema or strategy.
tools – Optional tools.
middleware – Optional middleware stack.
system_prompt – Optional base system prompt.
model – Optional model instance or model identifier.
model_name – Default model name when
modelis omitted.reasoning_effort – Default reasoning effort when
modelis omitted.model_kwargs – Extra kwargs used only when building the default model.
- Returns:
The constructed LangChain agent runnable.
- Raises:
RuntimeError – If the default model is used and no API key is available.
- oas2mcp.agent.base.build_default_chat_model(*, model_name: str = DEFAULT_MODEL_NAME, reasoning_effort: str = DEFAULT_REASONING_EFFORT, api_key: str | None = None, **kwargs: Any) langchain_openai.ChatOpenAI[source][source]¶
Build the default OpenAI chat model.
- Parameters:
model_name – The OpenAI model name.
reasoning_effort – The reasoning effort to request.
api_key – Optional OpenAI API key.
**kwargs – Extra keyword arguments forwarded to
ChatOpenAI.
- Returns:
Configured chat model.
- Return type:
ChatOpenAI
- Raises:
RuntimeError – If no API key is available.
- oas2mcp.agent.base.load_project_env() None[source][source]¶
Load likely project-local environment files.
- Parameters:
None.
- Returns:
None.
- Raises:
None. –