Skip to content
Open
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
10 changes: 10 additions & 0 deletions clarifai/runners/models/openai_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,16 @@ def _update_old_fields(self, request_data: Dict[str, Any]) -> Dict[str, Any]:
request_data['max_completion_tokens'] = request_data.pop('max_tokens')
if 'top_p' in request_data:
request_data['top_p'] = float(request_data['top_p'])
if 'top_k' in request_data:
top_k = int(request_data.pop("top_k", -1))
if top_k > 0:
extra_body = request_data.get("extra_body", {})
assert isinstance(extra_body, dict), ValueError(
"`extra_body` must be a dictionary"
)
extra_body.update({"top_k": top_k})
request_data.update({"extra_body": extra_body})

# Note(zeiler): temporary fix for our playground sending additional fields.
# FIXME: remove this once the playground is updated.
# Shouldn't need to do anything with the responses API since playground isn't yet using it.
Expand Down
Loading