pi-ai-python 1.3.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.
- pi_agent/__init__.py +127 -0
- pi_agent/agent.py +617 -0
- pi_agent/agent_loop.py +820 -0
- pi_agent/proxy.py +269 -0
- pi_agent/py.typed +0 -0
- pi_agent/stream_fn.py +27 -0
- pi_agent/tools.py +327 -0
- pi_agent/types.py +394 -0
- pi_ai/__init__.py +263 -0
- pi_ai/abort.py +315 -0
- pi_ai/api/__init__.py +1 -0
- pi_ai/api/anthropic_messages.py +1782 -0
- pi_ai/api/azure_openai_config.py +138 -0
- pi_ai/api/azure_openai_responses.py +245 -0
- pi_ai/api/bedrock_converse_stream.py +1598 -0
- pi_ai/api/classifier_shared.py +211 -0
- pi_ai/api/cloudflare.py +36 -0
- pi_ai/api/cloudflare_workers_ai_system_one.py +80 -0
- pi_ai/api/constrained_sampling.py +279 -0
- pi_ai/api/github_copilot_headers.py +30 -0
- pi_ai/api/google_generative_ai.py +138 -0
- pi_ai/api/google_shared.py +927 -0
- pi_ai/api/google_vertex.py +234 -0
- pi_ai/api/lazy.py +156 -0
- pi_ai/api/llama_cpp_classify.py +449 -0
- pi_ai/api/mistral_conversations.py +756 -0
- pi_ai/api/openai_codex_responses.py +1545 -0
- pi_ai/api/openai_completions.py +1594 -0
- pi_ai/api/openai_decisions.py +210 -0
- pi_ai/api/openai_prompt_cache.py +19 -0
- pi_ai/api/openai_responses.py +418 -0
- pi_ai/api/openai_responses_shared.py +840 -0
- pi_ai/api/openai_sdk.py +204 -0
- pi_ai/api/openrouter_images.py +153 -0
- pi_ai/api/pi_messages.py +449 -0
- pi_ai/api/registry.py +103 -0
- pi_ai/api/simple_options.py +119 -0
- pi_ai/api/system_one_shared.py +148 -0
- pi_ai/api/transform_messages.py +211 -0
- pi_ai/api/typesafe_system_one.py +43 -0
- pi_ai/auth/__init__.py +1 -0
- pi_ai/auth/context.py +47 -0
- pi_ai/auth/credential_store.py +208 -0
- pi_ai/auth/helpers.py +123 -0
- pi_ai/auth/oauth/__init__.py +5 -0
- pi_ai/auth/oauth/_common.py +454 -0
- pi_ai/auth/oauth/anthropic.py +283 -0
- pi_ai/auth/oauth/callback_server.py +339 -0
- pi_ai/auth/oauth/device_code.py +127 -0
- pi_ai/auth/oauth/github_copilot.py +508 -0
- pi_ai/auth/oauth/kimi_coding.py +283 -0
- pi_ai/auth/oauth/load.py +64 -0
- pi_ai/auth/oauth/meta.py +238 -0
- pi_ai/auth/oauth/openai_chatgpt.py +321 -0
- pi_ai/auth/oauth/openai_codex.py +391 -0
- pi_ai/auth/oauth/openrouter.py +173 -0
- pi_ai/auth/oauth/pkce.py +23 -0
- pi_ai/auth/oauth/radius.py +311 -0
- pi_ai/auth/oauth/xai.py +220 -0
- pi_ai/auth/resolve.py +190 -0
- pi_ai/auth/types.py +292 -0
- pi_ai/cli.py +265 -0
- pi_ai/compat.py +651 -0
- pi_ai/env_api_keys.py +137 -0
- pi_ai/event_stream.py +329 -0
- pi_ai/models.py +1191 -0
- pi_ai/models_store.py +121 -0
- pi_ai/oauth.py +90 -0
- pi_ai/providers/__init__.py +1 -0
- pi_ai/providers/all.py +154 -0
- pi_ai/providers/amazon_bedrock.py +116 -0
- pi_ai/providers/ant_ling.py +23 -0
- pi_ai/providers/anthropic.py +105 -0
- pi_ai/providers/azure.py +103 -0
- pi_ai/providers/baseten.py +23 -0
- pi_ai/providers/catalog.py +167 -0
- pi_ai/providers/cerebras.py +23 -0
- pi_ai/providers/cloudflare_ai_gateway.py +30 -0
- pi_ai/providers/cloudflare_auth.py +112 -0
- pi_ai/providers/cloudflare_stream.py +84 -0
- pi_ai/providers/cloudflare_workers_ai.py +26 -0
- pi_ai/providers/data/amazon-bedrock.json +1 -0
- pi_ai/providers/data/ant-ling.json +1 -0
- pi_ai/providers/data/anthropic.json +1 -0
- pi_ai/providers/data/azure.json +1 -0
- pi_ai/providers/data/baseten.json +1 -0
- pi_ai/providers/data/cerebras.json +1 -0
- pi_ai/providers/data/cloudflare-ai-gateway.json +1 -0
- pi_ai/providers/data/cloudflare-workers-ai.json +1 -0
- pi_ai/providers/data/deepseek.json +1 -0
- pi_ai/providers/data/fireworks.json +1 -0
- pi_ai/providers/data/github-copilot.json +1 -0
- pi_ai/providers/data/google-vertex.json +1 -0
- pi_ai/providers/data/google.json +1 -0
- pi_ai/providers/data/groq.json +1 -0
- pi_ai/providers/data/huggingface.json +1 -0
- pi_ai/providers/data/kimi-coding.json +1 -0
- pi_ai/providers/data/manifest.json +1 -0
- pi_ai/providers/data/meta.json +1 -0
- pi_ai/providers/data/minimax-cn.json +1 -0
- pi_ai/providers/data/minimax.json +1 -0
- pi_ai/providers/data/mistral.json +1 -0
- pi_ai/providers/data/moonshotai-cn.json +1 -0
- pi_ai/providers/data/moonshotai.json +1 -0
- pi_ai/providers/data/nvidia.json +1 -0
- pi_ai/providers/data/openai-codex.json +1 -0
- pi_ai/providers/data/openai.json +1 -0
- pi_ai/providers/data/opencode-go.json +1 -0
- pi_ai/providers/data/opencode.json +1 -0
- pi_ai/providers/data/openrouter.json +1 -0
- pi_ai/providers/data/qwen-token-plan-cn.json +1 -0
- pi_ai/providers/data/qwen-token-plan-individual.json +1 -0
- pi_ai/providers/data/qwen-token-plan.json +1 -0
- pi_ai/providers/data/radius.json +1 -0
- pi_ai/providers/data/together.json +1 -0
- pi_ai/providers/data/typesafe.json +1 -0
- pi_ai/providers/data/vercel-ai-gateway.json +1 -0
- pi_ai/providers/data/xai.json +1 -0
- pi_ai/providers/data/xiaomi-token-plan-ams.json +1 -0
- pi_ai/providers/data/xiaomi-token-plan-cn.json +1 -0
- pi_ai/providers/data/xiaomi-token-plan-sgp.json +1 -0
- pi_ai/providers/data/xiaomi.json +1 -0
- pi_ai/providers/data/zai-coding-cn.json +1 -0
- pi_ai/providers/data/zai.json +1 -0
- pi_ai/providers/deepseek.py +23 -0
- pi_ai/providers/faux.py +680 -0
- pi_ai/providers/fireworks.py +26 -0
- pi_ai/providers/github_copilot.py +46 -0
- pi_ai/providers/google.py +23 -0
- pi_ai/providers/google_vertex.py +131 -0
- pi_ai/providers/groq.py +23 -0
- pi_ai/providers/huggingface.py +23 -0
- pi_ai/providers/kimi_coding.py +32 -0
- pi_ai/providers/meta.py +32 -0
- pi_ai/providers/minimax.py +23 -0
- pi_ai/providers/minimax_cn.py +23 -0
- pi_ai/providers/mistral.py +23 -0
- pi_ai/providers/moonshotai.py +23 -0
- pi_ai/providers/moonshotai_cn.py +23 -0
- pi_ai/providers/nvidia.py +23 -0
- pi_ai/providers/openai.py +44 -0
- pi_ai/providers/openai_codex.py +26 -0
- pi_ai/providers/opencode.py +36 -0
- pi_ai/providers/opencode_go.py +33 -0
- pi_ai/providers/opencode_headers.py +60 -0
- pi_ai/providers/openrouter.py +145 -0
- pi_ai/providers/openrouter_api.py +122 -0
- pi_ai/providers/qwen_token_plan.py +23 -0
- pi_ai/providers/qwen_token_plan_cn.py +23 -0
- pi_ai/providers/qwen_token_plan_individual.py +23 -0
- pi_ai/providers/radius.py +146 -0
- pi_ai/providers/radius_config.py +136 -0
- pi_ai/providers/together.py +23 -0
- pi_ai/providers/typesafe.py +22 -0
- pi_ai/providers/vercel_ai_gateway.py +25 -0
- pi_ai/providers/xai.py +32 -0
- pi_ai/providers/xiaomi.py +23 -0
- pi_ai/providers/xiaomi_token_plan_ams.py +23 -0
- pi_ai/providers/xiaomi_token_plan_cn.py +23 -0
- pi_ai/providers/xiaomi_token_plan_sgp.py +23 -0
- pi_ai/providers/zai.py +23 -0
- pi_ai/providers/zai_coding_cn.py +23 -0
- pi_ai/py.typed +0 -0
- pi_ai/serialization.py +477 -0
- pi_ai/session_resources.py +33 -0
- pi_ai/types.py +1003 -0
- pi_ai/utils/__init__.py +1 -0
- pi_ai/utils/callbacks.py +15 -0
- pi_ai/utils/diagnostics.py +70 -0
- pi_ai/utils/error_body.py +89 -0
- pi_ai/utils/estimate.py +125 -0
- pi_ai/utils/fastjson.py +63 -0
- pi_ai/utils/http.py +409 -0
- pi_ai/utils/json_parse.py +424 -0
- pi_ai/utils/misc.py +193 -0
- pi_ai/utils/model_operations.py +73 -0
- pi_ai/utils/models_error.py +35 -0
- pi_ai/utils/oauth_page.py +121 -0
- pi_ai/utils/overflow.py +87 -0
- pi_ai/utils/retry.py +193 -0
- pi_ai/utils/schema.py +283 -0
- pi_ai/utils/text.py +65 -0
- pi_ai/utils/transcript.py +271 -0
- pi_ai/utils/validation.py +813 -0
- pi_ai_python-1.3.0.dist-info/METADATA +167 -0
- pi_ai_python-1.3.0.dist-info/RECORD +189 -0
- pi_ai_python-1.3.0.dist-info/WHEEL +4 -0
- pi_ai_python-1.3.0.dist-info/entry_points.txt +2 -0
- pi_ai_python-1.3.0.dist-info/licenses/LICENSE +22 -0
pi_agent/__init__.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"""pi_agent: stateful agent with tool execution, steering/follow-up queues and
|
|
2
|
+
event streaming, built on pi_ai.
|
|
3
|
+
|
|
4
|
+
Python port of ``@earendil-works/pi-agent-core``.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from .agent import Agent, AgentInitialState, AgentListener, AgentState, default_convert_to_llm
|
|
10
|
+
from .agent_loop import (
|
|
11
|
+
AgentEventSink,
|
|
12
|
+
RunToolCallOptions,
|
|
13
|
+
ToolCallHooks,
|
|
14
|
+
agent_loop,
|
|
15
|
+
agent_loop_continue,
|
|
16
|
+
run_agent_loop,
|
|
17
|
+
run_agent_loop_continue,
|
|
18
|
+
run_tool_call,
|
|
19
|
+
)
|
|
20
|
+
from .proxy import ProxyStreamOptions, process_proxy_event, stream_proxy
|
|
21
|
+
from .stream_fn import get_default_stream_fn, set_default_stream_fn
|
|
22
|
+
from .tools import agent_tool, schema_from_type, tool_from_function
|
|
23
|
+
from .types import (
|
|
24
|
+
AfterToolCallContext,
|
|
25
|
+
AfterToolCallResult,
|
|
26
|
+
AgentContext,
|
|
27
|
+
AgentEndEvent,
|
|
28
|
+
AgentEvent,
|
|
29
|
+
AgentLoopConfig,
|
|
30
|
+
AgentLoopTurnUpdate,
|
|
31
|
+
AgentMessage,
|
|
32
|
+
AgentRequestUpdate,
|
|
33
|
+
AgentStartEvent,
|
|
34
|
+
AgentTool,
|
|
35
|
+
AgentToolCall,
|
|
36
|
+
AgentToolCallOutcome,
|
|
37
|
+
AgentToolResult,
|
|
38
|
+
AgentToolUpdateCallback,
|
|
39
|
+
AgentTurnContext,
|
|
40
|
+
AgentTurnDecision,
|
|
41
|
+
BeforeToolCallContext,
|
|
42
|
+
BeforeToolCallResult,
|
|
43
|
+
FinishTurn,
|
|
44
|
+
MessageEndEvent,
|
|
45
|
+
MessageStartEvent,
|
|
46
|
+
MessageUpdateEvent,
|
|
47
|
+
PrepareNextTurnContext,
|
|
48
|
+
PrepareRequest,
|
|
49
|
+
PrepareRequestContext,
|
|
50
|
+
QueueMode,
|
|
51
|
+
StreamFn,
|
|
52
|
+
ThinkingLevel,
|
|
53
|
+
ToolExecutionEndEvent,
|
|
54
|
+
ToolExecutionMode,
|
|
55
|
+
ToolExecutionStartEvent,
|
|
56
|
+
ToolExecutionUpdateEvent,
|
|
57
|
+
TurnEndEvent,
|
|
58
|
+
TurnStartEvent,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
__version__ = "1.3.0"
|
|
62
|
+
|
|
63
|
+
__all__ = [
|
|
64
|
+
"__version__",
|
|
65
|
+
# agent
|
|
66
|
+
"Agent",
|
|
67
|
+
"AgentState",
|
|
68
|
+
"AgentInitialState",
|
|
69
|
+
"AgentListener",
|
|
70
|
+
"default_convert_to_llm",
|
|
71
|
+
# loop
|
|
72
|
+
"agent_loop",
|
|
73
|
+
"agent_loop_continue",
|
|
74
|
+
"run_agent_loop",
|
|
75
|
+
"run_agent_loop_continue",
|
|
76
|
+
"run_tool_call",
|
|
77
|
+
"RunToolCallOptions",
|
|
78
|
+
"ToolCallHooks",
|
|
79
|
+
"AgentEventSink",
|
|
80
|
+
# stream function
|
|
81
|
+
"set_default_stream_fn",
|
|
82
|
+
"get_default_stream_fn",
|
|
83
|
+
"stream_proxy",
|
|
84
|
+
"process_proxy_event",
|
|
85
|
+
"ProxyStreamOptions",
|
|
86
|
+
# tools
|
|
87
|
+
"agent_tool",
|
|
88
|
+
"tool_from_function",
|
|
89
|
+
"schema_from_type",
|
|
90
|
+
# types
|
|
91
|
+
"AfterToolCallContext",
|
|
92
|
+
"AfterToolCallResult",
|
|
93
|
+
"AgentContext",
|
|
94
|
+
"AgentLoopConfig",
|
|
95
|
+
"AgentLoopTurnUpdate",
|
|
96
|
+
"AgentMessage",
|
|
97
|
+
"AgentRequestUpdate",
|
|
98
|
+
"AgentTool",
|
|
99
|
+
"AgentToolCall",
|
|
100
|
+
"AgentToolCallOutcome",
|
|
101
|
+
"AgentToolResult",
|
|
102
|
+
"AgentToolUpdateCallback",
|
|
103
|
+
"AgentTurnContext",
|
|
104
|
+
"AgentTurnDecision",
|
|
105
|
+
"BeforeToolCallContext",
|
|
106
|
+
"BeforeToolCallResult",
|
|
107
|
+
"FinishTurn",
|
|
108
|
+
"PrepareNextTurnContext",
|
|
109
|
+
"PrepareRequest",
|
|
110
|
+
"PrepareRequestContext",
|
|
111
|
+
"QueueMode",
|
|
112
|
+
"StreamFn",
|
|
113
|
+
"ThinkingLevel",
|
|
114
|
+
"ToolExecutionMode",
|
|
115
|
+
# events
|
|
116
|
+
"AgentEvent",
|
|
117
|
+
"AgentStartEvent",
|
|
118
|
+
"AgentEndEvent",
|
|
119
|
+
"TurnStartEvent",
|
|
120
|
+
"TurnEndEvent",
|
|
121
|
+
"MessageStartEvent",
|
|
122
|
+
"MessageUpdateEvent",
|
|
123
|
+
"MessageEndEvent",
|
|
124
|
+
"ToolExecutionStartEvent",
|
|
125
|
+
"ToolExecutionUpdateEvent",
|
|
126
|
+
"ToolExecutionEndEvent",
|
|
127
|
+
]
|