windlass 0.1.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.
- windlass/__init__.py +243 -0
- windlass/_version.py +7 -0
- windlass/agent/__init__.py +44 -0
- windlass/agent/builder.py +709 -0
- windlass/agent/checkpoint.py +330 -0
- windlass/agent/graph.py +410 -0
- windlass/agent/runtime.py +633 -0
- windlass/agent/supervisor.py +373 -0
- windlass/api.py +469 -0
- windlass/cli.py +389 -0
- windlass/core/__init__.py +145 -0
- windlass/core/cache.py +336 -0
- windlass/core/concurrency.py +341 -0
- windlass/core/config.py +461 -0
- windlass/core/container.py +383 -0
- windlass/core/exceptions.py +465 -0
- windlass/core/lazy.py +208 -0
- windlass/core/logging.py +204 -0
- windlass/core/registry.py +626 -0
- windlass/core/retry.py +288 -0
- windlass/core/text.py +505 -0
- windlass/core/types.py +671 -0
- windlass/core/vectors.py +306 -0
- windlass/interfaces/__init__.py +81 -0
- windlass/interfaces/base.py +191 -0
- windlass/interfaces/chunker.py +279 -0
- windlass/interfaces/embedding.py +259 -0
- windlass/interfaces/evaluator.py +264 -0
- windlass/interfaces/guardrail.py +289 -0
- windlass/interfaces/llm.py +410 -0
- windlass/interfaces/loader.py +349 -0
- windlass/interfaces/mcp.py +312 -0
- windlass/interfaces/memory.py +178 -0
- windlass/interfaces/preprocessor.py +195 -0
- windlass/interfaces/retriever.py +245 -0
- windlass/interfaces/tool.py +339 -0
- windlass/interfaces/tracer.py +366 -0
- windlass/interfaces/vectordb.py +340 -0
- windlass/providers/__init__.py +642 -0
- windlass/providers/chunkers/__init__.py +7 -0
- windlass/providers/chunkers/hierarchical.py +254 -0
- windlass/providers/chunkers/recursive.py +260 -0
- windlass/providers/chunkers/semantic.py +204 -0
- windlass/providers/chunkers/structural.py +323 -0
- windlass/providers/embeddings/__init__.py +7 -0
- windlass/providers/embeddings/hash.py +127 -0
- windlass/providers/embeddings/hf_inference.py +284 -0
- windlass/providers/embeddings/huggingface.py +187 -0
- windlass/providers/embeddings/openai.py +126 -0
- windlass/providers/evaluation/__init__.py +7 -0
- windlass/providers/evaluation/builtin.py +428 -0
- windlass/providers/evaluation/external.py +356 -0
- windlass/providers/guardrails/__init__.py +7 -0
- windlass/providers/guardrails/nemo.py +241 -0
- windlass/providers/guardrails/rules.py +241 -0
- windlass/providers/llm/__init__.py +9 -0
- windlass/providers/llm/anthropic.py +355 -0
- windlass/providers/llm/fake.py +271 -0
- windlass/providers/llm/gemini.py +291 -0
- windlass/providers/llm/groq.py +361 -0
- windlass/providers/llm/ollama.py +313 -0
- windlass/providers/llm/openai.py +424 -0
- windlass/providers/loaders/__init__.py +7 -0
- windlass/providers/loaders/media.py +296 -0
- windlass/providers/loaders/office.py +511 -0
- windlass/providers/loaders/text.py +507 -0
- windlass/providers/loaders/web.py +452 -0
- windlass/providers/mcp/__init__.py +7 -0
- windlass/providers/mcp/fastmcp.py +635 -0
- windlass/providers/memory/__init__.py +7 -0
- windlass/providers/memory/conversation.py +322 -0
- windlass/providers/memory/longterm.py +304 -0
- windlass/providers/observability/__init__.py +7 -0
- windlass/providers/observability/console.py +259 -0
- windlass/providers/observability/multi.py +160 -0
- windlass/providers/observability/platforms.py +424 -0
- windlass/providers/preprocessors/__init__.py +7 -0
- windlass/providers/preprocessors/clean.py +306 -0
- windlass/providers/preprocessors/dedup.py +321 -0
- windlass/providers/preprocessors/enrich.py +303 -0
- windlass/providers/preprocessors/privacy.py +307 -0
- windlass/providers/retrievers/__init__.py +7 -0
- windlass/providers/retrievers/bm25.py +365 -0
- windlass/providers/retrievers/contextual.py +326 -0
- windlass/providers/retrievers/hybrid.py +255 -0
- windlass/providers/retrievers/vector.py +247 -0
- windlass/providers/vectordb/__init__.py +7 -0
- windlass/providers/vectordb/chroma.py +382 -0
- windlass/providers/vectordb/faiss.py +445 -0
- windlass/providers/vectordb/memory.py +361 -0
- windlass/providers/vectordb/pinecone.py +442 -0
- windlass/py.typed +1 -0
- windlass/rag/__init__.py +34 -0
- windlass/rag/builder.py +739 -0
- windlass/rag/loading.py +250 -0
- windlass/rag/pipeline.py +854 -0
- windlass/testing.py +376 -0
- windlass/tools/__init__.py +458 -0
- windlass/tools/schema.py +417 -0
- windlass-0.1.0.dist-info/METADATA +679 -0
- windlass-0.1.0.dist-info/RECORD +104 -0
- windlass-0.1.0.dist-info/WHEEL +4 -0
- windlass-0.1.0.dist-info/entry_points.txt +2 -0
- windlass-0.1.0.dist-info/licenses/LICENSE +205 -0
windlass/__init__.py
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"""Windlass — the modular AI application framework.
|
|
2
|
+
|
|
3
|
+
One elegant API for agents, RAG, tools, MCP, guardrails, evaluation and
|
|
4
|
+
observability. Windlass is not a wrapper around other libraries; it is an
|
|
5
|
+
architecture that lets them be swapped, extended and replaced without rewriting
|
|
6
|
+
your application.
|
|
7
|
+
|
|
8
|
+
Quick start::
|
|
9
|
+
|
|
10
|
+
from windlass import Windlass
|
|
11
|
+
|
|
12
|
+
rag = Windlass.rag()
|
|
13
|
+
rag.ingest("./documents")
|
|
14
|
+
print(rag.ask("What changed in the API last quarter?"))
|
|
15
|
+
|
|
16
|
+
agent = Windlass.agent().llm("openai").tool(my_function).memory()
|
|
17
|
+
print(agent.run("Summarise my open tickets"))
|
|
18
|
+
|
|
19
|
+
Three levels of API, always:
|
|
20
|
+
|
|
21
|
+
1. **Simple** — ``rag.ask("...")`` works with sensible defaults.
|
|
22
|
+
2. **Configured** — ``rag.chunker("semantic", chunk_size=1000, overlap=200)``.
|
|
23
|
+
3. **Native** — ``rag.native_store()``, ``agent.native_graph()``. Windlass
|
|
24
|
+
simplifies libraries; it never hides them.
|
|
25
|
+
|
|
26
|
+
Importing this module is cheap and pulls in no optional dependency. Providers are
|
|
27
|
+
registered by dotted path and imported only when you actually use them.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
from __future__ import annotations
|
|
31
|
+
|
|
32
|
+
from typing import TYPE_CHECKING, Any
|
|
33
|
+
|
|
34
|
+
from windlass._version import __version__
|
|
35
|
+
from windlass.api import Windlass
|
|
36
|
+
from windlass.core.config import WindlassSettings, configure, reset_settings, settings
|
|
37
|
+
from windlass.core.container import Container, root_container
|
|
38
|
+
from windlass.core.exceptions import (
|
|
39
|
+
AgentError,
|
|
40
|
+
AuthenticationError,
|
|
41
|
+
ComponentNotFoundError,
|
|
42
|
+
ConfigurationError,
|
|
43
|
+
DuplicateComponentError,
|
|
44
|
+
EvaluationError,
|
|
45
|
+
GuardrailViolation,
|
|
46
|
+
IngestionError,
|
|
47
|
+
MaxIterationsExceeded,
|
|
48
|
+
MCPError,
|
|
49
|
+
MissingDependencyError,
|
|
50
|
+
PipelineError,
|
|
51
|
+
PluginError,
|
|
52
|
+
ProviderError,
|
|
53
|
+
ProviderTimeoutError,
|
|
54
|
+
RateLimitError,
|
|
55
|
+
RegistryError,
|
|
56
|
+
ResponseError,
|
|
57
|
+
RetrievalError,
|
|
58
|
+
SerializationError,
|
|
59
|
+
ToolError,
|
|
60
|
+
ToolExecutionError,
|
|
61
|
+
ToolNotFoundError,
|
|
62
|
+
ValidationError,
|
|
63
|
+
WindlassError,
|
|
64
|
+
)
|
|
65
|
+
from windlass.core.exceptions import InterruptedError_ as AgentInterrupt
|
|
66
|
+
from windlass.core.exceptions import MemoryError_ as WindlassMemoryError
|
|
67
|
+
from windlass.core.logging import configure_logging, get_logger
|
|
68
|
+
from windlass.core.registry import REGISTRY, ComponentSpec, Registry, available, create, register
|
|
69
|
+
from windlass.core.types import (
|
|
70
|
+
AgentResponse,
|
|
71
|
+
AgentStep,
|
|
72
|
+
Chunk,
|
|
73
|
+
Completion,
|
|
74
|
+
Document,
|
|
75
|
+
Embedding,
|
|
76
|
+
EvaluationReport,
|
|
77
|
+
EvaluationResult,
|
|
78
|
+
FinishReason,
|
|
79
|
+
GuardrailResult,
|
|
80
|
+
Message,
|
|
81
|
+
RAGAnswer,
|
|
82
|
+
Role,
|
|
83
|
+
ScoredChunk,
|
|
84
|
+
SearchResult,
|
|
85
|
+
StreamEvent,
|
|
86
|
+
ToolCall,
|
|
87
|
+
ToolResult,
|
|
88
|
+
Usage,
|
|
89
|
+
)
|
|
90
|
+
from windlass.interfaces import (
|
|
91
|
+
LLM,
|
|
92
|
+
Chunker,
|
|
93
|
+
Component,
|
|
94
|
+
Embedder,
|
|
95
|
+
EvalSample,
|
|
96
|
+
Evaluator,
|
|
97
|
+
Guardrail,
|
|
98
|
+
Loader,
|
|
99
|
+
MCPClient,
|
|
100
|
+
Memory,
|
|
101
|
+
Preprocessor,
|
|
102
|
+
Retriever,
|
|
103
|
+
Span,
|
|
104
|
+
Tool,
|
|
105
|
+
Tracer,
|
|
106
|
+
VectorStore,
|
|
107
|
+
)
|
|
108
|
+
from windlass.providers import register_builtins
|
|
109
|
+
from windlass.tools import FunctionTool, ToolRegistry, tool
|
|
110
|
+
|
|
111
|
+
if TYPE_CHECKING: # pragma: no cover - import-time cost avoided at runtime
|
|
112
|
+
from windlass.agent import AgentBuilder, AgentRuntime, Supervisor
|
|
113
|
+
from windlass.rag import RAGBuilder, RAGPipeline
|
|
114
|
+
|
|
115
|
+
# Register every built-in component by dotted path. No provider module is
|
|
116
|
+
# imported here — that happens on first use.
|
|
117
|
+
register_builtins()
|
|
118
|
+
|
|
119
|
+
__all__ = [
|
|
120
|
+
"LLM",
|
|
121
|
+
"REGISTRY",
|
|
122
|
+
"AgentBuilder",
|
|
123
|
+
"AgentError",
|
|
124
|
+
"AgentInterrupt",
|
|
125
|
+
"AgentResponse",
|
|
126
|
+
"AgentRuntime",
|
|
127
|
+
"AgentStep",
|
|
128
|
+
"AuthenticationError",
|
|
129
|
+
"Chunk",
|
|
130
|
+
"Chunker",
|
|
131
|
+
"Completion",
|
|
132
|
+
"Component",
|
|
133
|
+
"ComponentNotFoundError",
|
|
134
|
+
"ComponentSpec",
|
|
135
|
+
"ConfigurationError",
|
|
136
|
+
"Container",
|
|
137
|
+
"Document",
|
|
138
|
+
"DuplicateComponentError",
|
|
139
|
+
"Embedder",
|
|
140
|
+
"Embedding",
|
|
141
|
+
"EvalSample",
|
|
142
|
+
"EvaluationError",
|
|
143
|
+
"EvaluationReport",
|
|
144
|
+
"EvaluationResult",
|
|
145
|
+
"Evaluator",
|
|
146
|
+
"FinishReason",
|
|
147
|
+
"FunctionTool",
|
|
148
|
+
"Guardrail",
|
|
149
|
+
"GuardrailResult",
|
|
150
|
+
"GuardrailViolation",
|
|
151
|
+
"IngestionError",
|
|
152
|
+
"Loader",
|
|
153
|
+
"MCPClient",
|
|
154
|
+
"MCPError",
|
|
155
|
+
"MaxIterationsExceeded",
|
|
156
|
+
"Memory",
|
|
157
|
+
"Message",
|
|
158
|
+
"MissingDependencyError",
|
|
159
|
+
"PipelineError",
|
|
160
|
+
"PluginError",
|
|
161
|
+
"Preprocessor",
|
|
162
|
+
"ProviderError",
|
|
163
|
+
"ProviderTimeoutError",
|
|
164
|
+
"RAGAnswer",
|
|
165
|
+
"RAGBuilder",
|
|
166
|
+
"RAGPipeline",
|
|
167
|
+
"RateLimitError",
|
|
168
|
+
"Registry",
|
|
169
|
+
"RegistryError",
|
|
170
|
+
"ResponseError",
|
|
171
|
+
"RetrievalError",
|
|
172
|
+
"Retriever",
|
|
173
|
+
"Role",
|
|
174
|
+
"ScoredChunk",
|
|
175
|
+
"SearchResult",
|
|
176
|
+
"SerializationError",
|
|
177
|
+
"Span",
|
|
178
|
+
"StreamEvent",
|
|
179
|
+
"Supervisor",
|
|
180
|
+
"Tool",
|
|
181
|
+
"ToolCall",
|
|
182
|
+
"ToolError",
|
|
183
|
+
"ToolExecutionError",
|
|
184
|
+
"ToolNotFoundError",
|
|
185
|
+
"ToolRegistry",
|
|
186
|
+
"ToolResult",
|
|
187
|
+
"Tracer",
|
|
188
|
+
"Usage",
|
|
189
|
+
"ValidationError",
|
|
190
|
+
"VectorStore",
|
|
191
|
+
"Windlass",
|
|
192
|
+
"WindlassError",
|
|
193
|
+
"WindlassMemoryError",
|
|
194
|
+
"WindlassSettings",
|
|
195
|
+
"__version__",
|
|
196
|
+
"available",
|
|
197
|
+
"configure",
|
|
198
|
+
"configure_logging",
|
|
199
|
+
"create",
|
|
200
|
+
"get_logger",
|
|
201
|
+
"register",
|
|
202
|
+
"reset_settings",
|
|
203
|
+
"root_container",
|
|
204
|
+
"settings",
|
|
205
|
+
"tool",
|
|
206
|
+
]
|
|
207
|
+
|
|
208
|
+
#: Builder classes exported lazily, so ``import windlass`` never pays for the
|
|
209
|
+
#: agent or RAG subpackages until something actually touches them.
|
|
210
|
+
_LAZY: dict[str, tuple[str, str]] = {
|
|
211
|
+
"AgentBuilder": ("windlass.agent.builder", "AgentBuilder"),
|
|
212
|
+
"AgentRuntime": ("windlass.agent.runtime", "AgentRuntime"),
|
|
213
|
+
"Supervisor": ("windlass.agent.supervisor", "Supervisor"),
|
|
214
|
+
"RAGBuilder": ("windlass.rag.builder", "RAGBuilder"),
|
|
215
|
+
"RAGPipeline": ("windlass.rag.pipeline", "RAGPipeline"),
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def __getattr__(name: str) -> Any:
|
|
220
|
+
"""Resolve lazily exported names on first access.
|
|
221
|
+
|
|
222
|
+
Args:
|
|
223
|
+
name: The attribute being looked up.
|
|
224
|
+
|
|
225
|
+
Returns:
|
|
226
|
+
The resolved object.
|
|
227
|
+
|
|
228
|
+
Raises:
|
|
229
|
+
AttributeError: When the name is not exported by this package.
|
|
230
|
+
"""
|
|
231
|
+
target = _LAZY.get(name)
|
|
232
|
+
if target is None:
|
|
233
|
+
raise AttributeError(f"module 'windlass' has no attribute {name!r}")
|
|
234
|
+
import importlib
|
|
235
|
+
|
|
236
|
+
module, attribute = target
|
|
237
|
+
resolved = getattr(importlib.import_module(module), attribute)
|
|
238
|
+
globals()[name] = resolved
|
|
239
|
+
return resolved
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def __dir__() -> list[str]: # pragma: no cover - REPL nicety
|
|
243
|
+
return sorted(__all__)
|
windlass/_version.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Agents — models that use tools to accomplish goals.
|
|
2
|
+
|
|
3
|
+
Start with :func:`windlass.Windlass.agent`, which returns an
|
|
4
|
+
:class:`~windlass.agent.builder.AgentBuilder`::
|
|
5
|
+
|
|
6
|
+
from windlass import Windlass, tool
|
|
7
|
+
|
|
8
|
+
@tool
|
|
9
|
+
def search(query: str) -> list[str]:
|
|
10
|
+
'''Search the knowledge base.'''
|
|
11
|
+
return kb.search(query)
|
|
12
|
+
|
|
13
|
+
agent = Windlass.agent().llm("openai").tool(search).memory()
|
|
14
|
+
print(agent.run("What changed in the API last quarter?"))
|
|
15
|
+
|
|
16
|
+
The pieces:
|
|
17
|
+
|
|
18
|
+
* :class:`~windlass.agent.builder.AgentBuilder` — the fluent API.
|
|
19
|
+
* :class:`~windlass.agent.runtime.AgentRuntime` — the built-in reason/act loop,
|
|
20
|
+
with no dependencies.
|
|
21
|
+
* :class:`~windlass.agent.graph.LangGraphRuntime` — LangGraph-backed execution,
|
|
22
|
+
for conditional routing and subgraphs.
|
|
23
|
+
* :class:`~windlass.agent.supervisor.Supervisor` — multi-agent delegation.
|
|
24
|
+
* :mod:`~windlass.agent.checkpoint` — durable state for resume and
|
|
25
|
+
human-in-the-loop.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
from __future__ import annotations
|
|
29
|
+
|
|
30
|
+
from windlass.agent.builder import AgentBuilder
|
|
31
|
+
from windlass.agent.checkpoint import Checkpointer, MemoryCheckpointer, SQLiteCheckpointer
|
|
32
|
+
from windlass.agent.runtime import DEFAULT_SYSTEM_PROMPT, AgentRuntime
|
|
33
|
+
from windlass.agent.supervisor import AgentTool, Supervisor
|
|
34
|
+
|
|
35
|
+
__all__ = [
|
|
36
|
+
"DEFAULT_SYSTEM_PROMPT",
|
|
37
|
+
"AgentBuilder",
|
|
38
|
+
"AgentRuntime",
|
|
39
|
+
"AgentTool",
|
|
40
|
+
"Checkpointer",
|
|
41
|
+
"MemoryCheckpointer",
|
|
42
|
+
"SQLiteCheckpointer",
|
|
43
|
+
"Supervisor",
|
|
44
|
+
]
|