Skip to content

reorganize the model resolver and add openai compatible route for oth… - #143

Open
weilixu wants to merge 3 commits into
developfrom
openstudio_ai_dev
Open

reorganize the model resolver and add openai compatible route for oth…#143
weilixu wants to merge 3 commits into
developfrom
openstudio_ai_dev

Conversation

@weilixu

@weilixu weilixu commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

reorganize the model resolver and add openai compatible route for other LLM providers.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c1632a938

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

api_version: str | None = None
max_retries: int | None = None
model_kwargs: dict[str, Any] | None = None
default_headers: dict[str, str] | None = None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve Authorization placeholders in default_headers

When a YAML spec supplies an OpenAI-compatible token as default_headers.Authorization: Bearer ${PROVIDER_TOKEN}, this new field is accepted but _resolve_env_placeholders() only resolves values whose final key is secret-like, so Authorization remains literal; _extract_bearer_token() then treats ${PROVIDER_TOKEN} as a real key and the request is sent with the placeholder instead of failing fast or using the environment value. Please include Authorization/default_headers in the secret-placeholder resolution path or document that only api_key supports env placeholders.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reorganizes chat model resolution into a dedicated automa_ai.models module and adds an openai-compatible model provider option (including YAML spec + docs + tests) to support OpenAI chat-completions–compatible endpoints.

Changes:

  • Introduces automa_ai/models/chat.py and routes AgentFactory through it for chat model resolution.
  • Adds GenericLLM.OPENAI_COMPATIBLE plus YAML spec fields for model_kwargs, default_headers, and extra_body.
  • Extends documentation and tests to cover OpenAI-compatible provider mapping and behavior.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
uv.lock Bumps the project version in the lockfile.
automa_ai/agents/init.py Adds GenericLLM.OPENAI_COMPATIBLE enum value.
automa_ai/agents/agent_factory.py Removes inline resolver and delegates model resolution to automa_ai.models.chat.resolve_chat_model; threads new model options through the factory.
automa_ai/models/chat.py New centralized chat-model resolver, including OpenAI-compatible routing and lazy provider imports.
automa_ai/models/init.py Exposes resolve_chat_model from the new models package.
automa_ai/config/agent_spec.py Extends YAML model spec surface with model_kwargs, default_headers, and extra_body and maps them into factory kwargs.
docs/yaml_agent_spec.md Documents openai-compatible provider plus additional model configuration fields.
tests/test_yaml_agent_spec.py Adds coverage for YAML mapping of OpenAI-compatible model options.
tests/test_agent_factory_openai_env.py Updates tests to target the new resolver module and adds OpenAI-compatible resolver behavior tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread automa_ai/models/chat.py
Comment on lines +27 to +32
# Backward compatibility for older calls shaped as:
# resolve_chat_model(backend, model_name, base_url)
if isinstance(agent_type, str) and base_url is None:
base_url = agent_type
agent_type = None

Comment thread automa_ai/models/chat.py
Comment on lines +60 to +68
if backend == GenericLLM.OPENAI:
return _resolve_openai_chat_model(
model_name=model_name,
agent_type=agent_type,
base_url=base_url,
api_key=api_key,
api_version=api_version,
default_headers=default_headers,
)
Comment thread automa_ai/models/chat.py
Comment on lines +133 to +136
assert resolved_api_key, (
"You must provide an API key (api_key), an Authorization bearer token, "
"or OPENAI_API_KEY in the environment to access OpenAI GPT models"
)
Comment thread automa_ai/models/chat.py
Comment on lines +177 to +181
assert resolved_api_key, (
"You must provide an API key to access OpenAI-compatible models. "
"Checked explicit api_key, Authorization bearer token, plus env vars: "
f"{', '.join(OPENAI_COMPATIBLE_API_KEY_ENV_VARS)}"
)
Comment thread automa_ai/models/chat.py
)
if backend == GenericLLM.CLAUDE:
ChatAnthropic = _load_anthropic_chat_model()
assert api_key, "You must provide an API key to access Anthropic Claude model"
Comment thread automa_ai/models/chat.py
Comment on lines +89 to +91
assert os.getenv(
"GOOGLE_API_KEY"
), "You must add GOOGLE_API_KEY in the system environment."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants