Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
SreejanPersonal authored Nov 7, 2024
1 parent a34b8de commit 3a42978
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] - 2024-11-07
## [0.1.1] - 2024-11-08
### Added
- Updated the README file for better visual understanding.

### Fixed
- Resolved bugs in the streaming functionality.

## [0.1.0] - 2024-11-07
### Added
- Initial release

Expand Down
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Python Versions](https://img.shields.io/pypi/pyversions/openai-unofficial.svg)](https://pypi.org/project/openai-unofficial/)
[![Downloads](https://static.pepy.tech/badge/openai-unofficial)](https://pepy.tech/project/openai-unofficial)

An unofficial Free & Unlimited Python SDK for the OpenAI API, providing seamless integration and easy-to-use methods for interacting with OpenAI's latest powerful AI models, including GPT-4o (Including gpt-4o-audio-preview & gpt-4o-realtime-preview Models), GPT-4, GPT-3.5 Turbo, DALL·E 3, Whisper & Text-to-Speech (TTS) models
An Free & Unlimited unofficial Python SDK for the OpenAI API, providing seamless integration and easy-to-use methods for interacting with OpenAI's latest powerful AI models, including GPT-4o (Including gpt-4o-audio-preview & gpt-4o-realtime-preview Models), GPT-4, GPT-3.5 Turbo, DALL·E 3, Whisper & Text-to-Speech (TTS) models for Free

## Table of Contents

Expand Down Expand Up @@ -98,6 +98,8 @@ print("ChatBot:", response.choices[0].message.content)
### Chat Completion with Image Input

```python
from openai_unofficial import OpenAIUnofficial

client = OpenAIUnofficial()
response = client.chat.completions.create(
messages=[{
Expand All @@ -117,6 +119,23 @@ response = client.chat.completions.create(
print("Response:", response.choices[0].message.content)
```

### Streaming Chat Completion

```python
from openai_unofficial import OpenAIUnofficial

client = OpenAIUnofficial()
completion_stream = client.chat.completions.create(
messages=[{"role": "user", "content": "Write a short story in 3 sentences."}],
model="gpt-4o-mini-2024-07-18",
stream=True
)
for chunk in completion_stream:
content = chunk.choices[0].delta.content
if content:
print(content, end='', flush=True)
```

### Audio Generation with TTS Model

```python
Expand Down Expand Up @@ -247,4 +266,4 @@ Here's a partial list of models that the SDK currently supports. For Complete li
- `text-embedding-3-small`
- `text-embedding-3-large`

---
---
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "openai-unofficial"
version = "0.1.0"
version = "0.1.1"
authors = [
{ name="DevsDoCode", email="[email protected]" },
]
Expand Down
2 changes: 1 addition & 1 deletion src/openai_unofficial/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .main import OpenAIUnofficial

__version__ = "0.1.0"
__version__ = "0.1.1"
__all__ = ["OpenAIUnofficial"]
3 changes: 1 addition & 2 deletions src/openai_unofficial/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ def _handle_streaming_response(self, response: requests.Response) -> Iterator[Ch
line_str = line_str[len('data: '):]
data = json.loads(line_str)
yield ChatCompletionChunk(data)
except json.JSONDecodeError as e:
logger.warning(f"Failed to parse streaming response: {e}")
except:
continue

class Audio:
Expand Down

0 comments on commit 3a42978

Please sign in to comment.