Skip to content

Commit 87bf769

Browse files
docs: add examples directory with basic usage
Add examples/basic/main.py demonstrating how to use the Python SDK to interact with hawk daemon. Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
1 parent a61360c commit 87bf769

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

examples/basic/main.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python3
2+
"""Basic example of using the Hawk SDK."""
3+
4+
from hawk import HawkClient
5+
6+
def main():
7+
with HawkClient() as client:
8+
# Health check
9+
health = client.health()
10+
print(f"Hawk daemon: version={health.version}, sessions={health.sessions}")
11+
12+
# Chat
13+
response = client.chat("Explain what a decorator is in Python")
14+
print(f"Response: {response.response}")
15+
16+
# Streaming
17+
print("\nStreaming response:")
18+
with client.chat_stream("Write a haiku about code") as stream:
19+
for event in stream.events():
20+
print(event.data, end="", flush=True)
21+
print()
22+
23+
if __name__ == "__main__":
24+
main()

0 commit comments

Comments
 (0)