dotcode-sdk 0.1.0__py3-none-any.whl → 0.2.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.
- dotcode_sdk/__init__.py +46 -23
- dotcode_sdk/client.py +480 -308
- dotcode_sdk/events.py +312 -0
- dotcode_sdk/py.typed +0 -0
- dotcode_sdk/schema.py +232 -0
- dotcode_sdk/tools.py +136 -0
- dotcode_sdk/types.py +310 -70
- dotcode_sdk-0.2.0.dist-info/METADATA +87 -0
- dotcode_sdk-0.2.0.dist-info/RECORD +12 -0
- dotcode_sdk-0.1.0.dist-info/METADATA +0 -66
- dotcode_sdk-0.1.0.dist-info/RECORD +0 -8
- {dotcode_sdk-0.1.0.dist-info → dotcode_sdk-0.2.0.dist-info}/WHEEL +0 -0
- {dotcode_sdk-0.1.0.dist-info → dotcode_sdk-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {dotcode_sdk-0.1.0.dist-info → dotcode_sdk-0.2.0.dist-info}/top_level.txt +0 -0
dotcode_sdk/__init__.py
CHANGED
|
@@ -8,38 +8,61 @@ Built by Gravicode Studios, led by Kang Fadhil.
|
|
|
8
8
|
Example::
|
|
9
9
|
|
|
10
10
|
import asyncio
|
|
11
|
-
from
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from typing import Annotated
|
|
13
|
+
from dotcode_sdk import DotCodeClient, PermissionHandler, define_tool
|
|
14
|
+
from dotcode_sdk.events import AssistantTextDeltaEvent
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class WeatherParams:
|
|
18
|
+
city: Annotated[str, "City name"]
|
|
19
|
+
|
|
20
|
+
@define_tool(description="Weather for a city")
|
|
21
|
+
async def get_weather(params: WeatherParams) -> str:
|
|
22
|
+
return f"{params.city}: sunny"
|
|
12
23
|
|
|
13
24
|
async def main():
|
|
14
25
|
async with DotCodeClient() as client:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
async with await client.create_session(model="openai:gpt-5", tools=[get_weather],
|
|
27
|
+
on_permission_request=PermissionHandler.approve_all) as session:
|
|
28
|
+
session.on(AssistantTextDeltaEvent, lambda e: print(e.text, end=""))
|
|
29
|
+
result = await session.send_and_wait("Weather in Bogor?")
|
|
30
|
+
print(result.cost_usd)
|
|
18
31
|
|
|
19
32
|
asyncio.run(main())
|
|
20
33
|
"""
|
|
21
34
|
|
|
22
|
-
from .client import
|
|
35
|
+
from .client import PROTOCOL_VERSION, DotCodeClient, DotCodeError, DotCodeSession
|
|
36
|
+
from .events import (
|
|
37
|
+
AssistantMessageEvent, AssistantTextDeltaEvent, AssistantThinkingDeltaEvent, ContextCompactedEvent, ErrorEvent,
|
|
38
|
+
ModeChangedEvent, ModelChangedEvent, ModelFallbackEvent, NoticeEvent, RetryEvent, SessionEvent,
|
|
39
|
+
SubagentCompletedEvent, SubagentStartedEvent, TodoItem, TodoUpdatedEvent, ToolCompletedEvent, ToolProgressEvent,
|
|
40
|
+
ToolStartedEvent, TurnCompletedEvent, UnknownEvent, Usage, UsageUpdatedEvent, UserMessageEvent,
|
|
41
|
+
)
|
|
42
|
+
from .schema import ToolArgumentError, schema_for
|
|
43
|
+
from .tools import BinaryResult, Tool, ToolInvocation, ToolResult, define_tool
|
|
23
44
|
from .types import (
|
|
24
|
-
|
|
25
|
-
PermissionDecision,
|
|
26
|
-
|
|
27
|
-
SendResult,
|
|
28
|
-
|
|
29
|
-
UserQuestion,
|
|
45
|
+
Attachment, BuiltinTool, ExitPlanModeRequest, ExitPlanModeResult, FileAttachment, ImageAttachment, Invocation,
|
|
46
|
+
McpHttpServer, McpStdioServer, ModelInfo, PermissionDecision, PermissionDecisionApproveAlways,
|
|
47
|
+
PermissionDecisionApproveForSession, PermissionDecisionApproveOnce, PermissionDecisionReject, PermissionHandler,
|
|
48
|
+
PermissionMode, PermissionRequest, ProviderConfig, QuestionOption, ReasoningEffort, SendResult, SessionMetadata,
|
|
49
|
+
SystemMessageConfig, ToolInfo, UserInputRequest, UserQuestion, UserQuestionAnswer,
|
|
30
50
|
)
|
|
31
51
|
|
|
32
52
|
__all__ = [
|
|
33
|
-
"DotCodeClient",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"SendResult",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
53
|
+
"PROTOCOL_VERSION", "DotCodeClient", "DotCodeError", "DotCodeSession",
|
|
54
|
+
"define_tool", "Tool", "ToolInvocation", "ToolResult", "BinaryResult", "ToolArgumentError", "schema_for",
|
|
55
|
+
"PermissionHandler", "PermissionRequest", "PermissionDecision", "PermissionDecisionApproveOnce",
|
|
56
|
+
"PermissionDecisionApproveForSession", "PermissionDecisionApproveAlways", "PermissionDecisionReject",
|
|
57
|
+
"UserInputRequest", "UserQuestion", "QuestionOption", "UserQuestionAnswer", "ExitPlanModeRequest",
|
|
58
|
+
"ExitPlanModeResult", "Invocation",
|
|
59
|
+
"BuiltinTool", "PermissionMode", "ReasoningEffort", "ProviderConfig", "McpStdioServer", "McpHttpServer",
|
|
60
|
+
"SystemMessageConfig", "Attachment", "FileAttachment", "ImageAttachment",
|
|
61
|
+
"SendResult", "SessionMetadata", "ModelInfo", "ToolInfo", "Usage", "TodoItem",
|
|
62
|
+
"SessionEvent", "UserMessageEvent", "AssistantTextDeltaEvent", "AssistantThinkingDeltaEvent",
|
|
63
|
+
"AssistantMessageEvent", "ToolStartedEvent", "ToolProgressEvent", "ToolCompletedEvent", "TodoUpdatedEvent",
|
|
64
|
+
"SubagentStartedEvent", "SubagentCompletedEvent", "ContextCompactedEvent", "UsageUpdatedEvent",
|
|
65
|
+
"ModelChangedEvent", "ModelFallbackEvent", "RetryEvent", "NoticeEvent", "ErrorEvent", "ModeChangedEvent",
|
|
66
|
+
"TurnCompletedEvent", "UnknownEvent",
|
|
44
67
|
]
|
|
45
|
-
__version__ = "0.
|
|
68
|
+
__version__ = "0.2.0"
|