diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml
index 5ad732f..4adb429 100644
--- a/.github/workflows/publish.yaml
+++ b/.github/workflows/publish.yaml
@@ -16,6 +16,8 @@ jobs:
name: "Run tests"
runs-on: ubuntu-latest
steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
- name: Test
uses: ./.github/workflows/test.yaml
version:
diff --git a/docs/reference.md b/docs/reference.md
index 5a3e892..3eddae1 100644
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -49,7 +49,7 @@ Your function with additional attribute `openai_schema`
```python
async def stream_to_log(
- response: Union[Iterator[OAIResponse], AsyncIterator[OAIResponse]]
+ response: Union[Iterator[OAIResponse], AsyncIterator[OAIResponse]]
) -> List[OAIResponse]
```
@@ -77,7 +77,7 @@ This is useful for debugging, when you first save the stream to an array and the
**Arguments**:
-- `log`:
+- `log`:
@@ -134,7 +134,7 @@ The difference between the current dictionary and the previous one
async def process_response(
response: OAIResponse,
content_func: Optional[Callable[[AsyncGenerator[str, None]],
- Awaitable[None]]] = None,
+ Awaitable[None]]] = None,
funcs: Optional[List[Callable[[], Awaitable[None]]]] = None,
self: Optional = None) -> Tuple[Set[str], Dict[str, Any]]
```
@@ -177,7 +177,7 @@ function in the func attribute).
**Arguments**:
-- `func`:
+- `func`:
@@ -198,7 +198,7 @@ Dispatches function calls from a generator that yields function names and argume
- `gen`: The generator that yields function names and arguments
- `funcs`: The functions to dispatch to
- `dict_preprocessor`: A function that takes a function name and a dictionary of arguments and returns a new
-dictionary of arguments
+ dictionary of arguments
- `self`: An optional self argument to pass to the functions
**Returns**:
@@ -267,9 +267,9 @@ Called when the parsing was terminated
```python
async def process_struct_response(
- response: OAIResponse,
- handler: BaseHandler,
- output_serialization: OutputSerialization = "json"
+ response: OAIResponse,
+ handler: BaseHandler,
+ output_serialization: OutputSerialization = "json"
) -> Tuple[Optional[Union[TModel, Terminate]], Dict[str, Any]]
```
diff --git a/openai_streaming/__init__.py b/openai_streaming/__init__.py
index 8949458..d140ca3 100644
--- a/openai_streaming/__init__.py
+++ b/openai_streaming/__init__.py
@@ -1,2 +1,2 @@
-from .stream_processing import process_response
from .decorator import openai_streaming_function
+from .stream_processing import process_response
diff --git a/openai_streaming/struct/__init__.py b/openai_streaming/struct/__init__.py
index 699f327..e96f566 100644
--- a/openai_streaming/struct/__init__.py
+++ b/openai_streaming/struct/__init__.py
@@ -1 +1 @@
-from .handler import process_struct_response, Terminate, BaseHandler
\ No newline at end of file
+from .handler import process_struct_response, Terminate, BaseHandler
diff --git a/openai_streaming/struct/yaml_parser.py b/openai_streaming/struct/yaml_parser.py
index 4e37ad4..ef3a765 100644
--- a/openai_streaming/struct/yaml_parser.py
+++ b/openai_streaming/struct/yaml_parser.py
@@ -1,4 +1,5 @@
from typing import List, Dict, Tuple, Generator, Optional
+
from json_streamer import Parser, ParseState
diff --git a/pyproject.toml b/pyproject.toml
index d61ae91..183c3f1 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -6,11 +6,11 @@ build-backend = "setuptools.build_meta"
name = "openai-streaming"
version = "0.0.0-dev"
description = "Work with OpenAI's streaming API at ease, with Python generators"
-authors = [{name = "Almog Baku", email = "almog.baku@gmail.com"}]
-license = {text = "MIT"}
+authors = [{ name = "Almog Baku", email = "almog.baku@gmail.com" }]
+license = { text = "MIT" }
readme = "README.md"
keywords = ["openai", "gpt", "llm", "streaming", "stream", "generator"]
-dependencies= [
+dependencies = [
"openai>=1.14.0,<2.0.0",
"json-streamer>=0.1.0,<0.2.0",
"pydantic>=2.0.2,<3.0.0",
diff --git a/tests/example_struct.py b/tests/example_struct.py
index 95f92a3..8fb33d7 100644
--- a/tests/example_struct.py
+++ b/tests/example_struct.py
@@ -1,12 +1,11 @@
+import asyncio
import os
from time import sleep
+from typing import Optional, List
from openai import AsyncOpenAI
-import asyncio
-
from pydantic import BaseModel
-from typing import Optional, List
from openai_streaming.struct import BaseHandler, process_struct_response, Terminate
# Initialize OpenAI Client
diff --git a/tests/test_with_struct.py b/tests/test_with_struct.py
index c4fb9d5..5b02143 100644
--- a/tests/test_with_struct.py
+++ b/tests/test_with_struct.py
@@ -1,15 +1,13 @@
import json
import unittest
from os.path import dirname
-
-import openai
+from typing import Dict, Generator, Optional, List
from unittest.mock import patch, AsyncMock
+import openai
from openai import BaseModel
from openai.types.chat import ChatCompletionChunk
-from typing import Dict, Generator, Optional, List
-
from openai_streaming.struct import Terminate, BaseHandler, process_struct_response
openai.api_key = '...'