Skip to content

Commit 05487b3

Browse files
committed
fix spec ModelInput field and prompt syntax
1 parent 82c7de4 commit 05487b3

File tree

7 files changed

+25
-18
lines changed

7 files changed

+25
-18
lines changed

CHANGLOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [0.1.18] - 2025-10-10
2+
### Added
3+
- fix prompt syntax error, use Union instead of |
4+
5+
## [0.1.17] - 2025-10-10
6+
### Added
7+
- fix trace spec ModelInput field name, from model_tool_choice to tool_choice
8+
19
## [0.1.16] - 2025-09-24
210
### Added
311
- support custom trace connect ptaas trace

cozeloop/internal/httpclient/http_client.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# SPDX-License-Identifier: MIT
33

44
import logging
5-
import typing
6-
from typing import Dict, Type, TypeVar, Any, Generator
5+
from typing import Dict, Type, TypeVar, Any, Union
76

87
import httpx
98
import pydantic
@@ -23,17 +22,17 @@ def __init__(self):
2322
self.sync_client = httpx.Client()
2423
self.async_client = httpx.AsyncClient()
2524

26-
def request(self, method: str, url: URL | str, **kwargs: Any) -> Response:
25+
def request(self, method: str, url: Union[URL, str], **kwargs: Any) -> Response:
2726
return self.sync_client.request(method, url, **kwargs)
2827

29-
def stream(self, method: str, url: URL | str, **kwargs: Any):
28+
def stream(self, method: str, url: Union[URL, str], **kwargs: Any):
3029
"""Return synchronous stream context manager"""
3130
return self.sync_client.stream(method, url, **kwargs)
3231

33-
async def arequest(self, method: str, url: URL | str, **kwargs: Any) -> Response:
32+
async def arequest(self, method: str, url: Union[URL, str], **kwargs: Any) -> Response:
3433
return await self.async_client.request(method, url, **kwargs)
3534

36-
def astream(self, method: str, url: URL | str, **kwargs: Any):
35+
def astream(self, method: str, url: Union[URL, str], **kwargs: Any):
3736
"""Return asynchronous stream context manager"""
3837
return self.async_client.stream(method, url, **kwargs)
3938

cozeloop/internal/stream/sse.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from __future__ import annotations
55

66
import json
7-
from typing import Any, Iterator, Optional, AsyncIterator
7+
from typing import Any, Iterator, Optional, AsyncIterator, Union
88

99

1010
class ServerSentEvent:
@@ -18,10 +18,10 @@ class ServerSentEvent:
1818
def __init__(
1919
self,
2020
*,
21-
event: str | None = None,
22-
data: str | None = None,
23-
id: str | None = None,
24-
retry: int | None = None,
21+
event: Union[str, None] = None,
22+
data: Union[str, None] = None,
23+
id: Union[str, None] = None,
24+
retry: Union[int, None] = None,
2525
) -> None:
2626
"""
2727
Initialize ServerSentEvent
@@ -41,17 +41,17 @@ def __init__(
4141
self._retry = retry
4242

4343
@property
44-
def event(self) -> str | None:
44+
def event(self) -> Union[str, None]:
4545
"""Get event type"""
4646
return self._event
4747

4848
@property
49-
def id(self) -> str | None:
49+
def id(self) -> Union[str, None]:
5050
"""Get event ID"""
5151
return self._id
5252

5353
@property
54-
def retry(self) -> int | None:
54+
def retry(self) -> Union[int, None]:
5555
"""Get retry interval"""
5656
return self._retry
5757

cozeloop/internal/trace/span.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def deep_copy_message_of_model_input(self, src: ModelInput) -> ModelInput:
204204
) for part in message.parts]) for message in src.messages]
205205

206206
result.tools = src.tools
207-
result.model_tool_choice = src.model_tool_choice
207+
result.tool_choice = src.tool_choice
208208
return result
209209

210210
def get_model_input_bytes_size(self, m_content):

cozeloop/internal/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
22
# SPDX-License-Identifier: MIT
33

4-
VERSION = 'v0.1.16'
4+
VERSION = 'v0.1.18'

cozeloop/spec/tracespec/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class ModelInput(BaseModel):
1111
messages: Optional[List['ModelMessage']] = None
1212
tools: Optional[List['ModelTool']] = None
13-
model_tool_choice: Optional['ModelToolChoice'] = None
13+
tool_choice: Optional['ModelToolChoice'] = None
1414

1515

1616
# ModelOutput is the output for model span, for tag key: output

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "cozeloop"
3-
version = "0.1.16"
3+
version = "0.1.18"
44
description = "coze loop sdk"
55
authors = ["JiangQi715 <[email protected]>"]
66
license = "MIT"

0 commit comments

Comments
 (0)