Skip to content

Commit 9654e96

Browse files
committed
Release 3.2.0
1 parent 201b4c3 commit 9654e96

14 files changed

Lines changed: 252 additions & 11 deletions

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "reka-api"
3-
version = "3.1.1"
3+
version = "3.2.0"
44
description = "Reka Python SDK"
55
readme = "README.md"
66
authors = [

‎src/reka/__init__.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
MediaType,
1717
MessageResponse,
1818
Model,
19+
Tool,
20+
ToolCall,
21+
ToolChoice,
22+
ToolOutput,
1923
TypedMediaContent,
2024
TypedText,
2125
Usage,
@@ -44,6 +48,10 @@
4448
"MessageResponse",
4549
"Model",
4650
"RekaEnvironment",
51+
"Tool",
52+
"ToolCall",
53+
"ToolChoice",
54+
"ToolOutput",
4755
"TypedMediaContent",
4856
"TypedText",
4957
"UnprocessableEntityError",

‎src/reka/chat/client.py‎

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from ..types.chat_response import ChatResponse
2020
from ..types.chunk_chat_response import ChunkChatResponse
2121
from ..types.http_validation_error import HttpValidationError
22+
from ..types.tool import Tool
23+
from ..types.tool_choice import ToolChoice
2224

2325
# this is used as the default value for optional parameters
2426
OMIT = typing.cast(typing.Any, ...)
@@ -39,6 +41,8 @@ def create_stream(
3941
seed: typing.Optional[int] = OMIT,
4042
stop: typing.Optional[typing.Sequence[str]] = OMIT,
4143
temperature: typing.Optional[float] = OMIT,
44+
tool_choice: typing.Optional[ToolChoice] = OMIT,
45+
tools: typing.Optional[typing.Sequence[Tool]] = OMIT,
4246
top_k: typing.Optional[int] = OMIT,
4347
top_p: typing.Optional[float] = OMIT,
4448
use_search_engine: typing.Optional[bool] = OMIT,
@@ -71,6 +75,12 @@ def create_stream(
7175
temperature : typing.Optional[float]
7276
Positive number representing the temperature to use for generation. Higher values will make the output more unformly random or *creative*. 0.0 means greedy decoding. Defaults to 0.4.
7377
78+
tool_choice : typing.Optional[ToolChoice]
79+
Controls how the model may use the provided tools. Set to 'auto' to let the model decide whether or not to invoke a tool. Set to 'none' to disable tool use. Set to 'tool' to force the model to invoke a tool.
80+
81+
tools : typing.Optional[typing.Sequence[Tool]]
82+
List of tools the model has access to.
83+
7484
top_k : typing.Optional[int]
7585
Parameter which forces the model to only consider the tokens with the `top_k` highest probabilities at the next step. Defaults to 1024.
7686
@@ -90,7 +100,7 @@ def create_stream(
90100
91101
Examples
92102
--------
93-
from reka import ChatMessage
103+
from reka import ChatMessage, Tool, ToolCall
94104
from reka.client import Reka
95105
96106
client = Reka(
@@ -103,13 +113,28 @@ def create_stream(
103113
ChatMessage(
104114
content="string",
105115
role="user",
116+
tool_calls=[
117+
ToolCall(
118+
id="string",
119+
name="string",
120+
parameters={},
121+
)
122+
],
106123
)
107124
],
108125
model="string",
109126
presence_penalty=1.1,
110127
seed=1,
111128
stop=["string"],
112129
temperature=1.1,
130+
tool_choice="auto",
131+
tools=[
132+
Tool(
133+
description="string",
134+
name="string",
135+
parameters={"string": {"key": "value"}},
136+
)
137+
],
113138
top_k=1,
114139
top_p=1.1,
115140
use_search_engine=True,
@@ -130,6 +155,10 @@ def create_stream(
130155
_request["stop"] = stop
131156
if temperature is not OMIT:
132157
_request["temperature"] = temperature
158+
if tool_choice is not OMIT:
159+
_request["tool_choice"] = tool_choice
160+
if tools is not OMIT:
161+
_request["tools"] = tools
133162
if top_k is not OMIT:
134163
_request["top_k"] = top_k
135164
if top_p is not OMIT:
@@ -191,6 +220,8 @@ def create(
191220
seed: typing.Optional[int] = OMIT,
192221
stop: typing.Optional[typing.Sequence[str]] = OMIT,
193222
temperature: typing.Optional[float] = OMIT,
223+
tool_choice: typing.Optional[ToolChoice] = OMIT,
224+
tools: typing.Optional[typing.Sequence[Tool]] = OMIT,
194225
top_k: typing.Optional[int] = OMIT,
195226
top_p: typing.Optional[float] = OMIT,
196227
use_search_engine: typing.Optional[bool] = OMIT,
@@ -223,6 +254,12 @@ def create(
223254
temperature : typing.Optional[float]
224255
Positive number representing the temperature to use for generation. Higher values will make the output more unformly random or *creative*. 0.0 means greedy decoding. Defaults to 0.4.
225256
257+
tool_choice : typing.Optional[ToolChoice]
258+
Controls how the model may use the provided tools. Set to 'auto' to let the model decide whether or not to invoke a tool. Set to 'none' to disable tool use. Set to 'tool' to force the model to invoke a tool.
259+
260+
tools : typing.Optional[typing.Sequence[Tool]]
261+
List of tools the model has access to.
262+
226263
top_k : typing.Optional[int]
227264
Parameter which forces the model to only consider the tokens with the `top_k` highest probabilities at the next step. Defaults to 1024.
228265
@@ -271,6 +308,10 @@ def create(
271308
_request["stop"] = stop
272309
if temperature is not OMIT:
273310
_request["temperature"] = temperature
311+
if tool_choice is not OMIT:
312+
_request["tool_choice"] = tool_choice
313+
if tools is not OMIT:
314+
_request["tools"] = tools
274315
if top_k is not OMIT:
275316
_request["top_k"] = top_k
276317
if top_p is not OMIT:
@@ -333,6 +374,8 @@ async def create_stream(
333374
seed: typing.Optional[int] = OMIT,
334375
stop: typing.Optional[typing.Sequence[str]] = OMIT,
335376
temperature: typing.Optional[float] = OMIT,
377+
tool_choice: typing.Optional[ToolChoice] = OMIT,
378+
tools: typing.Optional[typing.Sequence[Tool]] = OMIT,
336379
top_k: typing.Optional[int] = OMIT,
337380
top_p: typing.Optional[float] = OMIT,
338381
use_search_engine: typing.Optional[bool] = OMIT,
@@ -365,6 +408,12 @@ async def create_stream(
365408
temperature : typing.Optional[float]
366409
Positive number representing the temperature to use for generation. Higher values will make the output more unformly random or *creative*. 0.0 means greedy decoding. Defaults to 0.4.
367410
411+
tool_choice : typing.Optional[ToolChoice]
412+
Controls how the model may use the provided tools. Set to 'auto' to let the model decide whether or not to invoke a tool. Set to 'none' to disable tool use. Set to 'tool' to force the model to invoke a tool.
413+
414+
tools : typing.Optional[typing.Sequence[Tool]]
415+
List of tools the model has access to.
416+
368417
top_k : typing.Optional[int]
369418
Parameter which forces the model to only consider the tokens with the `top_k` highest probabilities at the next step. Defaults to 1024.
370419
@@ -384,7 +433,7 @@ async def create_stream(
384433
385434
Examples
386435
--------
387-
from reka import ChatMessage
436+
from reka import ChatMessage, Tool, ToolCall
388437
from reka.client import AsyncReka
389438
390439
client = AsyncReka(
@@ -397,13 +446,28 @@ async def create_stream(
397446
ChatMessage(
398447
content="string",
399448
role="user",
449+
tool_calls=[
450+
ToolCall(
451+
id="string",
452+
name="string",
453+
parameters={},
454+
)
455+
],
400456
)
401457
],
402458
model="string",
403459
presence_penalty=1.1,
404460
seed=1,
405461
stop=["string"],
406462
temperature=1.1,
463+
tool_choice="auto",
464+
tools=[
465+
Tool(
466+
description="string",
467+
name="string",
468+
parameters={"string": {"key": "value"}},
469+
)
470+
],
407471
top_k=1,
408472
top_p=1.1,
409473
use_search_engine=True,
@@ -424,6 +488,10 @@ async def create_stream(
424488
_request["stop"] = stop
425489
if temperature is not OMIT:
426490
_request["temperature"] = temperature
491+
if tool_choice is not OMIT:
492+
_request["tool_choice"] = tool_choice
493+
if tools is not OMIT:
494+
_request["tools"] = tools
427495
if top_k is not OMIT:
428496
_request["top_k"] = top_k
429497
if top_p is not OMIT:
@@ -485,6 +553,8 @@ async def create(
485553
seed: typing.Optional[int] = OMIT,
486554
stop: typing.Optional[typing.Sequence[str]] = OMIT,
487555
temperature: typing.Optional[float] = OMIT,
556+
tool_choice: typing.Optional[ToolChoice] = OMIT,
557+
tools: typing.Optional[typing.Sequence[Tool]] = OMIT,
488558
top_k: typing.Optional[int] = OMIT,
489559
top_p: typing.Optional[float] = OMIT,
490560
use_search_engine: typing.Optional[bool] = OMIT,
@@ -517,6 +587,12 @@ async def create(
517587
temperature : typing.Optional[float]
518588
Positive number representing the temperature to use for generation. Higher values will make the output more unformly random or *creative*. 0.0 means greedy decoding. Defaults to 0.4.
519589
590+
tool_choice : typing.Optional[ToolChoice]
591+
Controls how the model may use the provided tools. Set to 'auto' to let the model decide whether or not to invoke a tool. Set to 'none' to disable tool use. Set to 'tool' to force the model to invoke a tool.
592+
593+
tools : typing.Optional[typing.Sequence[Tool]]
594+
List of tools the model has access to.
595+
520596
top_k : typing.Optional[int]
521597
Parameter which forces the model to only consider the tokens with the `top_k` highest probabilities at the next step. Defaults to 1024.
522598
@@ -565,6 +641,10 @@ async def create(
565641
_request["stop"] = stop
566642
if temperature is not OMIT:
567643
_request["temperature"] = temperature
644+
if tool_choice is not OMIT:
645+
_request["tool_choice"] = tool_choice
646+
if tools is not OMIT:
647+
_request["tools"] = tools
568648
if top_k is not OMIT:
569649
_request["top_k"] = top_k
570650
if top_p is not OMIT:

‎src/reka/core/client_wrapper.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get_headers(self) -> typing.Dict[str, str]:
1717
headers: typing.Dict[str, str] = {
1818
"X-Fern-Language": "Python",
1919
"X-Fern-SDK-Name": "reka-api",
20-
"X-Fern-SDK-Version": "3.1.1",
20+
"X-Fern-SDK-Version": "3.2.0",
2121
}
2222
headers["X-Api-Key"] = self.api_key
2323
return headers

‎src/reka/types/__init__.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
from .media_type import MediaType
1616
from .message_response import MessageResponse
1717
from .model import Model
18+
from .tool import Tool
19+
from .tool_call import ToolCall
20+
from .tool_choice import ToolChoice
21+
from .tool_output import ToolOutput
1822
from .typed_media_content import TypedMediaContent
1923
from .typed_text import TypedText
2024
from .usage import Usage
@@ -37,6 +41,10 @@
3741
"MediaType",
3842
"MessageResponse",
3943
"Model",
44+
"Tool",
45+
"ToolCall",
46+
"ToolChoice",
47+
"ToolOutput",
4048
"TypedMediaContent",
4149
"TypedText",
4250
"Usage",

‎src/reka/types/chat_message.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
from ..core.unchecked_base_model import UncheckedBaseModel
99
from .chat_role import ChatRole
1010
from .content import Content
11+
from .tool_call import ToolCall
1112

1213

1314
class ChatMessage(UncheckedBaseModel):
1415
"""
1516
A collection of pieces of content from a single entity (role).
1617
"""
1718

18-
content: Content
19+
content: typing.Optional[Content] = None
1920
role: ChatRole
21+
tool_calls: typing.Optional[typing.List[ToolCall]] = None
2022

2123
def json(self, **kwargs: typing.Any) -> str:
2224
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}

‎src/reka/types/chat_message_chunk.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from ..core.unchecked_base_model import UncheckedBaseModel
99
from .chat_role import ChatRole
1010
from .content import Content
11+
from .tool_call import ToolCall
1112

1213

1314
class ChatMessageChunk(UncheckedBaseModel):
@@ -16,8 +17,9 @@ class ChatMessageChunk(UncheckedBaseModel):
1617
entity (role). This is the streaming version.
1718
"""
1819

19-
content: Content
20+
content: typing.Optional[Content] = None
2021
role: ChatRole
22+
tool_calls: typing.Optional[typing.List[ToolCall]] = None
2123

2224
def json(self, **kwargs: typing.Any) -> str:
2325
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}

‎src/reka/types/chat_role.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
import typing
44

5-
ChatRole = typing.Union[typing.Literal["user", "assistant"], typing.Any]
5+
ChatRole = typing.Union[typing.Literal["user", "assistant", "system", "tool_output"], typing.Any]

‎src/reka/types/content.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
import typing
44

55
from .chat_message_chunk_content_item import ChatMessageChunkContentItem
6+
from .tool_output import ToolOutput
67

7-
Content = typing.Union[str, typing.List[ChatMessageChunkContentItem]]
8+
Content = typing.Union[str, typing.List[ChatMessageChunkContentItem], typing.List[ToolOutput]]

‎src/reka/types/model.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
class Model(UncheckedBaseModel):
1212
"""
1313
Represents a model entry. A list of these is the response
14-
1514
from the list models endpoints. Different users might have
16-
17-
permissions to access different models.'
15+
permissions to access different models.
1816
"""
1917

2018
id: str

0 commit comments

Comments
 (0)