Skip to content

Commit

Permalink
fix: housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmogBaku committed May 17, 2024
1 parent 289947b commit d1519ad
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 8 additions & 8 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
```

Expand Down Expand Up @@ -77,7 +77,7 @@ This is useful for debugging, when you first save the stream to an array and the

**Arguments**:

- `log`:
- `log`:

<a id="stream_processing"></a>

Expand Down Expand Up @@ -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]]
```
Expand Down Expand Up @@ -177,7 +177,7 @@ function in the func attribute).

**Arguments**:

- `func`:
- `func`:

<a id="fn_dispatcher.dispatch_yielded_functions_with_args"></a>

Expand All @@ -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**:
Expand Down Expand Up @@ -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]]
```

Expand Down
2 changes: 1 addition & 1 deletion openai_streaming/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .stream_processing import process_response
from .decorator import openai_streaming_function
from .stream_processing import process_response
2 changes: 1 addition & 1 deletion openai_streaming/struct/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .handler import process_struct_response, Terminate, BaseHandler
from .handler import process_struct_response, Terminate, BaseHandler
1 change: 1 addition & 0 deletions openai_streaming/struct/yaml_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import List, Dict, Tuple, Generator, Optional

from json_streamer import Parser, ParseState


Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"}]
license = {text = "MIT"}
authors = [{ name = "Almog Baku", email = "[email protected]" }]
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",
Expand Down
5 changes: 2 additions & 3 deletions tests/example_struct.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 2 additions & 4 deletions tests/test_with_struct.py
Original file line number Diff line number Diff line change
@@ -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 = '...'
Expand Down

0 comments on commit d1519ad

Please sign in to comment.