diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fca066e..dfb911f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,10 +2,10 @@ name: CI on: push: branches: - - main + - stainless pull_request: branches: - - main + - stainless jobs: lint: diff --git a/README.md b/README.md index 449ef18..4f8e12a 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ chat_completion = client.chat.completions.create( ], model="mixtral-8x7b-32768", ) -print(chat_completion.choices_0.message.content) +print(chat_completion.choices[0].message.content) ``` While you can provide an `api_key` keyword argument, @@ -71,7 +71,7 @@ async def main() -> None: ], model="mixtral-8x7b-32768", ) - print(chat_completion.choices_0.message.content) + print(chat_completion.choices[0].message.content) asyncio.run(main()) @@ -261,9 +261,9 @@ completion = response.parse() # get the object that `chat.completions.create()` print(completion.id) ``` -These methods return an [`APIResponse`](https://github.com/groq/groq-python/tree/main/src/groq/_response.py) object. +These methods return an [`APIResponse`](https://github.com/groq/groq-python/tree/stainless/src/groq/_response.py) object. -The async client returns an [`AsyncAPIResponse`](https://github.com/groq/groq-python/tree/main/src/groq/_response.py) with the same structure, the only difference being `await`able methods for reading the response content. +The async client returns an [`AsyncAPIResponse`](https://github.com/groq/groq-python/tree/stainless/src/groq/_response.py) with the same structure, the only difference being `await`able methods for reading the response content. #### `.with_streaming_response` diff --git a/examples/chat_completion_async.py b/examples/chat_completion_async.py index b1f0fde..8e5056d 100644 --- a/examples/chat_completion_async.py +++ b/examples/chat_completion_async.py @@ -3,7 +3,7 @@ from groq import AsyncGroq -async def main(): +async def main() -> None: client = AsyncGroq() chat_completion = await client.chat.completions.create( diff --git a/examples/chat_completion_async_streaming.py b/examples/chat_completion_async_streaming.py index 594d61a..eac7ce9 100644 --- a/examples/chat_completion_async_streaming.py +++ b/examples/chat_completion_async_streaming.py @@ -3,7 +3,7 @@ from groq import AsyncGroq -async def main(): +async def main() -> None: client = AsyncGroq() stream = await client.chat.completions.create( diff --git a/src/groqcloud/lib/chat_completion_chunk.py b/src/groqcloud/lib/chat_completion_chunk.py index 2aabbcf..86c0ffa 100644 --- a/src/groqcloud/lib/chat_completion_chunk.py +++ b/src/groqcloud/lib/chat_completion_chunk.py @@ -70,11 +70,12 @@ class ChoiceDeltaToolCall(BaseModel): class ChoiceDelta(BaseModel): - content: Optional[str] = None + content: str + + role: str function_call: Optional[ChoiceDeltaFunctionCall] = None - role: Optional[str] = None tool_calls: Optional[List[ChoiceDeltaToolCall]] = None @@ -82,22 +83,22 @@ class ChoiceDelta(BaseModel): class Choice(BaseModel): delta: ChoiceDelta - finish_reason: Optional[str] = None + finish_reason: str - index: Optional[int] = None + index: int - logprobs: Optional[ChoiceLogprobs] = None + logprobs: ChoiceLogprobs class ChatCompletionChunk(BaseModel): - id: Optional[str] = None + id: str - choices: Optional[List[Choice]] = None + choices: List[Choice] - created: Optional[int] = None + created: int - model: Optional[str] = None + model: str - object: Optional[str] = None + object: str system_fingerprint: Optional[str] = None