Skip to content
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 api.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,4 @@ from writerai.types import VisionRequest, VisionResponse

Methods:

- <code title="post /v1/vision">client.vision.<a href="./src/writerai/resources/vision.py">analyze_images</a>(\*\*<a href="src/writerai/types/vision_analyze_images_params.py">params</a>) -> <a href="./src/writerai/types/vision_response.py">VisionResponse</a></code>
- <code title="post /v1/vision">client.vision.<a href="./src/writerai/resources/vision.py">analyze</a>(\*\*<a href="src/writerai/types/vision_analyze_params.py">params</a>) -> <a href="./src/writerai/types/vision_response.py">VisionResponse</a></code>
30 changes: 15 additions & 15 deletions src/writerai/resources/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import httpx

from ..types import vision_analyze_images_params
from ..types import vision_analyze_params
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from .._utils import (
maybe_transform,
Expand Down Expand Up @@ -46,12 +46,12 @@ def with_streaming_response(self) -> VisionResourceWithStreamingResponse:
"""
return VisionResourceWithStreamingResponse(self)

def analyze_images(
def analyze(
self,
*,
model: str,
prompt: str,
variables: Iterable[vision_analyze_images_params.Variable],
variables: Iterable[vision_analyze_params.Variable],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -86,7 +86,7 @@ def analyze_images(
"prompt": prompt,
"variables": variables,
},
vision_analyze_images_params.VisionAnalyzeImagesParams,
vision_analyze_params.VisionAnalyzeParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
Expand Down Expand Up @@ -115,12 +115,12 @@ def with_streaming_response(self) -> AsyncVisionResourceWithStreamingResponse:
"""
return AsyncVisionResourceWithStreamingResponse(self)

async def analyze_images(
async def analyze(
self,
*,
model: str,
prompt: str,
variables: Iterable[vision_analyze_images_params.Variable],
variables: Iterable[vision_analyze_params.Variable],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -155,7 +155,7 @@ async def analyze_images(
"prompt": prompt,
"variables": variables,
},
vision_analyze_images_params.VisionAnalyzeImagesParams,
vision_analyze_params.VisionAnalyzeParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
Expand All @@ -168,33 +168,33 @@ class VisionResourceWithRawResponse:
def __init__(self, vision: VisionResource) -> None:
self._vision = vision

self.analyze_images = to_raw_response_wrapper(
vision.analyze_images,
self.analyze = to_raw_response_wrapper(
vision.analyze,
)


class AsyncVisionResourceWithRawResponse:
def __init__(self, vision: AsyncVisionResource) -> None:
self._vision = vision

self.analyze_images = async_to_raw_response_wrapper(
vision.analyze_images,
self.analyze = async_to_raw_response_wrapper(
vision.analyze,
)


class VisionResourceWithStreamingResponse:
def __init__(self, vision: VisionResource) -> None:
self._vision = vision

self.analyze_images = to_streamed_response_wrapper(
vision.analyze_images,
self.analyze = to_streamed_response_wrapper(
vision.analyze,
)


class AsyncVisionResourceWithStreamingResponse:
def __init__(self, vision: AsyncVisionResource) -> None:
self._vision = vision

self.analyze_images = async_to_streamed_response_wrapper(
vision.analyze_images,
self.analyze = async_to_streamed_response_wrapper(
vision.analyze,
)
2 changes: 1 addition & 1 deletion src/writerai/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
from .graph_question_params import GraphQuestionParams as GraphQuestionParams
from .graph_update_response import GraphUpdateResponse as GraphUpdateResponse
from .tool_parse_pdf_params import ToolParsePdfParams as ToolParsePdfParams
from .vision_analyze_params import VisionAnalyzeParams as VisionAnalyzeParams
from .chat_completion_choice import ChatCompletionChoice as ChatCompletionChoice
from .application_list_params import ApplicationListParams as ApplicationListParams
from .chat_completion_message import ChatCompletionMessage as ChatCompletionMessage
from .question_response_chunk import QuestionResponseChunk as QuestionResponseChunk
from .tool_parse_pdf_response import ToolParsePdfResponse as ToolParsePdfResponse
from .completion_create_params import CompletionCreateParams as CompletionCreateParams
from .application_list_response import ApplicationListResponse as ApplicationListResponse
from .vision_analyze_images_params import VisionAnalyzeImagesParams as VisionAnalyzeImagesParams
from .application_retrieve_response import ApplicationRetrieveResponse as ApplicationRetrieveResponse
from .graph_add_file_to_graph_params import GraphAddFileToGraphParams as GraphAddFileToGraphParams
from .application_generate_content_chunk import ApplicationGenerateContentChunk as ApplicationGenerateContentChunk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from typing import Iterable
from typing_extensions import Required, TypedDict

__all__ = ["VisionAnalyzeImagesParams", "Variable"]
__all__ = ["VisionAnalyzeParams", "Variable"]


class VisionAnalyzeImagesParams(TypedDict, total=False):
class VisionAnalyzeParams(TypedDict, total=False):
model: Required[str]
"""The model to be used for image analysis.

Expand Down
24 changes: 12 additions & 12 deletions tests/api_resources/test_vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class TestVision:
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])

@parametrize
def test_method_analyze_images(self, client: Writer) -> None:
vision = client.vision.analyze_images(
def test_method_analyze(self, client: Writer) -> None:
vision = client.vision.analyze(
model="palmyra-vision",
prompt="Describe the difference between the image {{image_1}} and the image {{image_2}}.",
variables=[
Expand All @@ -36,8 +36,8 @@ def test_method_analyze_images(self, client: Writer) -> None:
assert_matches_type(VisionResponse, vision, path=["response"])

@parametrize
def test_raw_response_analyze_images(self, client: Writer) -> None:
response = client.vision.with_raw_response.analyze_images(
def test_raw_response_analyze(self, client: Writer) -> None:
response = client.vision.with_raw_response.analyze(
model="palmyra-vision",
prompt="Describe the difference between the image {{image_1}} and the image {{image_2}}.",
variables=[
Expand All @@ -58,8 +58,8 @@ def test_raw_response_analyze_images(self, client: Writer) -> None:
assert_matches_type(VisionResponse, vision, path=["response"])

@parametrize
def test_streaming_response_analyze_images(self, client: Writer) -> None:
with client.vision.with_streaming_response.analyze_images(
def test_streaming_response_analyze(self, client: Writer) -> None:
with client.vision.with_streaming_response.analyze(
model="palmyra-vision",
prompt="Describe the difference between the image {{image_1}} and the image {{image_2}}.",
variables=[
Expand All @@ -86,8 +86,8 @@ class TestAsyncVision:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])

@parametrize
async def test_method_analyze_images(self, async_client: AsyncWriter) -> None:
vision = await async_client.vision.analyze_images(
async def test_method_analyze(self, async_client: AsyncWriter) -> None:
vision = await async_client.vision.analyze(
model="palmyra-vision",
prompt="Describe the difference between the image {{image_1}} and the image {{image_2}}.",
variables=[
Expand All @@ -104,8 +104,8 @@ async def test_method_analyze_images(self, async_client: AsyncWriter) -> None:
assert_matches_type(VisionResponse, vision, path=["response"])

@parametrize
async def test_raw_response_analyze_images(self, async_client: AsyncWriter) -> None:
response = await async_client.vision.with_raw_response.analyze_images(
async def test_raw_response_analyze(self, async_client: AsyncWriter) -> None:
response = await async_client.vision.with_raw_response.analyze(
model="palmyra-vision",
prompt="Describe the difference between the image {{image_1}} and the image {{image_2}}.",
variables=[
Expand All @@ -126,8 +126,8 @@ async def test_raw_response_analyze_images(self, async_client: AsyncWriter) -> N
assert_matches_type(VisionResponse, vision, path=["response"])

@parametrize
async def test_streaming_response_analyze_images(self, async_client: AsyncWriter) -> None:
async with async_client.vision.with_streaming_response.analyze_images(
async def test_streaming_response_analyze(self, async_client: AsyncWriter) -> None:
async with async_client.vision.with_streaming_response.analyze(
model="palmyra-vision",
prompt="Describe the difference between the image {{image_1}} and the image {{image_2}}.",
variables=[
Expand Down