agn-sdk 1.0.0__py3-none-any.whl
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.
- agn/__init__.py +222 -0
- agn/adapters/__init__.py +104 -0
- agn/adapters/additional_models.py +1605 -0
- agn/adapters/aggregation_platforms.py +1429 -0
- agn/adapters/agnes.py +741 -0
- agn/adapters/anthropic.py +610 -0
- agn/adapters/audio_adapters.py +2039 -0
- agn/adapters/azure.py +479 -0
- agn/adapters/base.py +760 -0
- agn/adapters/chinese.py +2301 -0
- agn/adapters/emerging_models.py +1195 -0
- agn/adapters/factory.py +132 -0
- agn/adapters/gemini.py +666 -0
- agn/adapters/kling.py +365 -0
- agn/adapters/more_models.py +1592 -0
- agn/adapters/openai.py +684 -0
- agn/adapters/pika.py +359 -0
- agn/adapters/runway.py +358 -0
- agn/adapters/stability.py +443 -0
- agn/adapters/volcengine_cv.py +427 -0
- agn/client.py +526 -0
- agn/core/__init__.py +40 -0
- agn/core/config.py +128 -0
- agn/core/errors.py +210 -0
- agn/core/http_client.py +276 -0
- agn/core/retry.py +147 -0
- agn/core/utils.py +229 -0
- agn/models/__init__.py +131 -0
- agn/models/audio.py +155 -0
- agn/models/chat.py +147 -0
- agn/models/common.py +140 -0
- agn/models/image.py +99 -0
- agn/models/options.py +671 -0
- agn/models/video.py +93 -0
- agn/router.py +952 -0
- agn_sdk-1.0.0.dist-info/METADATA +477 -0
- agn_sdk-1.0.0.dist-info/RECORD +38 -0
- agn_sdk-1.0.0.dist-info/WHEEL +4 -0
agn/__init__.py
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AGN-SDK - 多模型统一接口 SDK
|
|
3
|
+
|
|
4
|
+
一套 API 调用所有 AI 模型,无论文本对话、图像生成、视频生成还是语音处理。
|
|
5
|
+
|
|
6
|
+
快速开始:
|
|
7
|
+
|
|
8
|
+
from agn import Client
|
|
9
|
+
|
|
10
|
+
client = Client(provider="agnes", api_key="your-key")
|
|
11
|
+
|
|
12
|
+
# 文本对话
|
|
13
|
+
response = await client.chat(
|
|
14
|
+
model="claude-3-opus",
|
|
15
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
# 图像生成
|
|
19
|
+
result = await client.image_generate(
|
|
20
|
+
model="dall-e-3",
|
|
21
|
+
prompt="A beautiful sunset"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
# 视频生成
|
|
25
|
+
task = await client.video_create(
|
|
26
|
+
model="video-gen-1",
|
|
27
|
+
prompt="A cat walking"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# 语音转文字
|
|
31
|
+
result = await client.transcribe(
|
|
32
|
+
model="whisper-1",
|
|
33
|
+
file="audio.mp3"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# 文字转语音
|
|
37
|
+
result = await client.speech(
|
|
38
|
+
model="tts-1",
|
|
39
|
+
input="Hello world",
|
|
40
|
+
voice="alloy"
|
|
41
|
+
)
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
# 版本信息
|
|
45
|
+
__version__ = "1.0.0"
|
|
46
|
+
|
|
47
|
+
# 核心类
|
|
48
|
+
# 导入所有适配器(触发自动注册)
|
|
49
|
+
import agn.adapters # noqa: F401
|
|
50
|
+
|
|
51
|
+
# 适配器
|
|
52
|
+
from agn.adapters.base import BaseAdapter, Capabilities
|
|
53
|
+
from agn.adapters.factory import AdapterFactory
|
|
54
|
+
from agn.client import Client
|
|
55
|
+
|
|
56
|
+
# 配置
|
|
57
|
+
from agn.core.config import Config, load_env
|
|
58
|
+
|
|
59
|
+
# 错误类型
|
|
60
|
+
from agn.core.errors import (
|
|
61
|
+
AGNError,
|
|
62
|
+
APIError,
|
|
63
|
+
AuthenticationError,
|
|
64
|
+
ModelNotFoundError,
|
|
65
|
+
NetworkError,
|
|
66
|
+
ProviderNotFoundError,
|
|
67
|
+
RateLimitError,
|
|
68
|
+
TimeoutError,
|
|
69
|
+
UnsupportedCapabilityError,
|
|
70
|
+
ValidationError,
|
|
71
|
+
)
|
|
72
|
+
from agn.models.audio import (
|
|
73
|
+
AudioResponseFormat,
|
|
74
|
+
SpeechResult,
|
|
75
|
+
SpeechVoice,
|
|
76
|
+
TranscriptionResult,
|
|
77
|
+
TranscriptionSegment,
|
|
78
|
+
TranscriptionWord,
|
|
79
|
+
)
|
|
80
|
+
from agn.models.chat import (
|
|
81
|
+
ChatChoice,
|
|
82
|
+
ChatCompletion,
|
|
83
|
+
ChatCompletionChunk,
|
|
84
|
+
ChatCompletionDelta,
|
|
85
|
+
ChatCompletionRequest,
|
|
86
|
+
ChatFunction,
|
|
87
|
+
ChatMessage,
|
|
88
|
+
ChatUsage,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
# 数据模型
|
|
92
|
+
from agn.models.common import (
|
|
93
|
+
ImageSize,
|
|
94
|
+
ModelInfo,
|
|
95
|
+
ModelType,
|
|
96
|
+
ProviderConfig,
|
|
97
|
+
ProviderInfo,
|
|
98
|
+
TaskStatus,
|
|
99
|
+
VideoMode,
|
|
100
|
+
)
|
|
101
|
+
from agn.models.image import (
|
|
102
|
+
ImageData,
|
|
103
|
+
ImageEditRequest,
|
|
104
|
+
ImageGenerationOptions,
|
|
105
|
+
ImageGenerationResult,
|
|
106
|
+
ImageVariationRequest,
|
|
107
|
+
)
|
|
108
|
+
from agn.models.options import (
|
|
109
|
+
ANTHROPIC_MAPPING,
|
|
110
|
+
COHERE_MAPPING,
|
|
111
|
+
GEMINI_MAPPING,
|
|
112
|
+
OPENAI_COMPATIBLE_MAPPING,
|
|
113
|
+
AspectRatio,
|
|
114
|
+
ChatOptions,
|
|
115
|
+
EmbeddingResult,
|
|
116
|
+
EmbedOptions,
|
|
117
|
+
FunctionDefinition,
|
|
118
|
+
FunctionParameter,
|
|
119
|
+
ImageOptions,
|
|
120
|
+
ImageStyle,
|
|
121
|
+
ParameterMapping,
|
|
122
|
+
ReasoningEffort,
|
|
123
|
+
ResponseFormat,
|
|
124
|
+
SpeechOptions,
|
|
125
|
+
ToolCall,
|
|
126
|
+
ToolChoice,
|
|
127
|
+
ToolDefinition,
|
|
128
|
+
TranscribeOptions,
|
|
129
|
+
VideoDuration,
|
|
130
|
+
VideoOptions,
|
|
131
|
+
)
|
|
132
|
+
from agn.models.video import (
|
|
133
|
+
VideoGenerationOptions,
|
|
134
|
+
VideoStatus,
|
|
135
|
+
VideoTask,
|
|
136
|
+
VideoTaskCreate,
|
|
137
|
+
)
|
|
138
|
+
from agn.router import Router
|
|
139
|
+
|
|
140
|
+
__all__ = [
|
|
141
|
+
# 版本
|
|
142
|
+
"__version__",
|
|
143
|
+
# 核心类
|
|
144
|
+
"Client",
|
|
145
|
+
"Router",
|
|
146
|
+
# 通用模型
|
|
147
|
+
"ProviderConfig",
|
|
148
|
+
"ModelInfo",
|
|
149
|
+
"ProviderInfo",
|
|
150
|
+
"ModelType",
|
|
151
|
+
"VideoMode",
|
|
152
|
+
"ImageSize",
|
|
153
|
+
"TaskStatus",
|
|
154
|
+
# 文本对话模型
|
|
155
|
+
"ChatMessage",
|
|
156
|
+
"ChatFunction",
|
|
157
|
+
"ChatChoice",
|
|
158
|
+
"ChatUsage",
|
|
159
|
+
"ChatCompletion",
|
|
160
|
+
"ChatCompletionChunk",
|
|
161
|
+
"ChatCompletionDelta",
|
|
162
|
+
"ChatCompletionRequest",
|
|
163
|
+
# 图像生成模型
|
|
164
|
+
"ImageData",
|
|
165
|
+
"ImageGenerationResult",
|
|
166
|
+
"ImageEditRequest",
|
|
167
|
+
"ImageVariationRequest",
|
|
168
|
+
"ImageGenerationOptions",
|
|
169
|
+
# 视频生成模型
|
|
170
|
+
"VideoTask",
|
|
171
|
+
"VideoStatus",
|
|
172
|
+
"VideoGenerationOptions",
|
|
173
|
+
"VideoTaskCreate",
|
|
174
|
+
# 语音模型
|
|
175
|
+
"TranscriptionResult",
|
|
176
|
+
"TranscriptionSegment",
|
|
177
|
+
"TranscriptionWord",
|
|
178
|
+
"SpeechResult",
|
|
179
|
+
"AudioResponseFormat",
|
|
180
|
+
"SpeechVoice",
|
|
181
|
+
# 统一请求选项
|
|
182
|
+
"ChatOptions",
|
|
183
|
+
"ImageOptions",
|
|
184
|
+
"VideoOptions",
|
|
185
|
+
"EmbedOptions",
|
|
186
|
+
"EmbeddingResult",
|
|
187
|
+
"TranscribeOptions",
|
|
188
|
+
"SpeechOptions",
|
|
189
|
+
"ToolDefinition",
|
|
190
|
+
"ToolCall",
|
|
191
|
+
"ToolChoice",
|
|
192
|
+
"FunctionDefinition",
|
|
193
|
+
"FunctionParameter",
|
|
194
|
+
"ReasoningEffort",
|
|
195
|
+
"ImageStyle",
|
|
196
|
+
"VideoDuration",
|
|
197
|
+
"AspectRatio",
|
|
198
|
+
"ResponseFormat",
|
|
199
|
+
"ParameterMapping",
|
|
200
|
+
"Capabilities",
|
|
201
|
+
"OPENAI_COMPATIBLE_MAPPING",
|
|
202
|
+
"ANTHROPIC_MAPPING",
|
|
203
|
+
"GEMINI_MAPPING",
|
|
204
|
+
"COHERE_MAPPING",
|
|
205
|
+
# 错误类型
|
|
206
|
+
"AGNError",
|
|
207
|
+
"APIError",
|
|
208
|
+
"AuthenticationError",
|
|
209
|
+
"ModelNotFoundError",
|
|
210
|
+
"NetworkError",
|
|
211
|
+
"ProviderNotFoundError",
|
|
212
|
+
"RateLimitError",
|
|
213
|
+
"TimeoutError",
|
|
214
|
+
"UnsupportedCapabilityError",
|
|
215
|
+
"ValidationError",
|
|
216
|
+
# 配置
|
|
217
|
+
"Config",
|
|
218
|
+
"load_env",
|
|
219
|
+
# 适配器
|
|
220
|
+
"BaseAdapter",
|
|
221
|
+
"AdapterFactory",
|
|
222
|
+
]
|
agn/adapters/__init__.py
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AGN-SDK 适配器层
|
|
3
|
+
|
|
4
|
+
包含适配器基类和所有 Provider 适配器实现。
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from agn.adapters.additional_models import (
|
|
8
|
+
GrokAdapter,
|
|
9
|
+
GroqAdapter,
|
|
10
|
+
HunyuanAdapter,
|
|
11
|
+
SenseNovaAdapter,
|
|
12
|
+
YiAdapter,
|
|
13
|
+
)
|
|
14
|
+
from agn.adapters.aggregation_platforms import (
|
|
15
|
+
CloudflareAIAdapter,
|
|
16
|
+
FireworksAIAdapter,
|
|
17
|
+
SiliconFlowAdapter,
|
|
18
|
+
TogetherAIAdapter,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
# 导入所有适配器(自动注册)
|
|
22
|
+
from agn.adapters.agnes import AgnesAdapter
|
|
23
|
+
from agn.adapters.anthropic import AnthropicAdapter
|
|
24
|
+
from agn.adapters.audio_adapters import (
|
|
25
|
+
AssemblyAIAdapter,
|
|
26
|
+
CartesiaAdapter,
|
|
27
|
+
DeepgramAdapter,
|
|
28
|
+
EdgeTTSAdapter,
|
|
29
|
+
ElevenLabsAdapter,
|
|
30
|
+
)
|
|
31
|
+
from agn.adapters.azure import AzureAdapter
|
|
32
|
+
from agn.adapters.base import BaseAdapter, Capabilities
|
|
33
|
+
from agn.adapters.chinese import (
|
|
34
|
+
DoubaoAdapter,
|
|
35
|
+
ErnieAdapter,
|
|
36
|
+
KimiAdapter,
|
|
37
|
+
MiniMaxAdapter,
|
|
38
|
+
QwenAdapter,
|
|
39
|
+
ZhipuAdapter,
|
|
40
|
+
)
|
|
41
|
+
from agn.adapters.emerging_models import (
|
|
42
|
+
IdeogramAdapter,
|
|
43
|
+
LlamaAdapter,
|
|
44
|
+
LumaAdapter,
|
|
45
|
+
)
|
|
46
|
+
from agn.adapters.factory import AdapterFactory
|
|
47
|
+
from agn.adapters.gemini import GeminiAdapter
|
|
48
|
+
from agn.adapters.kling import KlingAdapter
|
|
49
|
+
from agn.adapters.more_models import (
|
|
50
|
+
CohereAdapter,
|
|
51
|
+
DeepSeekAdapter,
|
|
52
|
+
MistralAdapter,
|
|
53
|
+
PerplexityAdapter,
|
|
54
|
+
StepFunAdapter,
|
|
55
|
+
)
|
|
56
|
+
from agn.adapters.openai import OpenAIAdapter
|
|
57
|
+
from agn.adapters.pika import PikaAdapter
|
|
58
|
+
from agn.adapters.runway import RunwayAdapter
|
|
59
|
+
from agn.adapters.stability import StabilityAdapter
|
|
60
|
+
from agn.adapters.volcengine_cv import VolcengineCVAdapter
|
|
61
|
+
|
|
62
|
+
__all__ = [
|
|
63
|
+
"BaseAdapter",
|
|
64
|
+
"Capabilities",
|
|
65
|
+
"AdapterFactory",
|
|
66
|
+
"AgnesAdapter",
|
|
67
|
+
"OpenAIAdapter",
|
|
68
|
+
"AzureAdapter",
|
|
69
|
+
"RunwayAdapter",
|
|
70
|
+
"PikaAdapter",
|
|
71
|
+
"StabilityAdapter",
|
|
72
|
+
"QwenAdapter",
|
|
73
|
+
"ZhipuAdapter",
|
|
74
|
+
"DoubaoAdapter",
|
|
75
|
+
"ErnieAdapter",
|
|
76
|
+
"KimiAdapter",
|
|
77
|
+
"MiniMaxAdapter",
|
|
78
|
+
"AnthropicAdapter",
|
|
79
|
+
"GeminiAdapter",
|
|
80
|
+
"KlingAdapter",
|
|
81
|
+
"VolcengineCVAdapter",
|
|
82
|
+
"DeepSeekAdapter",
|
|
83
|
+
"StepFunAdapter",
|
|
84
|
+
"MistralAdapter",
|
|
85
|
+
"CohereAdapter",
|
|
86
|
+
"PerplexityAdapter",
|
|
87
|
+
"GrokAdapter",
|
|
88
|
+
"YiAdapter",
|
|
89
|
+
"SenseNovaAdapter",
|
|
90
|
+
"HunyuanAdapter",
|
|
91
|
+
"GroqAdapter",
|
|
92
|
+
"SiliconFlowAdapter",
|
|
93
|
+
"TogetherAIAdapter",
|
|
94
|
+
"FireworksAIAdapter",
|
|
95
|
+
"CloudflareAIAdapter",
|
|
96
|
+
"ElevenLabsAdapter",
|
|
97
|
+
"DeepgramAdapter",
|
|
98
|
+
"AssemblyAIAdapter",
|
|
99
|
+
"CartesiaAdapter",
|
|
100
|
+
"EdgeTTSAdapter",
|
|
101
|
+
"IdeogramAdapter",
|
|
102
|
+
"LumaAdapter",
|
|
103
|
+
"LlamaAdapter",
|
|
104
|
+
]
|