claude-webapi 1.0.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.
- claude_webapi/__init__.py +82 -0
- claude_webapi/client.py +911 -0
- claude_webapi/constants.py +46 -0
- claude_webapi/exceptions.py +46 -0
- claude_webapi/session.py +169 -0
- claude_webapi/setup.py +38 -0
- claude_webapi/types.py +158 -0
- claude_webapi-1.0.0.dist-info/METADATA +457 -0
- claude_webapi-1.0.0.dist-info/RECORD +12 -0
- claude_webapi-1.0.0.dist-info/WHEEL +5 -0
- claude_webapi-1.0.0.dist-info/licenses/LICENSE +21 -0
- claude_webapi-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""
|
|
2
|
+
claude_webapi — Async Python wrapper for the Claude.ai web app.
|
|
3
|
+
|
|
4
|
+
Quick start::
|
|
5
|
+
|
|
6
|
+
import asyncio
|
|
7
|
+
from claude_webapi import ClaudeClient
|
|
8
|
+
|
|
9
|
+
async def main():
|
|
10
|
+
client = ClaudeClient("sk-ant-…", "your-org-uuid")
|
|
11
|
+
await client.init()
|
|
12
|
+
|
|
13
|
+
response = await client.generate_content("Hello Claude!")
|
|
14
|
+
print(response.text)
|
|
15
|
+
|
|
16
|
+
asyncio.run(main())
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from .client import ClaudeClient
|
|
20
|
+
from .constants import Model
|
|
21
|
+
from .exceptions import (
|
|
22
|
+
APIError,
|
|
23
|
+
AuthenticationError,
|
|
24
|
+
ClaudeWebAPIError,
|
|
25
|
+
ConversationNotFoundError,
|
|
26
|
+
FileUploadError,
|
|
27
|
+
QuotaExceededError,
|
|
28
|
+
TimeoutError,
|
|
29
|
+
)
|
|
30
|
+
from .session import ChatSession
|
|
31
|
+
from .types import Candidate, Image, ModelOutput
|
|
32
|
+
|
|
33
|
+
import logging as _logging
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def set_log_level(level: str) -> None:
|
|
37
|
+
"""
|
|
38
|
+
Configure the ``claude_webapi`` logger.
|
|
39
|
+
|
|
40
|
+
Calling this for the first time removes any existing handlers on the
|
|
41
|
+
``claude_webapi`` logger so the new level takes effect cleanly.
|
|
42
|
+
|
|
43
|
+
Parameters
|
|
44
|
+
----------
|
|
45
|
+
level:
|
|
46
|
+
One of ``"DEBUG"``, ``"INFO"``, ``"WARNING"``, ``"ERROR"``,
|
|
47
|
+
``"CRITICAL"``.
|
|
48
|
+
|
|
49
|
+
Example::
|
|
50
|
+
|
|
51
|
+
from claude_webapi import set_log_level
|
|
52
|
+
set_log_level("DEBUG")
|
|
53
|
+
"""
|
|
54
|
+
log = _logging.getLogger("claude_webapi")
|
|
55
|
+
log.handlers.clear()
|
|
56
|
+
handler = _logging.StreamHandler()
|
|
57
|
+
handler.setFormatter(
|
|
58
|
+
_logging.Formatter("%(asctime)s %(levelname)-5s %(name)s %(message)s")
|
|
59
|
+
)
|
|
60
|
+
log.addHandler(handler)
|
|
61
|
+
log.setLevel(getattr(_logging, level.upper(), _logging.INFO))
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
__all__ = [
|
|
65
|
+
"ClaudeClient",
|
|
66
|
+
"ChatSession",
|
|
67
|
+
"Model",
|
|
68
|
+
"ModelOutput",
|
|
69
|
+
"Candidate",
|
|
70
|
+
"Image",
|
|
71
|
+
"ClaudeWebAPIError",
|
|
72
|
+
"APIError",
|
|
73
|
+
"AuthenticationError",
|
|
74
|
+
"ConversationNotFoundError",
|
|
75
|
+
"FileUploadError",
|
|
76
|
+
"QuotaExceededError",
|
|
77
|
+
"TimeoutError",
|
|
78
|
+
"set_log_level",
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
__version__ = "1.0.0"
|
|
82
|
+
|