Skip to content

Commit 7c1fa24

Browse files
committed
feat(assistant_api): support more parameters for run
1 parent a6f5e44 commit 7c1fa24

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

dashscope/threads/runs/runs.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ def create(cls,
8282
workspace: str = None,
8383
extra_body: Optional[Dict] = None,
8484
api_key: str = None,
85+
top_p: Optional[float] = None,
86+
top_k: Optional[int] = None,
87+
temperature: Optional[float] = None,
88+
max_tokens: Optional[int] = None,
8589
**kwargs) -> Run:
8690
"""Create a run.
8791
@@ -122,6 +126,15 @@ def create(cls,
122126
if extra_body is not None and extra_body:
123127
data = {**data, **extra_body}
124128

129+
if top_p is not None:
130+
data['top_p'] = top_p
131+
if top_k is not None:
132+
data['top_k'] = top_k
133+
if temperature is not None:
134+
data['temperature'] = temperature
135+
if max_tokens is not None:
136+
data['max_tokens'] = max_tokens
137+
125138
response = super().call(data=data,
126139
path=f'threads/{thread_id}/runs',
127140
api_key=api_key,
@@ -180,6 +193,10 @@ def call(cls,
180193
workspace: str = None,
181194
extra_body: Optional[Dict] = None,
182195
api_key: str = None,
196+
top_p: Optional[float] = None,
197+
top_k: Optional[int] = None,
198+
temperature: Optional[float] = None,
199+
max_tokens: Optional[int] = None,
183200
**kwargs) -> Run:
184201
"""Create a run.
185202
@@ -214,6 +231,10 @@ def call(cls,
214231
workspace=workspace,
215232
extra_body=extra_body,
216233
api_key=api_key,
234+
top_p=top_p,
235+
top_k=top_k,
236+
temperature=temperature,
237+
max_tokens=max_tokens,
217238
**kwargs)
218239

219240
@classmethod

dashscope/threads/thread_types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,11 @@ class Run(BaseObjectMixin):
309309

310310
tools: List[Tool]
311311

312+
top_p: Optional[float] = None
313+
top_k: Optional[int] = None
314+
temperature: Optional[float] = None
315+
max_tokens: Optional[int] = None
316+
312317
usage: Optional[Usage] = None
313318

314319
def __init__(self, **kwargs):

0 commit comments

Comments
 (0)