Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): Add batch API #191

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 7
configured_endpoints: 15
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/groqcloud%2Fgroqcloud-d1588e103a6ae0234752b8e54a746fb1e4c93a0ee51ede294017bcd4f0ee4ac0.yml
36 changes: 36 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,39 @@ Methods:
- <code title="get /openai/v1/models/{model}">client.models.<a href="./src/groq/resources/models.py">retrieve</a>(model) -> <a href="./src/groq/types/model.py">Model</a></code>
- <code title="get /openai/v1/models">client.models.<a href="./src/groq/resources/models.py">list</a>() -> <a href="./src/groq/types/model_list_response.py">ModelListResponse</a></code>
- <code title="delete /openai/v1/models/{model}">client.models.<a href="./src/groq/resources/models.py">delete</a>(model) -> <a href="./src/groq/types/model_deleted.py">ModelDeleted</a></code>

# Batches

Types:

```python
from groq.types import BatchCreateResponse, BatchRetrieveResponse, BatchListResponse
```

Methods:

- <code title="post /openai/v1/batches">client.batches.<a href="./src/groq/resources/batches.py">create</a>(\*\*<a href="src/groq/types/batch_create_params.py">params</a>) -> <a href="./src/groq/types/batch_create_response.py">BatchCreateResponse</a></code>
- <code title="get /openai/v1/batches/{batch_id}">client.batches.<a href="./src/groq/resources/batches.py">retrieve</a>(batch_id) -> <a href="./src/groq/types/batch_retrieve_response.py">BatchRetrieveResponse</a></code>
- <code title="get /openai/v1/batches">client.batches.<a href="./src/groq/resources/batches.py">list</a>() -> <a href="./src/groq/types/batch_list_response.py">BatchListResponse</a></code>

# Files

Types:

```python
from groq.types import (
FileCreateResponse,
FileListResponse,
FileDeleteResponse,
FileContentResponse,
FileInfoResponse,
)
```

Methods:

