Skip to content

Commit 83db477

Browse files
Merge SDK headers into single x-dashscope-sdk-client field
1 parent 28d570f commit 83db477

12 files changed

Lines changed: 15 additions & 564 deletions

File tree

‎dashscope/acli/providers/tongyi.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ def __init__(
4848
request_timeout: int = 60,
4949
protocol: str = "openai",
5050
base_url: str | None = None,
51+
module: str = "",
5152
):
5253
self.model = model
5354
self.api_key = api_key
5455
self.request_timeout = request_timeout
5556
self.protocol = protocol
5657
self.base_url = (base_url or DASHSCOPE_BASE_URL).rstrip("/")
58+
self.module = module
5759

5860
def _convert_tools(self, tools: list[dict] | None) -> list[dict] | None:
5961
if not tools:
@@ -126,8 +128,10 @@ def _get_headers(self) -> dict:
126128
if self.api_key:
127129
headers["Authorization"] = f"Bearer {self.api_key}"
128130
if not os.environ.get("DASHSCOPE_DISABLE_SDK_HEADERS"):
129-
headers["x-dashscope-sdk-client"] = "acli"
130-
headers["x-dashscope-sdk-version"] = __version__
131+
parts = ["acli", __version__]
132+
if self.module:
133+
parts.append(self.module)
134+
headers["x-dashscope-sdk-client"] = "/".join(parts)
131135
headers["x-dashscope-sdk-session-id"] = SDK_SESSION_ID
132136
return headers
133137

‎dashscope/agentstudio/__init__.py‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,6 @@
7070
DeploymentCreateParams,
7171
DeploymentUpdateParams,
7272
SessionEventSendParams,
73-
WebhookEndpointCreateParams,
74-
WebhookEndpointUpdateParams,
75-
WebhookEventListParams,
76-
)
77-
from .constants import (
78-
WebhookDeliveryStatus,
79-
WebhookDisabledReason,
80-
WebhookEventType,
81-
WebhookStatus,
8273
)
8374

8475
__all__ = [
@@ -128,11 +119,4 @@
128119
"DeploymentCreateParams",
129120
"DeploymentUpdateParams",
130121
"SessionEventSendParams",
131-
"WebhookEndpointCreateParams",
132-
"WebhookEndpointUpdateParams",
133-
"WebhookEventListParams",
134-
"WebhookStatus",
135-
"WebhookDisabledReason",
136-
"WebhookDeliveryStatus",
137-
"WebhookEventType",
138122
]

