Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed May 16, 2024
1 parent 4522cd2 commit 16ba39f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
Types:

```python
from groq.types import EmbeddingCreateResponse
from groq.types import Embeddings
```

Methods:

- <code title="post /openai/v1/embeddings">client.embeddings.<a href="./src/groq/resources/embeddings.py">create</a>(\*\*<a href="src/groq/types/embedding_create_params.py">params</a>) -> <a href="./src/groq/types/embedding_create_response.py">EmbeddingCreateResponse</a></code>
- <code title="post /openai/v1/embeddings">client.embeddings.<a href="./src/groq/resources/embeddings.py">create</a>(\*\*<a href="src/groq/types/embedding_create_params.py">params</a>) -> <a href="./src/groq/types/embeddings.py">Embeddings</a></code>

# Chat

Expand Down
10 changes: 5 additions & 5 deletions src/groq/resources/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from .._base_client import (
make_request_options,
)
from ..types.embedding_create_response import EmbeddingCreateResponse
from ..types.embeddings import Embeddings

__all__ = ["EmbeddingsResource", "AsyncEmbeddingsResource"]

Expand Down Expand Up @@ -52,7 +52,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> EmbeddingCreateResponse:
) -> Embeddings:
"""
Creates an embedding vector representing the input text.
Expand Down Expand Up @@ -94,7 +94,7 @@ def create(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=EmbeddingCreateResponse,
cast_to=Embeddings,
)


Expand All @@ -121,7 +121,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> EmbeddingCreateResponse:
) -> Embeddings:
"""
Creates an embedding vector representing the input text.
Expand Down Expand Up @@ -163,7 +163,7 @@ async def create(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=EmbeddingCreateResponse,
cast_to=Embeddings,
)


Expand Down
2 changes: 1 addition & 1 deletion src/groq/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from .model import Model as Model
from .embeddings import Embeddings as Embeddings
from .model_list import ModelList as ModelList
from .translation import Translation as Translation
from .embedding_create_params import EmbeddingCreateParams as EmbeddingCreateParams
from .embedding_create_response import EmbeddingCreateResponse as EmbeddingCreateResponse
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from .._models import BaseModel

__all__ = ["EmbeddingCreateResponse", "Data", "Usage"]
__all__ = ["Embeddings", "Data", "Usage"]


class Data(BaseModel):
Expand All @@ -31,7 +31,7 @@ class Usage(BaseModel):
"""The total number of tokens used by the request."""


class EmbeddingCreateResponse(BaseModel):
class Embeddings(BaseModel):
data: List[Data]
"""The list of embeddings generated by the model."""

Expand Down
18 changes: 9 additions & 9 deletions tests/api_resources/test_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pytest

from groq import Groq, AsyncGroq
from groq.types import EmbeddingCreateResponse
from groq.types import Embeddings
from tests.utils import assert_matches_type

base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
Expand All @@ -23,7 +23,7 @@ def test_method_create(self, client: Groq) -> None:
input="The quick brown fox jumped over the lazy dog",
model="nomic-embed-text-v1.5",
)
assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"])
assert_matches_type(Embeddings, embedding, path=["response"])

@parametrize
def test_method_create_with_all_params(self, client: Groq) -> None:
Expand All @@ -34,7 +34,7 @@ def test_method_create_with_all_params(self, client: Groq) -> None:
encoding_format="float",
user="string",
)
assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"])
assert_matches_type(Embeddings, embedding, path=["response"])

@parametrize
def test_raw_response_create(self, client: Groq) -> None:
Expand All @@ -46,7 +46,7 @@ def test_raw_response_create(self, client: Groq) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
embedding = response.parse()
assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"])
assert_matches_type(Embeddings, embedding, path=["response"])

@parametrize
def test_streaming_response_create(self, client: Groq) -> None:
Expand All @@ -58,7 +58,7 @@ def test_streaming_response_create(self, client: Groq) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

embedding = response.parse()
assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"])
assert_matches_type(Embeddings, embedding, path=["response"])

assert cast(Any, response.is_closed) is True

Expand All @@ -72,7 +72,7 @@ async def test_method_create(self, async_client: AsyncGroq) -> None:
input="The quick brown fox jumped over the lazy dog",
model="nomic-embed-text-v1.5",
)
assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"])
assert_matches_type(Embeddings, embedding, path=["response"])

@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncGroq) -> None:
Expand All @@ -83,7 +83,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncGroq) -> N
encoding_format="float",
user="string",
)
assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"])
assert_matches_type(Embeddings, embedding, path=["response"])

@parametrize
async def test_raw_response_create(self, async_client: AsyncGroq) -> None:
Expand All @@ -95,7 +95,7 @@ async def test_raw_response_create(self, async_client: AsyncGroq) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
embedding = await response.parse()
assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"])
assert_matches_type(Embeddings, embedding, path=["response"])

@parametrize
async def test_streaming_response_create(self, async_client: AsyncGroq) -> None:
Expand All @@ -107,6 +107,6 @@ async def test_streaming_response_create(self, async_client: AsyncGroq) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

embedding = await response.parse()
assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"])
assert_matches_type(Embeddings, embedding, path=["response"])

assert cast(Any, response.is_closed) is True

0 comments on commit 16ba39f

Please sign in to comment.