- <code title="post /openai/v1/files">client.files.<a href="./src/groq/resources/files.py">create</a>(\*\*<a href="src/groq/types/file_create_params.py">params</a>) -> <a href="./src/groq/types/file_create_response.py">FileCreateResponse</a></code>
- <code title="get /openai/v1/files">client.files.<a href="./src/groq/resources/files.py">list</a>() -> <a href="./src/groq/types/file_list_response.py">FileListResponse</a></code>
- <code title="delete /openai/v1/files/{file_id}">client.files.<a href="./src/groq/resources/files.py">delete</a>(file_id) -> <a href="./src/groq/types/file_delete_response.py">FileDeleteResponse</a></code>
- <code title="get /openai/v1/files/{file_id}/content">client.files.<a href="./src/groq/resources/files.py">content</a>(file_id) -> str</code>
- <code title="get /openai/v1/files/{file_id}">client.files.<a href="./src/groq/resources/files.py">info</a>(file_id) -> <a href="./src/groq/types/file_info_response.py">FileInfoResponse</a></code>
18 changes: 17 additions & 1 deletion src/groq/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
get_async_library,
)
from ._version import __version__
from .resources import models, embeddings
from .resources import files, models, batches, embeddings
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
from ._exceptions import GroqError, APIStatusError
from ._base_client import (
Expand All @@ -43,6 +43,8 @@ class Groq(SyncAPIClient):
embeddings: embeddings.Embeddings
audio: audio.Audio
models: models.Models
batches: batches.Batches
files: files.Files
with_raw_response: GroqWithRawResponse
with_streaming_response: GroqWithStreamedResponse

Expand Down Expand Up @@ -104,6 +106,8 @@ def __init__(
self.embeddings = embeddings.Embeddings(self)
self.audio = audio.Audio(self)
self.models = models.Models(self)
self.batches = batches.Batches(self)
self.files = files.Files(self)
self.with_raw_response = GroqWithRawResponse(self)
self.with_streaming_response = GroqWithStreamedResponse(self)

Expand Down Expand Up @@ -217,6 +221,8 @@ class AsyncGroq(AsyncAPIClient):
embeddings: embeddings.AsyncEmbeddings
audio: audio.AsyncAudio
models: models.AsyncModels
batches: batches.AsyncBatches
files: files.AsyncFiles
with_raw_response: AsyncGroqWithRawResponse
with_streaming_response: AsyncGroqWithStreamedResponse

Expand Down Expand Up @@ -278,6 +284,8 @@ def __init__(
self.embeddings = embeddings.AsyncEmbeddings(self)
self.audio = audio.AsyncAudio(self)
self.models = models.AsyncModels(self)
self.batches = batches.AsyncBatches(self)
self.files = files.AsyncFiles(self)
self.with_raw_response = AsyncGroqWithRawResponse(self)
self.with_streaming_response = AsyncGroqWithStreamedResponse(self)

Expand Down Expand Up @@ -392,6 +400,8 @@ def __init__(self, client: Groq) -> None:
self.embeddings = embeddings.EmbeddingsWithRawResponse(client.embeddings)
self.audio = audio.AudioWithRawResponse(client.audio)
self.models = models.ModelsWithRawResponse(client.models)
self.batches = batches.BatchesWithRawResponse(client.batches)
self.files = files.FilesWithRawResponse(client.files)


class AsyncGroqWithRawResponse:
Expand All @@ -400,6 +410,8 @@ def __init__(self, client: AsyncGroq) -> None:
self.embeddings = embeddings.AsyncEmbeddingsWithRawResponse(client.embeddings)
self.audio = audio.AsyncAudioWithRawResponse(client.audio)
self.models = models.AsyncModelsWithRawResponse(client.models)
self.batches = batches.AsyncBatchesWithRawResponse(client.batches)
self.files = files.AsyncFilesWithRawResponse(client.files)


class GroqWithStreamedResponse:
Expand All @@ -408,6 +420,8 @@ def __init__(self, client: Groq) -> None:
self.embeddings = embeddings.EmbeddingsWithStreamingResponse(client.embeddings)
self.audio = audio.AudioWithStreamingResponse(client.audio)
self.models = models.ModelsWithStreamingResponse(client.models)
self.batches = batches.BatchesWithStreamingResponse(client.batches)
self.files = files.FilesWithStreamingResponse(client.files)


class AsyncGroqWithStreamedResponse:
Expand All @@ -416,6 +430,8 @@ def __init__(self, client: AsyncGroq) -> None:
self.embeddings = embeddings.AsyncEmbeddingsWithStreamingResponse(client.embeddings)
self.audio = audio.AsyncAudioWithStreamingResponse(client.audio)
self.models = models.AsyncModelsWithStreamingResponse(client.models)
self.batches = batches.AsyncBatchesWithStreamingResponse(client.batches)
self.files = files.AsyncFilesWithStreamingResponse(client.files)


Client = Groq
Expand Down
28 changes: 28 additions & 0 deletions src/groq/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
AudioWithStreamingResponse,
AsyncAudioWithStreamingResponse,
)
from .files import (
Files,
AsyncFiles,
FilesWithRawResponse,
AsyncFilesWithRawResponse,
FilesWithStreamingResponse,
AsyncFilesWithStreamingResponse,
)
from .models import (
Models,
AsyncModels,
Expand All @@ -24,6 +32,14 @@
ModelsWithStreamingResponse,
AsyncModelsWithStreamingResponse,
)
from .batches import (
Batches,
AsyncBatches,
BatchesWithRawResponse,
AsyncBatchesWithRawResponse,
BatchesWithStreamingResponse,
AsyncBatchesWithStreamingResponse,
)
from .embeddings import (
Embeddings,
AsyncEmbeddings,
Expand Down Expand Up @@ -58,4 +74,16 @@
"AsyncModelsWithRawResponse",
"ModelsWithStreamingResponse",
"AsyncModelsWithStreamingResponse",
"Batches",
"AsyncBatches",
"BatchesWithRawResponse",
"AsyncBatchesWithRawResponse",
"BatchesWithStreamingResponse",
"AsyncBatchesWithStreamingResponse",
"Files",
"AsyncFiles",
"FilesWithRawResponse",
"AsyncFilesWithRawResponse",
"FilesWithStreamingResponse",
"AsyncFilesWithStreamingResponse",
]
Loading