Skip to content

Commit 848026f

Browse files
committed
Release 0.1.8
1 parent 95b4c29 commit 848026f

File tree

4 files changed

+168
-11
lines changed

4 files changed

+168
-11
lines changed

README.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Klavis Python Library
2+
3+
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FKlavis-AI%2Fpython-sdk)
4+
[![pypi](https://img.shields.io/pypi/v/klavis)](https://pypi.python.org/pypi/klavis)
5+
6+
The Klavis Python library provides convenient access to the Klavis API from Python.
7+
8+
## Installation
9+
10+
```sh
11+
pip install klavis
12+
```
13+
14+
## Reference
15+
16+
A full reference for this library is available [here](https://github.com/Klavis-AI/python-sdk/blob/HEAD/./reference.md).
17+
18+
## Usage
19+
20+
Instantiate and use the client with the following:
21+
22+
```python
23+
from klavis import Klavis
24+
25+
client = Klavis(
26+
api_key="YOUR_API_KEY",
27+
)
28+
client.mcp_server.call_server_tool(
29+
server_url="serverUrl",
30+
tool_name="toolName",
31+
)
32+
```
33+
34+
## Async Client
35+
36+
The SDK also exports an `async` client so that you can make non-blocking calls to our API.
37+
38+
```python
39+
import asyncio
40+
41+
from klavis import AsyncKlavis
42+
43+
client = AsyncKlavis(
44+
api_key="YOUR_API_KEY",
45+
)
46+
47+
48+
async def main() -> None:
49+
await client.mcp_server.call_server_tool(
50+
server_url="serverUrl",
51+
tool_name="toolName",
52+
)
53+
54+
55+
asyncio.run(main())
56+
```
57+
58+
## Exception Handling
59+
60+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
61+
will be thrown.
62+
63+
```python
64+
from klavis.core.api_error import ApiError
65+
66+
try:
67+
client.mcp_server.call_server_tool(...)
68+
except ApiError as e:
69+
print(e.status_code)
70+
print(e.body)
71+
```
72+
73+
## Advanced
74+
75+
### Access Raw Response Data
76+
77+
The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
78+
The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
79+
80+
```python
81+
from klavis import Klavis
82+
83+
client = Klavis(
84+
...,
85+
)
86+
response = client.mcp_server.with_raw_response.call_server_tool(...)
87+
print(response.headers) # access the response headers
88+
print(response.data) # access the underlying object
89+
```
90+
91+
### Retries
92+
93+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
94+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
95+
retry limit (default: 2).
96+
97+
A request is deemed retryable when any of the following HTTP status codes is returned:
98+
99+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
100+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
101+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
102+
103+
Use the `max_retries` request option to configure this behavior.
104+
105+
```python
106+
client.mcp_server.call_server_tool(..., request_options={
107+
"max_retries": 1
108+
})
109+
```
110+
111+
### Timeouts
112+
113+
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
114+
115+
```python
116+
117+
from klavis import Klavis
118+
119+
client = Klavis(
120+
...,
121+
timeout=20.0,
122+
)
123+
124+
125+
# Override timeout for a specific method
126+
client.mcp_server.call_server_tool(..., request_options={
127+
"timeout_in_seconds": 1
128+
})
129+
```
130+
131+
### Custom Client
132+
133+
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
134+
and transports.
135+
136+
```python
137+
import httpx
138+
from klavis import Klavis
139+
140+
client = Klavis(
141+
...,
142+
httpx_client=httpx.Client(
143+
proxies="http://my.test.proxy.example.com",
144+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
145+
),
146+
)
147+
```
148+
149+
## Contributing
150+
151+
While we value open-source contributions to this SDK, this library is generated programmatically.
152+
Additions made directly to this library would have to be moved over to our generation code,
153+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
154+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
155+
an issue first to discuss with us!
156+
157+
On the other hand, contributions to the README are always very welcome!

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "klavis"
33

44
[tool.poetry]
55
name = "klavis"
6-
version = "0.1.7"
6+
version = "0.1.8"
77
description = ""
88
readme = "README.md"
99
authors = []

src/klavis/core/client_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ def __init__(self, *, api_key: str, base_url: str, timeout: typing.Optional[floa
1414

1515
def get_headers(self) -> typing.Dict[str, str]:
1616
headers: typing.Dict[str, str] = {
17-
"User-Agent": "klavis/0.1.7",
17+
"User-Agent": "klavis/0.1.8",
1818
"X-Fern-Language": "Python",
1919
"X-Fern-SDK-Name": "klavis",
20-
"X-Fern-SDK-Version": "0.1.7",
20+
"X-Fern-SDK-Version": "0.1.8",
2121
}
2222
headers["Authorization"] = self.api_key
2323
return headers

src/klavis/types/mcp_server_name.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ class McpServerName(str, enum.Enum):
1111
SLACK = "Slack"
1212
SUPABASE = "Supabase"
1313
POSTGRES = "Postgres"
14-
YOU_TUBE = "YouTube"
14+
YOUTUBE = "YouTube"
1515
DOC2MARKDOWN = "Doc2markdown"
1616
KLAVIS_REPORT_GEN = "Klavis ReportGen"
1717
RESEND = "Resend"
1818
DISCORD = "Discord"
1919
FIRECRAWL_WEB_SEARCH = "Firecrawl Web Search"
20-
GIT_HUB = "GitHub"
20+
GITHUB = "GitHub"
2121
FIRECRAWL_DEEP_RESEARCH = "Firecrawl Deep Research"
2222
JIRA = "Jira"
2323
CONFLUENCE = "Confluence"
@@ -42,13 +42,13 @@ def visit(
4242
slack: typing.Callable[[], T_Result],
4343
supabase: typing.Callable[[], T_Result],
4444
postgres: typing.Callable[[], T_Result],
45-
you_tube: typing.Callable[[], T_Result],
45+
youtube: typing.Callable[[], T_Result],
4646
doc2markdown: typing.Callable[[], T_Result],
4747
klavis_report_gen: typing.Callable[[], T_Result],
4848
resend: typing.Callable[[], T_Result],
4949
discord: typing.Callable[[], T_Result],
5050
firecrawl_web_search: typing.Callable[[], T_Result],
51-
git_hub: typing.Callable[[], T_Result],
51+
github: typing.Callable[[], T_Result],
5252
firecrawl_deep_research: typing.Callable[[], T_Result],
5353
jira: typing.Callable[[], T_Result],
5454
confluence: typing.Callable[[], T_Result],
@@ -75,8 +75,8 @@ def visit(
7575
return supabase()
7676
if self is McpServerName.POSTGRES:
7777
return postgres()
78-
if self is McpServerName.YOU_TUBE:
79-
return you_tube()
78+
if self is McpServerName.YOUTUBE:
79+
return youtube()
8080
if self is McpServerName.DOC2MARKDOWN:
8181
return doc2markdown()
8282
if self is McpServerName.KLAVIS_REPORT_GEN:
@@ -87,8 +87,8 @@ def visit(
8787
return discord()
8888
if self is McpServerName.FIRECRAWL_WEB_SEARCH:
8989
return firecrawl_web_search()
90-
if self is McpServerName.GIT_HUB:
91-
return git_hub()
90+
if self is McpServerName.GITHUB:
91+
return github()
9292
if self is McpServerName.FIRECRAWL_DEEP_RESEARCH:
9393
return firecrawl_deep_research()
9494
if self is McpServerName.JIRA:

0 commit comments

Comments
 (0)