‎dashscope/agentstudio/client.py‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
from dashscope.agentstudio.resources.sessions import Sessions, AsyncSessions
2525
from dashscope.agentstudio.resources.skills import Skills, AsyncSkills
2626
from dashscope.agentstudio.resources.vaults import Vaults, AsyncVaults
27-
from dashscope.agentstudio.resources.webhook_endpoints import (
28-
AsyncWebhookEndpoints,
29-
WebhookEndpoints,
30-
)
3127
from dashscope.agentstudio.constants import (
3228
AGENTSTUDIO_BASE_URL_TEMPLATE,
3329
AGENTSTUDIO_DEFAULT_REGION,
@@ -133,7 +129,6 @@ def __init__(
133129
self.files = Files(self)
134130
self.skills = Skills(self)
135131
self.vaults = Vaults(self)
136-
self.webhook_endpoints = WebhookEndpoints(self)
137132

138133
def close(self) -> None:
139134
self.transport.close()
@@ -206,7 +201,6 @@ def __init__(
206201
self.files = AsyncFiles(self)
207202
self.skills = AsyncSkills(self)
208203
self.vaults = AsyncVaults(self)
209-
self.webhook_endpoints = AsyncWebhookEndpoints(self)
210204

211205
async def aclose(self) -> None:
212206
await self.transport.aclose()

‎dashscope/agentstudio/constants.py‎

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -93,113 +93,3 @@ class SessionStatus(StrEnum):
9393
RUNNING = "running"
9494
RESCHEDULING = "rescheduling"
9595
TERMINATED = "terminated"
96-
97-
98-
class WebhookStatus(StrEnum):
99-
"""Webhook endpoint activation status."""
100-
101-
# The endpoint can receive webhook deliveries.
102-
ACTIVE = "ACTIVE"
103-
# The endpoint does not receive webhook deliveries.
104-
DISABLED = "DISABLED"
105-
106-
107-
class WebhookDisabledReason(StrEnum):
108-
"""Reason why a webhook endpoint was disabled."""
109-
110-
# The endpoint was disabled manually.
111-
MANUAL = "MANUAL"
112-
# The endpoint reached the consecutive delivery failure threshold.
113-
CONSECUTIVE_DELIVERY_FAILURES = "CONSECUTIVE_DELIVERY_FAILURES"
114-
# The endpoint returned an HTTP redirect response.
115-
REDIRECT_RESPONSE = "REDIRECT_RESPONSE"
116-
# The endpoint failed server-side request forgery validation.
117-
SSRF_VALIDATION_FAILED = "SSRF_VALIDATION_FAILED"
118-
# The endpoint failed Transport Layer Security validation.
119-
TLS_VALIDATION_FAILED = "TLS_VALIDATION_FAILED"
120-
121-
122-
class WebhookDeliveryStatus(StrEnum):
123-
"""Webhook delivery status."""
124-
125-
# The delivery is waiting to start.
126-
PENDING = "PENDING"
127-
# The delivery is currently being sent.
128-
DELIVERING = "DELIVERING"
129-
# The delivery is waiting for its next retry.
130-
WAITING_RETRY = "WAITING_RETRY"
131-
# The delivery completed successfully.
132-
SUCCEEDED = "SUCCEEDED"
133-
# The delivery exhausted all attempts.
134-
FAILED = "FAILED"
135-
# The delivery was canceled because its endpoint was disabled or deleted.
136-
CANCELED = "CANCELED"
137-
138-
139-
class WebhookEventType(StrEnum):
140-
"""Event types accepted by webhook endpoint subscriptions."""
141-
142-
# A session was created.
143-
SESSION_CREATED = "session.created"
144-
# A session was updated.
145-
SESSION_UPDATED = "session.updated"
146-
# A session was archived.
147-
SESSION_ARCHIVED = "session.archived"
148-
# A session was deleted.
149-
SESSION_DELETED = "session.deleted"
150-
# A session run started.
151-
SESSION_STATUS_RUN_STARTED = "session.status_run_started"
152-
# A session entered the idle state.
153-
SESSION_STATUS_IDLED = "session.status_idled"
154-
# A session entered the terminated state.
155-
SESSION_STATUS_TERMINATED = "session.status_terminated"
156-
# A session thread was created.
157-
SESSION_THREAD_CREATED = "session.thread_created"
158-
# A session thread run started.
159-
SESSION_THREAD_RUN_STARTED = "session.thread_run_started"
160-
# A session thread entered the idle state.
161-
SESSION_THREAD_IDLED = "session.thread_idled"
162-
# A session thread entered the terminated state.
163-
SESSION_THREAD_TERMINATED = "session.thread_terminated"
164-
# An agent was created.
165-
AGENT_CREATED = "agent.created"
166-
# An agent was updated.
167-
AGENT_UPDATED = "agent.updated"
168-
# An agent was archived.
169-
AGENT_ARCHIVED = "agent.archived"
170-
# A deployment was created.
171-
DEPLOYMENT_CREATED = "deployment.created"
172-
# A deployment was updated.
173-
DEPLOYMENT_UPDATED = "deployment.updated"
174-
# A deployment was archived.
175-
DEPLOYMENT_ARCHIVED = "deployment.archived"
176-
# A deployment was paused.
177-
DEPLOYMENT_PAUSED = "deployment.paused"
178-
# A deployment was resumed.
179-
DEPLOYMENT_UNPAUSED = "deployment.unpaused"
180-
# A deployment run started.
181-
DEPLOYMENT_RUN_STARTED = "deployment_run.started"
182-
# A deployment run failed.
183-
DEPLOYMENT_RUN_FAILED = "deployment_run.failed"
184-
# A deployment run succeeded.
185-
DEPLOYMENT_RUN_SUCCEEDED = "deployment_run.succeeded"
186-
# An environment was created.
187-
ENVIRONMENT_CREATED = "environment.created"
188-
# An environment was updated.
189-
ENVIRONMENT_UPDATED = "environment.updated"
190-
# An environment was archived.
191-
ENVIRONMENT_ARCHIVED = "environment.archived"
192-
# An environment was deleted.
193-
ENVIRONMENT_DELETED = "environment.deleted"
194-
# A vault was created.
195-
VAULT_CREATED = "vault.created"
196-
# A vault was archived.
197-
VAULT_ARCHIVED = "vault.archived"
198-
# A vault was deleted.
199-
VAULT_DELETED = "vault.deleted"
200-
# A vault credential was created.
201-
VAULT_CREDENTIAL_CREATED = "vault_credential.created"
202-
# A vault credential was archived.
203-
VAULT_CREDENTIAL_ARCHIVED = "vault_credential.archived"
204-
# A vault credential was deleted.
205-
VAULT_CREDENTIAL_DELETED = "vault_credential.deleted"

‎dashscope/agentstudio/resources/__init__.py‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@
4646
Credentials,
4747
Vaults,
4848
)
49-
from dashscope.agentstudio.resources.webhook_endpoints import (
50-
AsyncWebhookEndpoints,
51-
WebhookEndpoints,
52-
)
5349

5450
__all__ = [
5551
"Agents",
@@ -74,8 +70,6 @@
7470
"AsyncSessionEvents",
7571
"Vaults",
7672
"AsyncVaults",
77-
"WebhookEndpoints",
78-
"AsyncWebhookEndpoints",
7973
"_TypedEventStream",
8074
"_AioTypedEventStream",
8175
]

‎dashscope/agentstudio/resources/_helpers.py‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
Skill,
2020
SkillVersion,
2121
Vault,
22-
WebhookEndpoint,
23-
WebhookEvent,
24-
WebhookSecretReset,
2522
parse_server_event,
2623
)
2724

@@ -71,20 +68,6 @@ def _coerce_credential(payload: Mapping[str, Any]) -> Credential:
7168
return Credential(**dict(payload))
7269

7370

74-
def _coerce_webhook_endpoint(payload: Mapping[str, Any]) -> WebhookEndpoint:
75-
return WebhookEndpoint(**dict(payload))
76-
77-
78-
def _coerce_webhook_event(payload: Mapping[str, Any]) -> WebhookEvent:
79-
return WebhookEvent(**dict(payload))
80-
81-
82-
def _coerce_webhook_secret_reset(
83-
payload: Mapping[str, Any],
84-
) -> WebhookSecretReset:
85-
return WebhookSecretReset(**dict(payload))
86-
87-
8871
def _coerce_deployment(payload: Mapping[str, Any]) -> Deployment:
8972
return Deployment(**dict(payload))
9073

0 commit comments

Comments
 (0)