Skip to content

Commit c72a478

Browse files
docs(api): updates to API spec (#223)
1 parent 2ad9218 commit c72a478

5 files changed

Lines changed: 129 additions & 27 deletions

File tree

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 30
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-57a138ff1e8940e627dd0108eb14c25bbeacd70e5f1106f8abd796cba6c51882.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-50d65469557b50b46f15db6f5da3b81ed5c1f551e5eab64ded93e46eafaa3696.yml

src/writerai/resources/chat.py

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@ def chat(
115115
automatically choose the best tool, `none` disables tool calling. You can also
116116
pass a specific previously defined function.
117117
118-
tools: An array of tools described to the model using JSON schema that the model can
119-
use to generate responses. You can define your own functions or use the built-in
120-
`graph` or `llm` tools.
118+
tools: An array containing tool definitions for tools that the model can use to
119+
generate responses. The tool definitions use JSON schema. You can define your
120+
own functions or use one of the built-in `graph`, `llm`, or `vision` tools. Note
121+
that you can only use one built-in tool type in the array (only one of `graph`,
122+
`llm`, or `vision`).
121123
122124
top_p: Sets the threshold for "nucleus sampling," a technique to focus the model's
123125
token generation on the most likely subset of tokens. Only tokens with
@@ -198,9 +200,11 @@ def chat(
198200
automatically choose the best tool, `none` disables tool calling. You can also
199201
pass a specific previously defined function.
200202
201-
tools: An array of tools described to the model using JSON schema that the model can
202-
use to generate responses. You can define your own functions or use the built-in
203-
`graph` or `llm` tools.
203+
tools: An array containing tool definitions for tools that the model can use to
204+
generate responses. The tool definitions use JSON schema. You can define your
205+
own functions or use one of the built-in `graph`, `llm`, or `vision` tools. Note
206+
that you can only use one built-in tool type in the array (only one of `graph`,
207+
`llm`, or `vision`).
204208
205209
top_p: Sets the threshold for "nucleus sampling," a technique to focus the model's
206210
token generation on the most likely subset of tokens. Only tokens with
@@ -281,9 +285,11 @@ def chat(
281285
automatically choose the best tool, `none` disables tool calling. You can also
282286
pass a specific previously defined function.
283287
284-
tools: An array of tools described to the model using JSON schema that the model can
285-
use to generate responses. You can define your own functions or use the built-in
286-
`graph` or `llm` tools.
288+
tools: An array containing tool definitions for tools that the model can use to
289+
generate responses. The tool definitions use JSON schema. You can define your
290+
own functions or use one of the built-in `graph`, `llm`, or `vision` tools. Note
291+
that you can only use one built-in tool type in the array (only one of `graph`,
292+
`llm`, or `vision`).
287293
288294
top_p: Sets the threshold for "nucleus sampling," a technique to focus the model's
289295
token generation on the most likely subset of tokens. Only tokens with
@@ -435,9 +441,11 @@ async def chat(
435441
automatically choose the best tool, `none` disables tool calling. You can also
436442
pass a specific previously defined function.
437443
438-
tools: An array of tools described to the model using JSON schema that the model can
439-
use to generate responses. You can define your own functions or use the built-in
440-
`graph` or `llm` tools.
444+
tools: An array containing tool definitions for tools that the model can use to
445+
generate responses. The tool definitions use JSON schema. You can define your
446+
own functions or use one of the built-in `graph`, `llm`, or `vision` tools. Note
447+
that you can only use one built-in tool type in the array (only one of `graph`,
448+
`llm`, or `vision`).
441449
442450
top_p: Sets the threshold for "nucleus sampling," a technique to focus the model's
443451
token generation on the most likely subset of tokens. Only tokens with
@@ -518,9 +526,11 @@ async def chat(
518526
automatically choose the best tool, `none` disables tool calling. You can also
519527
pass a specific previously defined function.
520528
521-
tools: An array of tools described to the model using JSON schema that the model can
522-
use to generate responses. You can define your own functions or use the built-in
523-
`graph` or `llm` tools.
529+
tools: An array containing tool definitions for tools that the model can use to
530+
generate responses. The tool definitions use JSON schema. You can define your
531+
own functions or use one of the built-in `graph`, `llm`, or `vision` tools. Note
532+
that you can only use one built-in tool type in the array (only one of `graph`,
533+
`llm`, or `vision`).
524534
525535
top_p: Sets the threshold for "nucleus sampling," a technique to focus the model's
526536
token generation on the most likely subset of tokens. Only tokens with
@@ -601,9 +611,11 @@ async def chat(
601611
automatically choose the best tool, `none` disables tool calling. You can also
602612
pass a specific previously defined function.
603613
604-
tools: An array of tools described to the model using JSON schema that the model can
605-
use to generate responses. You can define your own functions or use the built-in
606-
`graph` or `llm` tools.
614+
tools: An array containing tool definitions for tools that the model can use to
615+
generate responses. The tool definitions use JSON schema. You can define your
616+
own functions or use one of the built-in `graph`, `llm`, or `vision` tools. Note
617+
that you can only use one built-in tool type in the array (only one of `graph`,
618+
`llm`, or `vision`).
607619
608620
top_p: Sets the threshold for "nucleus sampling," a technique to focus the model's
609621
token generation on the most likely subset of tokens. Only tokens with

src/writerai/types/chat_chat_params.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ class ChatChatParamsBase(TypedDict, total=False):
7777

7878
tools: Iterable[ToolParam]
7979
"""
80-
An array of tools described to the model using JSON schema that the model can
81-
use to generate responses. You can define your own functions or use the built-in
82-
`graph` or `llm` tools.
80+
An array containing tool definitions for tools that the model can use to
81+
generate responses. The tool definitions use JSON schema. You can define your
82+
own functions or use one of the built-in `graph`, `llm`, or `vision` tools. Note
83+
that you can only use one built-in tool type in the array (only one of `graph`,
84+
`llm`, or `vision`).
8385
"""
8486

8587
top_p: float

src/writerai/types/shared/tool_param.py

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@
77
from ..._models import BaseModel
88
from .function_definition import FunctionDefinition
99

10-
__all__ = ["ToolParam", "FunctionTool", "GraphTool", "GraphToolFunction", "LlmTool", "LlmToolFunction"]
10+
__all__ = [
11+
"ToolParam",
12+
"FunctionTool",
13+
"GraphTool",
14+
"GraphToolFunction",
15+
"LlmTool",
16+
"LlmToolFunction",
17+
"VisionTool",
18+
"VisionToolFunction",
19+
"VisionToolFunctionVariable",
20+
]
1121

1222

1323
class FunctionTool(BaseModel):
@@ -53,4 +63,39 @@ class LlmTool(BaseModel):
5363
"""The type of tool."""
5464

5565

56-
ToolParam: TypeAlias = Annotated[Union[FunctionTool, GraphTool, LlmTool], PropertyInfo(discriminator="type")]
66+
class VisionToolFunctionVariable(BaseModel):
67+
file_id: str
68+
"""The File ID of the image to be analyzed.
69+
70+
The file must be uploaded to the Writer platform before you use it with the
71+
Vision tool.
72+
"""
73+
74+
name: str
75+
"""The name of the file variable.
76+
77+
You must reference this name in the `message.content` field of the request to
78+
the chat completions endpoint. Use double curly braces (`{{}}`) to reference the
79+
file. For example,
80+
`Describe the difference between the image {{image_1}} and the image {{image_2}}`.
81+
"""
82+
83+
84+
class VisionToolFunction(BaseModel):
85+
model: str
86+
"""The model to be used for image analysis. Must be `palmyra-vision`."""
87+
88+
variables: List[VisionToolFunctionVariable]
89+
90+
91+
class VisionTool(BaseModel):
92+
function: VisionToolFunction
93+
"""A tool that uses Palmyra Vision to analyze images."""
94+
95+
type: Literal["vision"]
96+
"""The type of tool."""
97+
98+
99+
ToolParam: TypeAlias = Annotated[
100+
Union[FunctionTool, GraphTool, LlmTool, VisionTool], PropertyInfo(discriminator="type")
101+
]

src/writerai/types/shared_params/tool_param.py

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,22 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Union
5+
from typing import List, Union, Iterable
66
from typing_extensions import Literal, Required, TypeAlias, TypedDict
77

88
from .function_definition import FunctionDefinition
99

10-
__all__ = ["ToolParam", "FunctionTool", "GraphTool", "GraphToolFunction", "LlmTool", "LlmToolFunction"]
10+
__all__ = [
11+
"ToolParam",
12+
"FunctionTool",
13+
"GraphTool",
14+
"GraphToolFunction",
15+
"LlmTool",
16+
"LlmToolFunction",
17+
"VisionTool",
18+
"VisionToolFunction",
19+
"VisionToolFunctionVariable",
20+
]
1121

1222

1323
class FunctionTool(TypedDict, total=False):
@@ -53,4 +63,37 @@ class LlmTool(TypedDict, total=False):
5363
"""The type of tool."""
5464

5565

56-
ToolParam: TypeAlias = Union[FunctionTool, GraphTool, LlmTool]
66+
class VisionToolFunctionVariable(TypedDict, total=False):
67+
file_id: Required[str]
68+
"""The File ID of the image to be analyzed.
69+
70+
The file must be uploaded to the Writer platform before you use it with the
71+
Vision tool.
72+
"""
73+
74+
name: Required[str]
75+
"""The name of the file variable.
76+
77+
You must reference this name in the `message.content` field of the request to
78+
the chat completions endpoint. Use double curly braces (`{{}}`) to reference the
79+
file. For example,
80+
`Describe the difference between the image {{image_1}} and the image {{image_2}}`.
81+
"""
82+
83+
84+
class VisionToolFunction(TypedDict, total=False):
85+
model: Required[str]
86+
"""The model to be used for image analysis. Must be `palmyra-vision`."""
87+
88+
variables: Required[Iterable[VisionToolFunctionVariable]]
89+
90+
91+
class VisionTool(TypedDict, total=False):
92+
function: Required[VisionToolFunction]
93+
"""A tool that uses Palmyra Vision to analyze images."""
94+
95+
type: Required[Literal["vision"]]
96+
"""The type of tool."""
97+
98+
99+
ToolParam: TypeAlias = Union[FunctionTool, GraphTool, LlmTool, VisionTool]

0 commit comments

Comments
 (0)