Skip to content

Commit 9f4e1ee

Browse files
author
ChidcGithub
committed
Add Phase 5 features: streaming, tools, multi-provider support
- streaming.py: Stream support with sync/async iterators - tools.py: Function calling with @tool decorator - providers.py: OpenAI and Anthropic provider support - 35 new tests, 103 total tests passing
1 parent 71d8a3a commit 9f4e1ee

File tree

7 files changed

+2007
-1
lines changed

7 files changed

+2007
-1
lines changed

cognipy/__init__.py

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
- 反思循环:LLM 自我检查与修正
1010
- 异步调度:高性能并发调用
1111
- 确定性保证:类型约束、幻觉检测
12+
- 流式响应:实时输出支持
13+
- 工具调用:Function Calling 支持
14+
- 多提供商:OpenAI、Anthropic 等
1215
- 混合执行模型:确定性逻辑与模糊意图的无缝协同
1316
"""
1417

15-
__version__ = "0.1.0"
18+
__version__ = "0.2.0"
1619

1720
from .runtime import cognitive_call, CognitiveContext
1821
from .decorator import cognitive
@@ -56,6 +59,36 @@
5659
HallucinationCheck,
5760
deterministic_call
5861
)
62+
from .streaming import (
63+
StreamStatus,
64+
StreamChunk,
65+
StreamResult,
66+
stream_call,
67+
stream_call_async,
68+
stream_iter,
69+
stream_iter_async
70+
)
71+
from .tools import (
72+
ToolType,
73+
ToolParameter,
74+
ToolDefinition,
75+
ToolCall,
76+
ToolResult,
77+
ToolRegistry,
78+
tool,
79+
call_with_tools,
80+
register_tool,
81+
get_global_registry
82+
)
83+
from .providers import (
84+
ProviderType,
85+
ProviderConfig,
86+
BaseProvider,
87+
OpenAIProvider,
88+
AnthropicProvider,
89+
ProviderFactory,
90+
create_provider
91+
)
5992

6093
__all__ = [
6194
# Core
@@ -98,4 +131,31 @@
98131
"HallucinationDetector",
99132
"HallucinationCheck",
100133
"deterministic_call",
134+
# Streaming
135+
"StreamStatus",
136+
"StreamChunk",
137+
"StreamResult",
138+
"stream_call",
139+
"stream_call_async",
140+
"stream_iter",
141+
"stream_iter_async",
142+
# Tools
143+
"ToolType",
144+
"ToolParameter",
145+
"ToolDefinition",
146+
"ToolCall",
147+
"ToolResult",
148+
"ToolRegistry",
149+
"tool",
150+
"call_with_tools",
151+
"register_tool",
152+
"get_global_registry",
153+
# Providers
154+
"ProviderType",
155+
"ProviderConfig",
156+
"BaseProvider",
157+
"OpenAIProvider",
158+
"AnthropicProvider",
159+
"ProviderFactory",
160+
"create_provider",
101161
]

0 commit comments

Comments
 (0)