-
Notifications
You must be signed in to change notification settings - Fork 192
Add Responses API #844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Add Responses API #844
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
20b6a98
WIP responses client
gwarmstrong 6c9760a
WIP make python tool http runnable
gwarmstrong 06dd03c
ENH add see protocol to python tool
gwarmstrong 04d15ef
ENH enable response API for toolwrapper
gwarmstrong 2ef2683
ENH support responses model type
gwarmstrong 70aac38
MAINT revert unrelated python tool changes
gwarmstrong 2eb538f
MAINT cleanup adapters
gwarmstrong 97b4f2f
MAINT remove unused method
gwarmstrong 92e61b0
MAINT move import to top
gwarmstrong 7a1f019
Draft add client handler
gwarmstrong 5688efe
FIX up responses conversion
gwarmstrong 4e3a5a4
MAINT switch to use_responses_api parameter
gwarmstrong 8428242
MAINT cleanup
gwarmstrong 51fca89
Revert server type changes
gwarmstrong 3ea3bb6
ENH error if no serialized output
gwarmstrong f8c6367
ENH improve non default arg errors
gwarmstrong ab7ad54
Apply suggestion from @coderabbitai[bot]
gwarmstrong 8e137b8
log args
gwarmstrong 39b947e
Apply suggestion from @coderabbitai[bot]
gwarmstrong 503a9f1
Merge branch 'main' into georgea/response-api
gwarmstrong ec7551f
Merge branch 'main' into georgea/response-api
gwarmstrong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,18 +50,36 @@ | |
| } | ||
|
|
||
|
|
||
| def get_model(server_type, tokenizer=None, **kwargs): | ||
| """A helper function to make it easier to set server through cmd.""" | ||
| def get_model(server_type, use_responses_api=False, tokenizer=None, **kwargs): | ||
| """A helper function to make it easier to set server through cmd. | ||
|
|
||
| Args: | ||
| server_type: Type of server to use (e.g., 'openai', 'vllm', etc.) | ||
| use_responses_api: Whether to use responses API instead of chat completion API | ||
| tokenizer: Tokenizer to use | ||
| **kwargs: Additional arguments to pass to the model | ||
| """ | ||
| model_class = models[server_type.lower()] | ||
| if server_type == "trtllm" and kwargs.get("enable_soft_fail", False): | ||
| if kwargs.get("context_limit_retry_strategy", None) is not None: | ||
| raise ValueError("context_limit_retry_strategy is not supported for trtllm") | ||
| return model_class(tokenizer=tokenizer, **kwargs) | ||
| return model_class(use_responses_api=use_responses_api, tokenizer=tokenizer, **kwargs) | ||
|
|
||
|
|
||
| def get_code_execution_model(server_type, tokenizer=None, code_execution=None, sandbox=None, **kwargs): | ||
| """A helper function to make it easier to set server through cmd.""" | ||
| model = get_model(server_type=server_type, tokenizer=tokenizer, **kwargs) | ||
| def get_code_execution_model( | ||
| server_type, use_responses_api=False, tokenizer=None, code_execution=None, sandbox=None, **kwargs | ||
| ): | ||
| """A helper function to make it easier to set server through cmd. | ||
|
|
||
| Args: | ||
| server_type: Type of server to use (e.g., 'openai', 'vllm', etc.) | ||
| use_responses_api: Whether to use responses API instead of chat completion API | ||
| tokenizer: Tokenizer to use | ||
| code_execution: Code execution configuration | ||
| sandbox: Sandbox to use for code execution | ||
| **kwargs: Additional arguments to pass to the model | ||
| """ | ||
| model = get_model(server_type=server_type, use_responses_api=use_responses_api, tokenizer=tokenizer, **kwargs) | ||
| if code_execution is None: | ||
| code_execution = {} | ||
| code_execution_config = CodeExecutionConfig(**code_execution) | ||
|
|
@@ -94,14 +112,26 @@ def get_parallel_thinking_model( | |
|
|
||
| def get_tool_calling_model( | ||
| model, | ||
| use_responses_api=False, | ||
| tokenizer=None, | ||
| additional_config=None, | ||
| tool_modules: list[str] | None = None, | ||
| tool_overrides: dict | None = None, | ||
| **kwargs, | ||
| ): | ||
| """A helper function to create a tool calling model. | ||
|
|
||
| Args: | ||
| model: Model name/path or model instance | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of the function docstrings and some code comments are not informative enough (probably LLM artifacts). Maybe we could remove them to avoid redundancy? |
||
| use_responses_api: Whether to use responses API instead of chat completion API | ||
| tokenizer: Tokenizer to use | ||
| additional_config: Additional configuration | ||
| tool_modules: List of tool modules to use | ||
| tool_overrides: Tool overrides | ||
| **kwargs: Additional arguments to pass to the model | ||
| """ | ||
| if isinstance(model, str): | ||
| model = get_model(model=model, tokenizer=tokenizer, **kwargs) | ||
| model = get_model(model=model, use_responses_api=use_responses_api, tokenizer=tokenizer, **kwargs) | ||
| return ToolCallingWrapper( | ||
|
gwarmstrong marked this conversation as resolved.
|
||
| model, | ||
| tool_modules=tool_modules, | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.