Skip to content

Commit 78a0925

Browse files
committed
chore: Change IOMapper name to AgentIOMapper. Add minimal docs.
1 parent c95adf3 commit 78a0925

File tree

6 files changed

+29
-17
lines changed

6 files changed

+29
-17
lines changed

Diff for: agntcy_iomapper/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
IOModelSettings,
99
)
1010
from .iomapper import (
11-
IOMapper,
11+
AgentIOMapper,
1212
IOMapperConfig,
1313
IOModelArgs,
1414
)

Diff for: agntcy_iomapper/iomapper.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _validate_obj(self) -> Self:
7575
return self
7676

7777

78-
class IOMapper(BaseIOMapper):
78+
class AgentIOMapper(BaseIOMapper):
7979
_json_search_pattern: ClassVar[re.Pattern] = re.compile(r"```json\n(.*?)\n```", re.DOTALL)
8080

8181
def __init__(
@@ -160,7 +160,6 @@ def _get_agent(
160160
raise ValueError(f"requested model {model_name} not found")
161161

162162
return get_supported_agent(
163-
is_async,
164163
model_name,
165164
model_args=self.config.models[model_name],
166165
system_prompt=system_prompt,
@@ -273,7 +272,7 @@ async def main():
273272
input = IOMapperInput.model_validate_json(inputs)
274273
logging.info(f"Loaded input from {args.inputfile}: {input.model_dump_json()}")
275274

276-
p = IOMapper(config, jinja_env)
275+
p = AgentIOMapper(config, jinja_env)
277276
output = await p.ainvoke(input)
278277
outputs = output.model_dump_json()
279278

Diff for: agntcy_iomapper/supported_agents.py

+18-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,31 @@
1717

1818

1919
def get_supported_agent(
20-
is_async: bool,
2120
model_name: SupportedModelName,
2221
model_args: dict[str, Any] = {},
2322
**kwargs,
2423
) -> Agent:
24+
"""
25+
Creates and returns an `Agent` instance for the given model.
26+
27+
Args:
28+
model_name (SupportedModelName): The name of the model to be used.
29+
If the name starts with "azure:", an `AsyncAzureOpenAI` client is used.
30+
model_args (dict[str, Any], optional): Additional arguments for model
31+
initialization. Defaults to an empty dictionary.
32+
**kwargs: Additional keyword arguments passed to the `Agent` constructor.
33+
34+
Returns:
35+
Agent: An instance of the `Agent` class configured with the specified model.
36+
37+
Notes:
38+
- The `pydantic-ai` package does not currently pass `model_args` to the
39+
inferred model in the constructor, but this behavior might change in
40+
the future.
41+
"""
2542
if model_name.startswith("azure:"):
26-
# Note: the client is always async even if you call run_sync
2743
client = AsyncAzureOpenAI(**model_args)
2844
model = OpenAIModel(model_name[6:], openai_client=client)
2945
return Agent(model, **kwargs)
3046

31-
# Note: The constructor (in pydantic-ai package) does not pass any model args
32-
# to the inferred model. This might change in the future.
3347
return Agent(model_name, **kwargs)

Diff for: pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ version = "0.1.0"
44
license = "Apache-2.0"
55
description = "A tool to transform output from one agent to the input of another."
66
readme = "README.md"
7-
maintainers = ["Reginaldo Costa (regcosta) <[email protected]>"]
7+
authors = ["Jeff Napper <[email protected]>", "Reginaldo Costa <[email protected]>"]
8+
maintainers = ["Jeff Napper <[email protected]>", "Reginaldo Costa <[email protected]>"]
89

910
[tool.poetry.dependencies]
1011
python = "^3.12"

Diff for: tests/test_simple.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55
from openapi_pydantic import DataType, Schema
66

7-
from agntcy_iomapper import IOMapper, IOMapperInput, IOMapperOutput
7+
from agntcy_iomapper import AgentIOMapper, IOMapperInput, IOMapperOutput
88
from agntcy_iomapper.base import ArgumentsDescription
99
from utils import compare_outputs, compare_outputs_async
1010

@@ -109,7 +109,7 @@
109109
)
110110
@pytest.mark.llm
111111
async def test_simple_mapping_async(llm_iomapper_config, jinja_env_async, input, expected_output):
112-
llmIOMapper = IOMapper(llm_iomapper_config, jinja_env_async=jinja_env_async)
112+
llmIOMapper = AgentIOMapper(llm_iomapper_config, jinja_env_async=jinja_env_async)
113113
output = await llmIOMapper.ainvoke(input)
114114
if isinstance(output.data, str):
115115
equalp = await compare_outputs_async(llmIOMapper, output.data, expected_output.data)
@@ -126,7 +126,7 @@ async def test_simple_mapping_async(llm_iomapper_config, jinja_env_async, input,
126126
)
127127
@pytest.mark.llm
128128
def test_simple_mapping(llm_iomapper_config, jinja_env, input, expected_output):
129-
llmIOMapper = IOMapper(llm_iomapper_config, jinja_env=jinja_env)
129+
llmIOMapper = AgentIOMapper(llm_iomapper_config, jinja_env=jinja_env)
130130
output = llmIOMapper.invoke(input)
131131
if isinstance(output.data, str):
132132
equalp = compare_outputs(llmIOMapper, output.data, expected_output.data)

Diff for: tests/utils.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2025 Cisco and/or its affiliates.
22
# SPDX-License-Identifier: Apache-2.0
3-
from agntcy_iomapper import IOMapper
3+
from agntcy_iomapper import AgentIOMapper
44
from agntcy_iomapper.supported_agents import get_supported_agent
55
import re
66

@@ -24,10 +24,9 @@
2424
Reasoning
2525
"""
2626

27-
async def compare_outputs_async(iomapper: IOMapper, text1: str, text2: str) -> bool:
27+
async def compare_outputs_async(iomapper: AgentIOMapper, text1: str, text2: str) -> bool:
2828
model_name = iomapper.config.default_model
2929
agent = get_supported_agent(
30-
True,
3130
model_name,
3231
system_prompt=__COMPARE_SYSTEM_PROMPT,
3332
model_args=iomapper.config.models[model_name],
@@ -38,10 +37,9 @@ async def compare_outputs_async(iomapper: IOMapper, text1: str, text2: str) -> b
3837
match = matches.group(1)
3938
return match is not None and match.startswith("t")
4039

41-
def compare_outputs(iomapper: IOMapper, text1: str, text2: str) -> bool:
40+
def compare_outputs(iomapper: AgentIOMapper, text1: str, text2: str) -> bool:
4241
model_name = iomapper.config.default_model
4342
agent = get_supported_agent(
44-
False,
4543
model_name,
4644
system_prompt=__COMPARE_SYSTEM_PROMPT,
4745
model_args=iomapper.config.models[model_name],

0 commit comments

Comments
 (0)