hopeit-agents 0.2.0b1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: hopeit-agents
3
+ Version: 0.2.0b1
4
+ Summary: Hopeit integration for building agentic APIs
5
+ Author-email: Leo Smerling & Pablo Canto <contact@hopeit.com.ar>, Leo Smerling <contact@hopeit.com.ar>, Pablo Canto <contact@hopeit.com.ar>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/hopeit-git/hopeit.agents
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Programming Language :: Python
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Framework :: AsyncIO
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: hopeit.engine>=0.30.1
19
+ Requires-Dist: pydantic-ai-slim[openai]<3,>=2.9
20
+
21
+ # hopeit-agents
22
+
23
+ Shared Hopeit integration for agentic APIs built with `hopeit.engine` and Pydantic AI.
24
+
25
+ The initial package provides a configuration-driven model factory for OpenAI and an Ollama
26
+ server. Application code selects the provider with `AgentModelSettings`; agents and tools remain
27
+ provider-independent.
28
+
29
+ This project intentionally does not provide another agent loop, message hierarchy, tool
30
+ registry, or tracing format. Those responsibilities remain with Pydantic AI.
@@ -0,0 +1,10 @@
1
+ # hopeit-agents
2
+
3
+ Shared Hopeit integration for agentic APIs built with `hopeit.engine` and Pydantic AI.
4
+
5
+ The initial package provides a configuration-driven model factory for OpenAI and an Ollama
6
+ server. Application code selects the provider with `AgentModelSettings`; agents and tools remain
7
+ provider-independent.
8
+
9
+ This project intentionally does not provide another agent loop, message hierarchy, tool
10
+ registry, or tracing format. Those responsibilities remain with Pydantic AI.
@@ -0,0 +1,46 @@
1
+ [project]
2
+ name = "hopeit-agents"
3
+ version = "0.2.0b1"
4
+ requires-python = ">=3.11"
5
+
6
+ description = "Hopeit integration for building agentic APIs"
7
+ dynamic = ["readme"]
8
+
9
+ dependencies = [
10
+ "hopeit.engine>=0.30.1",
11
+ "pydantic-ai-slim[openai]>=2.9,<3",
12
+ ]
13
+
14
+ license = "Apache-2.0"
15
+ authors = [
16
+ { name = "Leo Smerling & Pablo Canto", email = "contact@hopeit.com.ar" },
17
+ { name = "Leo Smerling", email = "contact@hopeit.com.ar" },
18
+ { name = "Pablo Canto", email = "contact@hopeit.com.ar" },
19
+ ]
20
+ classifiers = [
21
+ "Intended Audience :: Developers",
22
+ "Programming Language :: Python",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Programming Language :: Python :: 3.14",
27
+ "Development Status :: 4 - Beta",
28
+ "Framework :: AsyncIO",
29
+ ]
30
+
31
+ [project.urls]
32
+ "Homepage" = "https://github.com/hopeit-git/hopeit.agents"
33
+
34
+ [tool.setuptools]
35
+ include-package-data = true
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
39
+ include = ["hopeit_agents*"]
40
+ namespaces = true
41
+
42
+ [tool.setuptools.package-data]
43
+ hopeit_agents = ["py.typed"]
44
+
45
+ [tool.setuptools.dynamic]
46
+ readme = { file = ["README.md"], content-type = "text/markdown" }
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,76 @@
1
+ """Configuration-driven model construction for Hopeit agents."""
2
+
3
+ import os
4
+ from collections.abc import Mapping
5
+ from enum import StrEnum
6
+
7
+ from hopeit.dataobjects import dataclass, dataobject
8
+ from pydantic_ai.models import Model
9
+ from pydantic_ai.models.ollama import OllamaModel
10
+ from pydantic_ai.models.openai import OpenAIChatModel
11
+ from pydantic_ai.providers.ollama import OllamaProvider
12
+ from pydantic_ai.providers.openai import OpenAIProvider
13
+
14
+ SETTINGS_KEY = "agent_model"
15
+
16
+
17
+ class AgentModelProvider(StrEnum):
18
+ """Model providers supported by the common Hopeit configuration."""
19
+
20
+ OPENAI = "openai"
21
+ OLLAMA = "ollama"
22
+
23
+
24
+ @dataobject
25
+ @dataclass
26
+ class AgentModelSettings:
27
+ """Settings used to construct the model shared by Hopeit agent events."""
28
+
29
+ provider: AgentModelProvider
30
+ model_name: str
31
+ base_url: str | None = None
32
+ api_key_env: str | None = None
33
+
34
+ def resolve_api_key(self, env: Mapping[str, str] | None = None) -> str | None:
35
+ """Resolve a provider API key from the configured environment variable."""
36
+ source = os.environ if env is None else env
37
+ env_name = self.api_key_env
38
+ if env_name is None:
39
+ env_name = (
40
+ "OPENAI_API_KEY" if self.provider == AgentModelProvider.OPENAI else "OLLAMA_API_KEY"
41
+ )
42
+ value = source.get(env_name)
43
+ return value if value else None
44
+
45
+ def resolve_base_url(self, env: Mapping[str, str] | None = None) -> str | None:
46
+ """Resolve an explicit base URL, with Ollama environment fallback."""
47
+ if self.base_url:
48
+ return self.base_url
49
+ if self.provider != AgentModelProvider.OLLAMA:
50
+ return None
51
+ source = os.environ if env is None else env
52
+ return source.get("OLLAMA_BASE_URL")
53
+
54
+
55
+ def build_agent_model(
56
+ settings: AgentModelSettings,
57
+ *,
58
+ env: Mapping[str, str] | None = None,
59
+ ) -> Model:
60
+ """Build an OpenAI or Ollama model without leaking provider checks into agents."""
61
+ api_key = settings.resolve_api_key(env)
62
+ base_url = settings.resolve_base_url(env)
63
+
64
+ match settings.provider:
65
+ case AgentModelProvider.OPENAI:
66
+ return OpenAIChatModel(
67
+ settings.model_name,
68
+ provider=OpenAIProvider(base_url=base_url, api_key=api_key),
69
+ )
70
+ case AgentModelProvider.OLLAMA:
71
+ return OllamaModel(
72
+ settings.model_name,
73
+ provider=OllamaProvider(base_url=base_url, api_key=api_key),
74
+ )
75
+
76
+ raise ValueError(f"Unsupported agent model provider: {settings.provider}")
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: hopeit-agents
3
+ Version: 0.2.0b1
4
+ Summary: Hopeit integration for building agentic APIs
5
+ Author-email: Leo Smerling & Pablo Canto <contact@hopeit.com.ar>, Leo Smerling <contact@hopeit.com.ar>, Pablo Canto <contact@hopeit.com.ar>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/hopeit-git/hopeit.agents
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Programming Language :: Python
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Framework :: AsyncIO
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: hopeit.engine>=0.30.1
19
+ Requires-Dist: pydantic-ai-slim[openai]<3,>=2.9
20
+
21
+ # hopeit-agents
22
+
23
+ Shared Hopeit integration for agentic APIs built with `hopeit.engine` and Pydantic AI.
24
+
25
+ The initial package provides a configuration-driven model factory for OpenAI and an Ollama
26
+ server. Application code selects the provider with `AgentModelSettings`; agents and tools remain
27
+ provider-independent.
28
+
29
+ This project intentionally does not provide another agent loop, message hierarchy, tool
30
+ registry, or tracing format. Those responsibilities remain with Pydantic AI.
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/hopeit_agents/agent_model.py
4
+ src/hopeit_agents/py.typed
5
+ src/hopeit_agents.egg-info/PKG-INFO
6
+ src/hopeit_agents.egg-info/SOURCES.txt
7
+ src/hopeit_agents.egg-info/dependency_links.txt
8
+ src/hopeit_agents.egg-info/requires.txt
9
+ src/hopeit_agents.egg-info/top_level.txt
10
+ test/test_agent_model.py
@@ -0,0 +1,2 @@
1
+ hopeit.engine>=0.30.1
2
+ pydantic-ai-slim[openai]<3,>=2.9
@@ -0,0 +1 @@
1
+ hopeit_agents
@@ -0,0 +1,42 @@
1
+ """Tests for the shared agent model factory."""
2
+
3
+ from pydantic_ai.models.ollama import OllamaModel
4
+ from pydantic_ai.models.openai import OpenAIChatModel
5
+
6
+ from hopeit_agents.agent_model import (
7
+ SETTINGS_KEY,
8
+ AgentModelProvider,
9
+ AgentModelSettings,
10
+ build_agent_model,
11
+ )
12
+
13
+
14
+ def test_agent_model_settings_key_is_provider_neutral() -> None:
15
+ assert SETTINGS_KEY == "agent_model"
16
+
17
+
18
+ def test_build_openai_model_from_configuration() -> None:
19
+ settings = AgentModelSettings(
20
+ provider=AgentModelProvider.OPENAI,
21
+ model_name="gpt-5.2",
22
+ api_key_env="TEST_OPENAI_API_KEY",
23
+ )
24
+
25
+ model = build_agent_model(settings, env={"TEST_OPENAI_API_KEY": "test-key"})
26
+
27
+ assert isinstance(model, OpenAIChatModel)
28
+ assert model.system == "openai"
29
+ assert str(model.base_url) == "https://api.openai.com/v1/"
30
+
31
+
32
+ def test_build_ollama_model_from_configuration() -> None:
33
+ settings = AgentModelSettings(
34
+ provider=AgentModelProvider.OLLAMA,
35
+ model_name="qwen3",
36
+ )
37
+
38
+ model = build_agent_model(settings, env={"OLLAMA_BASE_URL": "http://localhost:11434/v1"})
39
+
40
+ assert isinstance(model, OllamaModel)
41
+ assert model.system == "ollama"
42
+ assert str(model.base_url) == "http://localhost:11434/v1/"