community: docstrings (#23202)

Added missed docstrings. Format docstrings to the consistent format
(used in the API Reference)
This commit is contained in:
Leonid Ganeline
2024-06-20 08:08:13 -07:00
committed by GitHub
parent 6a1a0d977a
commit 51e75cf59d
11 changed files with 199 additions and 4 deletions

View File

@@ -42,6 +42,17 @@ ZHIPUAI_API_BASE = "https://open.bigmodel.cn/api/paas/v4/chat/completions"
@contextmanager
def connect_sse(client: Any, method: str, url: str, **kwargs: Any) -> Iterator:
"""Context manager for connecting to an SSE stream.
Args:
client: The HTTP client.
method: The HTTP method.
url: The URL.
**kwargs: Additional keyword arguments.
Yields:
The event source.
"""
from httpx_sse import EventSource
with client.stream(method, url, **kwargs) as response:
@@ -52,6 +63,17 @@ def connect_sse(client: Any, method: str, url: str, **kwargs: Any) -> Iterator:
async def aconnect_sse(
client: Any, method: str, url: str, **kwargs: Any
) -> AsyncIterator:
"""Async context manager for connecting to an SSE stream.
Args:
client: The HTTP client.
method: The HTTP method.
url: The URL.
**kwargs: Additional keyword arguments.
Yields:
The event source.
"""
from httpx_sse import EventSource
async with client.stream(method, url, **kwargs) as response:
@@ -59,7 +81,9 @@ async def aconnect_sse(
def _get_jwt_token(api_key: str) -> str:
"""Gets JWT token for ZhipuAI API, see 'https://open.bigmodel.cn/dev/api#nosdk'.
"""Gets JWT token for ZhipuAI API.
See 'https://open.bigmodel.cn/dev/api#nosdk'.
Args:
api_key: The API key for ZhipuAI API.