Skip to content

Commit 967073d

Browse files
feat(api): Add Vision endpoint. (#221)
1 parent 886b828 commit 967073d

5 files changed

Lines changed: 31 additions & 31 deletions

File tree

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,4 @@ from writerai.types import VisionRequest, VisionResponse
192192

193193
Methods:
194194

195-
- <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>
195+
- <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>

src/writerai/resources/vision.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import httpx
88

9-
from ..types import vision_analyze_images_params
9+
from ..types import vision_analyze_params
1010
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
1111
from .._utils import (
1212
maybe_transform,
@@ -46,12 +46,12 @@ def with_streaming_response(self) -> VisionResourceWithStreamingResponse:
4646
"""
4747
return VisionResourceWithStreamingResponse(self)
4848

49-
def analyze_images(
49+
def analyze(
5050
self,
5151
*,
5252
model: str,
5353
prompt: str,
54-
variables: Iterable[vision_analyze_images_params.Variable],
54+
variables: Iterable[vision_analyze_params.Variable],
5555
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5656
# The extra values given here take precedence over values defined on the client or passed to this method.
5757
extra_headers: Headers | None = None,
@@ -86,7 +86,7 @@ def analyze_images(
8686
"prompt": prompt,
8787
"variables": variables,
8888
},
89-
vision_analyze_images_params.VisionAnalyzeImagesParams,
89+
vision_analyze_params.VisionAnalyzeParams,
9090
),
9191
options=make_request_options(
9292
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
@@ -115,12 +115,12 @@ def with_streaming_response(self) -> AsyncVisionResourceWithStreamingResponse:
115115
"""
116116
return AsyncVisionResourceWithStreamingResponse(self)
117117

118-
async def analyze_images(
118+
async def analyze(
119119
self,
120120
*,
121121
model: str,
122122
prompt: str,
123-
variables: Iterable[vision_analyze_images_params.Variable],
123+
variables: Iterable[vision_analyze_params.Variable],
124124
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
125125
# The extra values given here take precedence over values defined on the client or passed to this method.
126126
extra_headers: Headers | None = None,
@@ -155,7 +155,7 @@ async def analyze_images(
155155
"prompt": prompt,
156156
"variables": variables,
157157
},
158-
vision_analyze_images_params.VisionAnalyzeImagesParams,
158+
vision_analyze_params.VisionAnalyzeParams,
159159
),
160160
options=make_request_options(
161161
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
@@ -168,33 +168,33 @@ class VisionResourceWithRawResponse:
168168
def __init__(self, vision: VisionResource) -> None:
169169
self._vision = vision
170170

171-
self.analyze_images = to_raw_response_wrapper(
172-
vision.analyze_images,
171+
self.analyze = to_raw_response_wrapper(
172+
vision.analyze,
173173
)
174174

175175

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

180-
self.analyze_images = async_to_raw_response_wrapper(
181-
vision.analyze_images,
180+
self.analyze = async_to_raw_response_wrapper(
181+
vision.analyze,
182182
)
183183

184184

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

189-
self.analyze_images = to_streamed_response_wrapper(
190-
vision.analyze_images,
189+
self.analyze = to_streamed_response_wrapper(
190+
vision.analyze,
191191
)
192192

193193

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

198-
self.analyze_images = async_to_streamed_response_wrapper(
199-
vision.analyze_images,
198+
self.analyze = async_to_streamed_response_wrapper(
199+
vision.analyze,
200200
)

src/writerai/types/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@
4141
from .graph_question_params import GraphQuestionParams as GraphQuestionParams
4242
from .graph_update_response import GraphUpdateResponse as GraphUpdateResponse
4343
from .tool_parse_pdf_params import ToolParsePdfParams as ToolParsePdfParams
44+
from .vision_analyze_params import VisionAnalyzeParams as VisionAnalyzeParams
4445
from .chat_completion_choice import ChatCompletionChoice as ChatCompletionChoice
4546
from .application_list_params import ApplicationListParams as ApplicationListParams
4647
from .chat_completion_message import ChatCompletionMessage as ChatCompletionMessage
4748
from .question_response_chunk import QuestionResponseChunk as QuestionResponseChunk
4849
from .tool_parse_pdf_response import ToolParsePdfResponse as ToolParsePdfResponse
4950
from .completion_create_params import CompletionCreateParams as CompletionCreateParams
5051
from .application_list_response import ApplicationListResponse as ApplicationListResponse
51-
from .vision_analyze_images_params import VisionAnalyzeImagesParams as VisionAnalyzeImagesParams
5252
from .application_retrieve_response import ApplicationRetrieveResponse as ApplicationRetrieveResponse
5353
from .graph_add_file_to_graph_params import GraphAddFileToGraphParams as GraphAddFileToGraphParams
5454
from .application_generate_content_chunk import ApplicationGenerateContentChunk as ApplicationGenerateContentChunk

src/writerai/types/vision_analyze_images_params.py renamed to src/writerai/types/vision_analyze_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
from typing import Iterable
66
from typing_extensions import Required, TypedDict
77

8-
__all__ = ["VisionAnalyzeImagesParams", "Variable"]
8+
__all__ = ["VisionAnalyzeParams", "Variable"]
99

1010

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

tests/api_resources/test_vision.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class TestVision:
1818
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
1919

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

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

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

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

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

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

0 commit comments

Comments
 (0)