Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
meorphis committed Feb 21, 2024
2 parents 153744e + 9638e4f commit a51d398
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: CI
on:
push:
branches:
- main
- stainless
pull_request:
branches:
- main
- stainless

jobs:
lint:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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`

Expand Down
2 changes: 1 addition & 1 deletion examples/chat_completion_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from groq import AsyncGroq


async def main():
async def main() -> None:
client = AsyncGroq()

chat_completion = await client.chat.completions.create(
Expand Down
2 changes: 1 addition & 1 deletion examples/chat_completion_async_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from groq import AsyncGroq


async def main():
async def main() -> None:
client = AsyncGroq()

stream = await client.chat.completions.create(
Expand Down
21 changes: 11 additions & 10 deletions src/groqcloud/lib/chat_completion_chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,34 +70,35 @@ 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


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

0 comments on commit a51d398

Please sign in to comment.