wauldo 0.1.0__tar.gz
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.
- wauldo-0.1.0/.editorconfig +11 -0
- wauldo-0.1.0/.gitignore +10 -0
- wauldo-0.1.0/CHANGELOG.md +23 -0
- wauldo-0.1.0/LICENSE +21 -0
- wauldo-0.1.0/PKG-INFO +172 -0
- wauldo-0.1.0/README.md +136 -0
- wauldo-0.1.0/examples/basic_chat.py +28 -0
- wauldo-0.1.0/examples/rag_workflow.py +25 -0
- wauldo-0.1.0/examples/streaming_chat.py +28 -0
- wauldo-0.1.0/pyproject.toml +75 -0
- wauldo-0.1.0/src/wauldo/__init__.py +89 -0
- wauldo-0.1.0/src/wauldo/client.py +618 -0
- wauldo-0.1.0/src/wauldo/conversation.py +115 -0
- wauldo-0.1.0/src/wauldo/exceptions.py +57 -0
- wauldo-0.1.0/src/wauldo/http_client.py +242 -0
- wauldo-0.1.0/src/wauldo/http_streaming.py +86 -0
- wauldo-0.1.0/src/wauldo/http_transport.py +108 -0
- wauldo-0.1.0/src/wauldo/http_types.py +171 -0
- wauldo-0.1.0/src/wauldo/mock_client.py +142 -0
- wauldo-0.1.0/src/wauldo/models.py +292 -0
- wauldo-0.1.0/src/wauldo/py.typed +0 -0
- wauldo-0.1.0/src/wauldo/transport.py +355 -0
- wauldo-0.1.0/tests/__init__.py +1 -0
- wauldo-0.1.0/tests/test_client.py +126 -0
- wauldo-0.1.0/tests/test_conversation.py +63 -0
- wauldo-0.1.0/tests/test_exceptions.py +103 -0
- wauldo-0.1.0/tests/test_http_client.py +203 -0
- wauldo-0.1.0/tests/test_http_mock.py +247 -0
- wauldo-0.1.0/tests/test_models.py +129 -0
wauldo-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the Wauldo Python SDK.
|
|
4
|
+
|
|
5
|
+
## [0.1.0] - 2026-03-16
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- `HttpClient` — REST API client (OpenAI-compatible)
|
|
9
|
+
- `chat()`, `chat_simple()`, `chat_stream()`, `list_models()`, `embeddings()`
|
|
10
|
+
- `rag_upload()`, `rag_query()`, `rag_ask()`
|
|
11
|
+
- `orchestrate()`, `orchestrate_parallel()`
|
|
12
|
+
- `AgentClient` / `AsyncAgentClient` — MCP client (sync + async)
|
|
13
|
+
- `reason()`, `extract_concepts()`, `plan_task()`
|
|
14
|
+
- `chunk_document()`, `retrieve_context()`, `summarize()`
|
|
15
|
+
- `search_knowledge()`, `add_to_knowledge()`
|
|
16
|
+
- `Conversation` — automatic chat history management
|
|
17
|
+
- `MockHttpClient` — offline testing without server
|
|
18
|
+
- Retry with exponential backoff (429/503/network errors)
|
|
19
|
+
- Structured logging via `logging.getLogger("wauldo")`
|
|
20
|
+
- Pydantic v2 response validation on all endpoints
|
|
21
|
+
- Full type hints + py.typed (PEP 561)
|
|
22
|
+
- Per-request `timeout_ms` override on `chat()`, `chat_simple()`, `rag_upload()`
|
|
23
|
+
- Event hooks: `on_request`, `on_response`, `on_error` callbacks
|
wauldo-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Wauldo Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
wauldo-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wauldo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for Wauldo — Verified AI answers from your documents
|
|
5
|
+
Project-URL: Homepage, https://wauldo.com
|
|
6
|
+
Project-URL: Documentation, https://wauldo.com/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/wauldo/wauldo-sdk-python
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/wauldo/wauldo-sdk-python/issues
|
|
9
|
+
Project-URL: RapidAPI, https://rapidapi.com/binnewzzin/api/smart-rag-api
|
|
10
|
+
Project-URL: Source, https://github.com/wauldo/wauldo-sdk-python
|
|
11
|
+
Author-email: Wauldo Team <contact@wauldo.com>
|
|
12
|
+
License: MIT
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Keywords: ai,api,chatgpt,gdpr,llm,machine-learning,nlp,openai,privacy,rapidapi
|
|
15
|
+
Classifier: Development Status :: 4 - Beta
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.9
|
|
28
|
+
Requires-Dist: pydantic>=2.0.0
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# Wauldo Python SDK
|
|
38
|
+
|
|
39
|
+
[](https://pypi.org/project/wauldo/)
|
|
40
|
+
[](https://pypi.org/project/wauldo/)
|
|
41
|
+
[](https://python.org/)
|
|
42
|
+
[](./LICENSE)
|
|
43
|
+
|
|
44
|
+
> **Verified AI answers from your documents.** Every response includes source citations, confidence scores, and an audit trail — or we don't answer at all.
|
|
45
|
+
|
|
46
|
+
Official Python SDK for the [Wauldo API](https://wauldo.com) — the AI inference layer with smart model routing and zero hallucinations.
|
|
47
|
+
|
|
48
|
+
## Why Wauldo?
|
|
49
|
+
|
|
50
|
+
- **Zero hallucinations** — every answer is verified against source documents
|
|
51
|
+
- **Smart model routing** — auto-selects the cheapest model that meets quality (save 40-80% on AI costs)
|
|
52
|
+
- **One API, 7+ providers** — OpenAI, Anthropic, Google, Qwen, Meta, Mistral, DeepSeek with automatic fallback
|
|
53
|
+
- **OpenAI-compatible** — swap your `base_url`, keep your existing code
|
|
54
|
+
- **Full audit trail** — confidence score, grounded status, model used, latency on every response
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from wauldo import HttpClient
|
|
60
|
+
|
|
61
|
+
client = HttpClient(base_url="https://api.wauldo.com", api_key="YOUR_API_KEY")
|
|
62
|
+
|
|
63
|
+
reply = client.chat_simple("auto", "What is Python?")
|
|
64
|
+
print(reply)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install wauldo
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Requirements:** Python 3.9+
|
|
74
|
+
|
|
75
|
+
## Features
|
|
76
|
+
|
|
77
|
+
### Chat Completions
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from wauldo import HttpClient, ChatRequest, HttpChatMessage
|
|
81
|
+
|
|
82
|
+
client = HttpClient(base_url="https://api.wauldo.com", api_key="YOUR_API_KEY")
|
|
83
|
+
|
|
84
|
+
request = ChatRequest(
|
|
85
|
+
model="auto",
|
|
86
|
+
messages=[
|
|
87
|
+
HttpChatMessage.system("You are a helpful assistant."),
|
|
88
|
+
HttpChatMessage.user("Explain Python decorators"),
|
|
89
|
+
],
|
|
90
|
+
)
|
|
91
|
+
response = client.chat(request)
|
|
92
|
+
print(response.choices[0].message.content)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### RAG — Upload & Query
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
# Upload a document
|
|
99
|
+
upload = client.rag_upload(content="Contract text here...", filename="contract.txt")
|
|
100
|
+
print(f"Indexed {upload.chunks_count} chunks")
|
|
101
|
+
|
|
102
|
+
# Query with verified answer
|
|
103
|
+
result = client.rag_query("What are the payment terms?")
|
|
104
|
+
print(f"Answer: {result.answer}")
|
|
105
|
+
print(f"Confidence: {result.get_confidence():.0%}")
|
|
106
|
+
print(f"Grounded: {result.audit.grounded}")
|
|
107
|
+
for source in result.sources:
|
|
108
|
+
print(f" Source ({source.score:.0%}): {source.content[:80]}")
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Streaming (SSE)
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from wauldo import ChatRequest, HttpChatMessage
|
|
115
|
+
|
|
116
|
+
request = ChatRequest(model="auto", messages=[HttpChatMessage.user("Hello!")])
|
|
117
|
+
for chunk in client.chat_stream(request):
|
|
118
|
+
print(chunk, end="", flush=True)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Conversation Helper
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
conv = client.conversation(system="You are an expert on Python.", model="auto")
|
|
125
|
+
reply = conv.say("What are list comprehensions?")
|
|
126
|
+
follow_up = conv.say("Give me a nested example")
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Error Handling
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from wauldo import WauldoError, ServerError, AgentTimeoutError
|
|
133
|
+
|
|
134
|
+
try:
|
|
135
|
+
response = client.chat(ChatRequest.quick("auto", "Hello"))
|
|
136
|
+
except ServerError as e:
|
|
137
|
+
print(f"Server error: {e}")
|
|
138
|
+
except AgentTimeoutError:
|
|
139
|
+
print("Request timed out")
|
|
140
|
+
except WauldoError as e:
|
|
141
|
+
print(f"SDK error: {e}")
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## RapidAPI
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
client = HttpClient(
|
|
148
|
+
base_url="https://api.wauldo.com",
|
|
149
|
+
headers={
|
|
150
|
+
"X-RapidAPI-Key": "YOUR_RAPIDAPI_KEY",
|
|
151
|
+
"X-RapidAPI-Host": "smart-rag-api.p.rapidapi.com",
|
|
152
|
+
},
|
|
153
|
+
)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Get your free API key (300 req/month): [RapidAPI](https://rapidapi.com/binnewzzin/api/smart-rag-api)
|
|
157
|
+
|
|
158
|
+
## Links
|
|
159
|
+
|
|
160
|
+
- [Website](https://wauldo.com)
|
|
161
|
+
- [Documentation](https://wauldo.com/docs)
|
|
162
|
+
- [Live Demo](https://api.wauldo.com/demo)
|
|
163
|
+
- [Cost Calculator](https://wauldo.com/calculator)
|
|
164
|
+
- [Status](https://wauldo.com/status)
|
|
165
|
+
|
|
166
|
+
## Contributing
|
|
167
|
+
|
|
168
|
+
Found a bug? Have a feature request? [Open an issue](https://github.com/wauldo/wauldo-sdk-python/issues).
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
MIT — see [LICENSE](./LICENSE)
|
wauldo-0.1.0/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Wauldo Python SDK
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/wauldo/)
|
|
4
|
+
[](https://pypi.org/project/wauldo/)
|
|
5
|
+
[](https://python.org/)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
|
|
8
|
+
> **Verified AI answers from your documents.** Every response includes source citations, confidence scores, and an audit trail — or we don't answer at all.
|
|
9
|
+
|
|
10
|
+
Official Python SDK for the [Wauldo API](https://wauldo.com) — the AI inference layer with smart model routing and zero hallucinations.
|
|
11
|
+
|
|
12
|
+
## Why Wauldo?
|
|
13
|
+
|
|
14
|
+
- **Zero hallucinations** — every answer is verified against source documents
|
|
15
|
+
- **Smart model routing** — auto-selects the cheapest model that meets quality (save 40-80% on AI costs)
|
|
16
|
+
- **One API, 7+ providers** — OpenAI, Anthropic, Google, Qwen, Meta, Mistral, DeepSeek with automatic fallback
|
|
17
|
+
- **OpenAI-compatible** — swap your `base_url`, keep your existing code
|
|
18
|
+
- **Full audit trail** — confidence score, grounded status, model used, latency on every response
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from wauldo import HttpClient
|
|
24
|
+
|
|
25
|
+
client = HttpClient(base_url="https://api.wauldo.com", api_key="YOUR_API_KEY")
|
|
26
|
+
|
|
27
|
+
reply = client.chat_simple("auto", "What is Python?")
|
|
28
|
+
print(reply)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install wauldo
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Requirements:** Python 3.9+
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
### Chat Completions
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from wauldo import HttpClient, ChatRequest, HttpChatMessage
|
|
45
|
+
|
|
46
|
+
client = HttpClient(base_url="https://api.wauldo.com", api_key="YOUR_API_KEY")
|
|
47
|
+
|
|
48
|
+
request = ChatRequest(
|
|
49
|
+
model="auto",
|
|
50
|
+
messages=[
|
|
51
|
+
HttpChatMessage.system("You are a helpful assistant."),
|
|
52
|
+
HttpChatMessage.user("Explain Python decorators"),
|
|
53
|
+
],
|
|
54
|
+
)
|
|
55
|
+
response = client.chat(request)
|
|
56
|
+
print(response.choices[0].message.content)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### RAG — Upload & Query
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
# Upload a document
|
|
63
|
+
upload = client.rag_upload(content="Contract text here...", filename="contract.txt")
|
|
64
|
+
print(f"Indexed {upload.chunks_count} chunks")
|
|
65
|
+
|
|
66
|
+
# Query with verified answer
|
|
67
|
+
result = client.rag_query("What are the payment terms?")
|
|
68
|
+
print(f"Answer: {result.answer}")
|
|
69
|
+
print(f"Confidence: {result.get_confidence():.0%}")
|
|
70
|
+
print(f"Grounded: {result.audit.grounded}")
|
|
71
|
+
for source in result.sources:
|
|
72
|
+
print(f" Source ({source.score:.0%}): {source.content[:80]}")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Streaming (SSE)
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from wauldo import ChatRequest, HttpChatMessage
|
|
79
|
+
|
|
80
|
+
request = ChatRequest(model="auto", messages=[HttpChatMessage.user("Hello!")])
|
|
81
|
+
for chunk in client.chat_stream(request):
|
|
82
|
+
print(chunk, end="", flush=True)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Conversation Helper
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
conv = client.conversation(system="You are an expert on Python.", model="auto")
|
|
89
|
+
reply = conv.say("What are list comprehensions?")
|
|
90
|
+
follow_up = conv.say("Give me a nested example")
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Error Handling
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from wauldo import WauldoError, ServerError, AgentTimeoutError
|
|
97
|
+
|
|
98
|
+
try:
|
|
99
|
+
response = client.chat(ChatRequest.quick("auto", "Hello"))
|
|
100
|
+
except ServerError as e:
|
|
101
|
+
print(f"Server error: {e}")
|
|
102
|
+
except AgentTimeoutError:
|
|
103
|
+
print("Request timed out")
|
|
104
|
+
except WauldoError as e:
|
|
105
|
+
print(f"SDK error: {e}")
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## RapidAPI
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
client = HttpClient(
|
|
112
|
+
base_url="https://api.wauldo.com",
|
|
113
|
+
headers={
|
|
114
|
+
"X-RapidAPI-Key": "YOUR_RAPIDAPI_KEY",
|
|
115
|
+
"X-RapidAPI-Host": "smart-rag-api.p.rapidapi.com",
|
|
116
|
+
},
|
|
117
|
+
)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Get your free API key (300 req/month): [RapidAPI](https://rapidapi.com/binnewzzin/api/smart-rag-api)
|
|
121
|
+
|
|
122
|
+
## Links
|
|
123
|
+
|
|
124
|
+
- [Website](https://wauldo.com)
|
|
125
|
+
- [Documentation](https://wauldo.com/docs)
|
|
126
|
+
- [Live Demo](https://api.wauldo.com/demo)
|
|
127
|
+
- [Cost Calculator](https://wauldo.com/calculator)
|
|
128
|
+
- [Status](https://wauldo.com/status)
|
|
129
|
+
|
|
130
|
+
## Contributing
|
|
131
|
+
|
|
132
|
+
Found a bug? Have a feature request? [Open an issue](https://github.com/wauldo/wauldo-sdk-python/issues).
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
MIT — see [LICENSE](./LICENSE)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Basic chat completion using the Wauldo HttpClient."""
|
|
2
|
+
|
|
3
|
+
from wauldo import HttpClient, ChatRequest, HttpChatMessage
|
|
4
|
+
|
|
5
|
+
def main() -> None:
|
|
6
|
+
client = HttpClient(base_url="http://localhost:3000")
|
|
7
|
+
|
|
8
|
+
# Quick one-liner chat
|
|
9
|
+
reply = client.chat_simple("qwen2.5:7b", "What is Rust?")
|
|
10
|
+
print(f"Simple reply: {reply[:120]}...")
|
|
11
|
+
|
|
12
|
+
# Full request with parameters
|
|
13
|
+
request = ChatRequest(
|
|
14
|
+
model="qwen2.5:7b",
|
|
15
|
+
messages=[
|
|
16
|
+
HttpChatMessage.system("You are a concise assistant."),
|
|
17
|
+
HttpChatMessage.user("Explain async/await in 2 sentences."),
|
|
18
|
+
],
|
|
19
|
+
temperature=0.3,
|
|
20
|
+
max_tokens=200,
|
|
21
|
+
)
|
|
22
|
+
response = client.chat(request)
|
|
23
|
+
print(f"Model: {response.model}")
|
|
24
|
+
print(f"Reply: {response.choices[0].message.content}")
|
|
25
|
+
print(f"Tokens used: {response.usage.total_tokens}")
|
|
26
|
+
|
|
27
|
+
if __name__ == "__main__":
|
|
28
|
+
main()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""RAG workflow: upload a document then query the knowledge base."""
|
|
2
|
+
|
|
3
|
+
from wauldo import HttpClient
|
|
4
|
+
|
|
5
|
+
def main() -> None:
|
|
6
|
+
client = HttpClient(base_url="http://localhost:3000")
|
|
7
|
+
|
|
8
|
+
# Upload a document for RAG indexing
|
|
9
|
+
doc = (
|
|
10
|
+
"Rust is a systems programming language focused on safety and performance. "
|
|
11
|
+
"It prevents data races at compile time through its ownership system. "
|
|
12
|
+
"The borrow checker enforces memory safety without a garbage collector."
|
|
13
|
+
)
|
|
14
|
+
upload = client.rag_upload(content=doc, filename="rust_intro.txt")
|
|
15
|
+
print(f"Uploaded: id={upload.document_id}, chunks={upload.chunks_count}")
|
|
16
|
+
|
|
17
|
+
# Query the knowledge base
|
|
18
|
+
result = client.rag_query("How does Rust ensure memory safety?", top_k=3)
|
|
19
|
+
print(f"\nAnswer: {result.answer}")
|
|
20
|
+
print(f"\nSources ({len(result.sources)}):")
|
|
21
|
+
for src in result.sources:
|
|
22
|
+
print(f" - [{src.score:.2f}] {src.content[:80]}...")
|
|
23
|
+
|
|
24
|
+
if __name__ == "__main__":
|
|
25
|
+
main()
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""SSE streaming chat completion using the Wauldo HttpClient."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from wauldo import HttpClient, ChatRequest, HttpChatMessage
|
|
5
|
+
|
|
6
|
+
def main() -> None:
|
|
7
|
+
client = HttpClient(base_url="http://localhost:3000")
|
|
8
|
+
|
|
9
|
+
request = ChatRequest(
|
|
10
|
+
model="qwen2.5:7b",
|
|
11
|
+
messages=[
|
|
12
|
+
HttpChatMessage.system("You are a helpful assistant."),
|
|
13
|
+
HttpChatMessage.user("Write a haiku about Rust programming."),
|
|
14
|
+
],
|
|
15
|
+
temperature=0.7,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
print("Streaming response: ", end="", flush=True)
|
|
19
|
+
token_count = 0
|
|
20
|
+
for chunk in client.chat_stream(request):
|
|
21
|
+
sys.stdout.write(chunk)
|
|
22
|
+
sys.stdout.flush()
|
|
23
|
+
token_count += 1
|
|
24
|
+
|
|
25
|
+
print(f"\n\nReceived {token_count} chunks.")
|
|
26
|
+
|
|
27
|
+
if __name__ == "__main__":
|
|
28
|
+
main()
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "wauldo"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Python SDK for Wauldo — Verified AI answers from your documents"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Wauldo Team", email = "contact@wauldo.com"}
|
|
14
|
+
]
|
|
15
|
+
keywords = ["ai", "llm", "openai", "privacy", "gdpr", "chatgpt", "api", "rapidapi", "nlp", "machine-learning"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
20
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
21
|
+
"License :: OSI Approved :: MIT License",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.9",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Operating System :: OS Independent",
|
|
28
|
+
"Typing :: Typed",
|
|
29
|
+
]
|
|
30
|
+
requires-python = ">=3.9"
|
|
31
|
+
dependencies = [
|
|
32
|
+
"pydantic>=2.0.0",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
dev = [
|
|
37
|
+
"pytest>=7.0.0",
|
|
38
|
+
"pytest-asyncio>=0.21.0",
|
|
39
|
+
"pytest-cov>=4.0",
|
|
40
|
+
"mypy>=1.0.0",
|
|
41
|
+
"ruff>=0.1.0",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[project.urls]
|
|
45
|
+
Homepage = "https://wauldo.com"
|
|
46
|
+
Documentation = "https://wauldo.com/docs"
|
|
47
|
+
Repository = "https://github.com/wauldo/wauldo-sdk-python"
|
|
48
|
+
"Bug Tracker" = "https://github.com/wauldo/wauldo-sdk-python/issues"
|
|
49
|
+
RapidAPI = "https://rapidapi.com/binnewzzin/api/smart-rag-api"
|
|
50
|
+
Source = "https://github.com/wauldo/wauldo-sdk-python"
|
|
51
|
+
|
|
52
|
+
[tool.hatch.build.targets.wheel]
|
|
53
|
+
packages = ["src/wauldo"]
|
|
54
|
+
|
|
55
|
+
[tool.pytest.ini_options]
|
|
56
|
+
asyncio_mode = "auto"
|
|
57
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
58
|
+
testpaths = ["tests"]
|
|
59
|
+
filterwarnings = [
|
|
60
|
+
"ignore::DeprecationWarning",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[tool.mypy]
|
|
64
|
+
python_version = "3.9"
|
|
65
|
+
strict = true
|
|
66
|
+
warn_return_any = true
|
|
67
|
+
warn_unused_configs = true
|
|
68
|
+
|
|
69
|
+
[tool.ruff]
|
|
70
|
+
target-version = "py39"
|
|
71
|
+
line-length = 100
|
|
72
|
+
|
|
73
|
+
[tool.ruff.lint]
|
|
74
|
+
select = ["E", "F", "I", "N", "W", "UP", "ANN", "B", "C4", "SIM"]
|
|
75
|
+
ignore = ["ANN101", "ANN102"]
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Wauldo Python SDK
|
|
3
|
+
|
|
4
|
+
Two client interfaces:
|
|
5
|
+
- AgentClient / AsyncAgentClient — MCP server (stdio JSON-RPC) for reasoning, planning, tools
|
|
6
|
+
- HttpClient — REST API (OpenAI-compatible) for chat, embeddings, RAG, orchestrator
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from .client import AgentClient, AsyncAgentClient
|
|
10
|
+
from .conversation import Conversation
|
|
11
|
+
from .exceptions import (
|
|
12
|
+
AgentConnectionError,
|
|
13
|
+
AgentTimeoutError,
|
|
14
|
+
ServerError,
|
|
15
|
+
ToolNotFoundError,
|
|
16
|
+
ValidationError,
|
|
17
|
+
WauldoError,
|
|
18
|
+
)
|
|
19
|
+
from .http_client import HttpClient
|
|
20
|
+
from .http_types import (
|
|
21
|
+
ChatMessage as HttpChatMessage,
|
|
22
|
+
)
|
|
23
|
+
from .http_types import (
|
|
24
|
+
ChatRequest,
|
|
25
|
+
ChatResponse,
|
|
26
|
+
EmbeddingResponse,
|
|
27
|
+
ModelList,
|
|
28
|
+
OrchestratorResponse,
|
|
29
|
+
RagAuditInfo,
|
|
30
|
+
RagQueryResponse,
|
|
31
|
+
RagSource,
|
|
32
|
+
RagUploadResponse,
|
|
33
|
+
)
|
|
34
|
+
from .mock_client import MockHttpClient
|
|
35
|
+
from .models import (
|
|
36
|
+
Chunk,
|
|
37
|
+
ChunkResult,
|
|
38
|
+
Concept,
|
|
39
|
+
ConceptResult,
|
|
40
|
+
GraphNode,
|
|
41
|
+
KnowledgeGraphResult,
|
|
42
|
+
PlanResult,
|
|
43
|
+
PlanStep,
|
|
44
|
+
ReasoningResult,
|
|
45
|
+
RetrievalResult,
|
|
46
|
+
ToolDefinition,
|
|
47
|
+
ToolsListResult,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
__version__ = "0.1.0"
|
|
51
|
+
__all__ = [
|
|
52
|
+
# MCP Clients
|
|
53
|
+
"AgentClient",
|
|
54
|
+
"AsyncAgentClient",
|
|
55
|
+
# HTTP Client
|
|
56
|
+
"HttpClient",
|
|
57
|
+
"MockHttpClient",
|
|
58
|
+
"Conversation",
|
|
59
|
+
"ChatRequest",
|
|
60
|
+
"ChatResponse",
|
|
61
|
+
"HttpChatMessage",
|
|
62
|
+
"EmbeddingResponse",
|
|
63
|
+
"ModelList",
|
|
64
|
+
"OrchestratorResponse",
|
|
65
|
+
"RagAuditInfo",
|
|
66
|
+
"RagQueryResponse",
|
|
67
|
+
"RagSource",
|
|
68
|
+
"RagUploadResponse",
|
|
69
|
+
# Exceptions
|
|
70
|
+
"WauldoError",
|
|
71
|
+
"AgentConnectionError",
|
|
72
|
+
"AgentTimeoutError",
|
|
73
|
+
"ServerError",
|
|
74
|
+
"ToolNotFoundError",
|
|
75
|
+
"ValidationError",
|
|
76
|
+
# MCP Models
|
|
77
|
+
"ReasoningResult",
|
|
78
|
+
"ConceptResult",
|
|
79
|
+
"Concept",
|
|
80
|
+
"ChunkResult",
|
|
81
|
+
"Chunk",
|
|
82
|
+
"RetrievalResult",
|
|
83
|
+
"KnowledgeGraphResult",
|
|
84
|
+
"PlanResult",
|
|
85
|
+
"PlanStep",
|
|
86
|
+
"GraphNode",
|
|
87
|
+
"ToolDefinition",
|
|
88
|
+
"ToolsListResult",
|
|
89
|
+
]
|