agenthub-python 0.3.2__tar.gz → 0.3.3__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.
Files changed (30) hide show
  1. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/PKG-INFO +1 -1
  2. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/auto_client.py +5 -1
  3. agenthub_python-0.3.3/agenthub/openai_embedding/__init__.py +18 -0
  4. agenthub_python-0.3.3/agenthub/openai_embedding/client.py +80 -0
  5. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/pyproject.toml +1 -1
  6. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/README.md +0 -0
  7. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/__init__.py +0 -0
  8. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/abort_signal.py +0 -0
  9. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/base_client.py +0 -0
  10. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/claude4_6/__init__.py +0 -0
  11. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/claude4_6/client.py +0 -0
  12. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/claude4_8/__init__.py +0 -0
  13. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/claude4_8/client.py +0 -0
  14. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/deepseek_v4/__init__.py +0 -0
  15. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/deepseek_v4/client.py +0 -0
  16. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/gemini3/__init__.py +0 -0
  17. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/gemini3/client.py +0 -0
  18. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/glm5_1/__init__.py +0 -0
  19. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/glm5_1/client.py +0 -0
  20. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/gpt5_5/__init__.py +0 -0
  21. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/gpt5_5/client.py +0 -0
  22. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/integration/__init__.py +0 -0
  23. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/integration/playground.py +0 -0
  24. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/integration/tracer.py +0 -0
  25. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/kimi_k2_6/__init__.py +0 -0
  26. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/kimi_k2_6/client.py +0 -0
  27. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/openai/__init__.py +0 -0
  28. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/openai/client.py +0 -0
  29. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/types.py +0 -0
  30. {agenthub_python-0.3.2 → agenthub_python-0.3.3}/agenthub/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agenthub-python
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: AgentHub is the LLM API Hub for the Agent era, built for high-precision autonomous agents.
5
5
  Keywords: agent,llm,gemini,claude,gpt
6
6
  Author: PrismShadow
@@ -77,6 +77,10 @@ class AutoLLMClient(LLMClient):
77
77
  from .deepseek_v4 import DeepSeekV4Client
78
78
 
79
79
  return DeepSeekV4Client(model=model, api_key=api_key, base_url=base_url)
80
+ elif "openai" in client_type and "embedding" in client_type:
81
+ from .openai_embedding import OpenaiEmbeddingClient
82
+
83
+ return OpenaiEmbeddingClient(model=model, api_key=api_key, base_url=base_url)
80
84
  elif "openai" in client_type:
81
85
  from .openai import OpenaiClient
82
86
 
@@ -84,7 +88,7 @@ class AutoLLMClient(LLMClient):
84
88
  else:
85
89
  raise ValueError(
86
90
  f"{client_type} is not supported. "
87
- "Supported client types: gemini-3, claude-4-8, claude-4-7, claude-4-6, gpt-5.5, gpt-5.4, glm-5.1, kimi-k2.6, kimi-k2.5, deepseek-v4, openai."
91
+ "Supported client types: gemini-3, claude-4-8, claude-4-7, claude-4-6, gpt-5.5, gpt-5.4, glm-5.1, kimi-k2.6, kimi-k2.5, deepseek-v4, openai-embedding, openai."
88
92
  )
89
93
 
90
94
  def transform_uni_config_to_model_config(self, config: UniConfig) -> Any:
@@ -0,0 +1,18 @@
1
+ # Copyright 2025 Prism Shadow. and/or its affiliates
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from .client import OpenaiEmbeddingClient
16
+
17
+
18
+ __all__ = ["OpenaiEmbeddingClient"]
@@ -0,0 +1,80 @@
1
+ # Copyright 2025 Prism Shadow. and/or its affiliates
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import os
16
+ from typing import Any, AsyncIterator
17
+
18
+ from openai import AsyncOpenAI
19
+
20
+ from ..base_client import LLMClient
21
+ from ..types import UniConfig, UniEvent, UniMessage
22
+
23
+
24
+ class OpenaiEmbeddingClient(LLMClient):
25
+ """OpenAI Embeddings-compatible client implementation."""
26
+
27
+ def __init__(self, model: str, api_key: str | None = None, base_url: str | None = None):
28
+ """Initialize OpenAI-compatible embedding client with model, API key, and base URL."""
29
+ self._model = model
30
+ api_key = api_key or os.getenv("OPENAI_API_KEY")
31
+ base_url = base_url or os.getenv("OPENAI_BASE_URL")
32
+ self._client = AsyncOpenAI(api_key=api_key, base_url=base_url)
33
+ self._history: list[UniMessage] = []
34
+
35
+ def transform_uni_config_to_model_config(self, config: UniConfig) -> dict[str, Any]:
36
+ """Transform universal configuration to OpenAI Embeddings configuration."""
37
+ params: dict[str, Any] = {"model": self._model}
38
+ embedding_config = config.get("embedding_config") or {}
39
+ if embedding_config.get("dimensions") is not None:
40
+ params["dimensions"] = embedding_config["dimensions"]
41
+ return params
42
+
43
+ def transform_uni_message_to_model_input(self, messages: list[UniMessage]) -> list[str]:
44
+ """Transform universal messages to OpenAI Embeddings input strings."""
45
+ texts = []
46
+ for msg in messages:
47
+ msg_text = ""
48
+ for item in msg["content_items"]:
49
+ if item["type"] != "text":
50
+ raise ValueError("OpenAI embeddings only support text content items.")
51
+ msg_text += item["text"]
52
+ texts.append(msg_text or " ")
53
+ return texts
54
+
55
+ def transform_model_output_to_uni_event(self, model_output: Any) -> UniEvent:
56
+ """Transform OpenAI Embeddings response to universal event format."""
57
+ usage = getattr(model_output, "usage", None)
58
+ return {
59
+ "role": "assistant",
60
+ "event_type": "stop",
61
+ "content_items": [{"type": "embedding", "embedding": item.embedding} for item in model_output.data],
62
+ "usage_metadata": {
63
+ "cached_tokens": None,
64
+ "prompt_tokens": usage.prompt_tokens if usage else None,
65
+ "thoughts_tokens": None,
66
+ "response_tokens": None,
67
+ },
68
+ "finish_reason": "stop",
69
+ }
70
+
71
+ async def _streaming_response_internal(
72
+ self,
73
+ messages: list[UniMessage],
74
+ config: UniConfig,
75
+ ) -> AsyncIterator[UniEvent]:
76
+ """Generate embeddings using OpenAI Embeddings-compatible API."""
77
+ params = self.transform_uni_config_to_model_config(config)
78
+ params["input"] = self.transform_uni_message_to_model_input(messages)
79
+ result = await self._client.embeddings.create(**params)
80
+ yield self.transform_model_output_to_uni_event(result)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "agenthub-python"
3
- version = "0.3.2"
3
+ version = "0.3.3"
4
4
  description = "AgentHub is the LLM API Hub for the Agent era, built for high-precision autonomous agents."
5
5
  keywords = ["agent", "llm", "gemini", "claude", "gpt"]
6
6
  readme = "README.md"