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): update via SDK Studio #43

Merged
merged 1 commit into from
May 15, 2024
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
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 Embeddings
from groq.types import CreateEmbeddingResponse, Embedding, Usage
```

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/embeddings.py">Embeddings</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/create_embedding_response.py">CreateEmbeddingResponse</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.embeddings import Embeddings
from ..types.create_embedding_response import CreateEmbeddingResponse

__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,
) -> Embeddings:
) -> CreateEmbeddingResponse:
"""
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=Embeddings,
cast_to=CreateEmbeddingResponse,
)


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,
) -> Embeddings:
) -> CreateEmbeddingResponse:
"""
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=Embeddings,
cast_to=CreateEmbeddingResponse,
)


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

from .model import Model as Model
from .embeddings import Embeddings as Embeddings
from .embedding import Embedding as Embedding
from .model_list import ModelList as ModelList
from .translation import Translation as Translation
from .embedding_create_params import EmbeddingCreateParams as EmbeddingCreateParams
from .create_embedding_response import CreateEmbeddingResponse as CreateEmbeddingResponse
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List, Union
from typing import List
from typing_extensions import Literal

from .._models import BaseModel
from .embedding import Embedding

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


class Data(BaseModel):
embedding: Union[List[float], str]
"""The embedding vector, which is a list of floats.

The length of vector depends on the model as listed in the
[embedding guide](/docs/guides/embeddings).
"""

index: int
"""The index of the embedding in the list of embeddings."""

object: Literal["embedding"]
"""The object type, which is always "embedding"."""
__all__ = ["CreateEmbeddingResponse", "Usage"]


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


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

model: str
Expand Down
23 changes: 23 additions & 0 deletions src/groq/types/embedding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List, Union
from typing_extensions import Literal

from .._models import BaseModel

__all__ = ["Embedding"]


class Embedding(BaseModel):
embedding: Union[List[float], str]
"""The embedding vector, which is a list of floats.

The length of vector depends on the model as listed in the
[embedding guide](/docs/guides/embeddings).
"""

index: int
"""The index of the embedding in the list of embeddings."""

object: Literal["embedding"]
"""The object type, which is always "embedding"."""
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 Embeddings
from groq.types import CreateEmbeddingResponse
from tests.utils import assert_matches_type

base_url = os.environ.get("TEST_API_BASE_URL", "https://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(Embeddings, embedding, path=["response"])
assert_matches_type(CreateEmbeddingResponse, 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(Embeddings, embedding, path=["response"])
assert_matches_type(CreateEmbeddingResponse, 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(Embeddings, embedding, path=["response"])
assert_matches_type(CreateEmbeddingResponse, 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(Embeddings, embedding, path=["response"])
assert_matches_type(CreateEmbeddingResponse, 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(Embeddings, embedding, path=["response"])
assert_matches_type(CreateEmbeddingResponse, 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(Embeddings, embedding, path=["response"])
assert_matches_type(CreateEmbeddingResponse, 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(Embeddings, embedding, path=["response"])
assert_matches_type(CreateEmbeddingResponse, 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(Embeddings, embedding, path=["response"])
assert_matches_type(CreateEmbeddingResponse, embedding, path=["response"])

assert cast(Any, response.is_closed) is True