Skip to content

update anthropic endpoint test#4594

Draft
littlegy wants to merge 8 commits into
InternLM:mainfrom
littlegy:test_anthropic_endpoint
Draft

update anthropic endpoint test#4594
littlegy wants to merge 8 commits into
InternLM:mainfrom
littlegy:test_anthropic_endpoint

Conversation

@littlegy

Copy link
Copy Markdown
Contributor

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily receiving feedbacks. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

Please describe the motivation of this PR and the goal you want to achieve through this PR.

Modification

Please briefly describe what modification is made in this PR.

BC-breaking (Optional)

Does the modification introduce changes that break the backward-compatibility of the downstream repositories?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.

Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.

Checklist

  1. Pre-commit or other linting tools are used to fix the potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness.
  3. If the modification has a dependency on downstream projects of a newer version, this PR should be tested with all supported versions of downstream projects.
  4. The documentation has been modified accordingly, like docstring or example tutorials.

@zhulinJulia24 zhulinJulia24 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

'unsloth/gpt-oss-20b-BF16',
'Qwen/Qwen2.5-7B-Instruct',
'internlm/Intern-S1-Pro-FP8',
'internlm/interns2-preview-0509',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls use the official model id

Comment thread autotest/utils/constant.py Outdated
'OpenGVLab/InternVL3-38B', 'Qwen/Qwen3-VL-8B-Instruct', 'internlm/Intern-S1',
'internlm/internlm3-8b-instruct', 'meta-llama/Llama-3.2-3B-Instruct',
'Qwen/Qwen3-VL-30B-A3B-Instruct',
'Qwen/Qwen3-VL-30B-A3B-Instruct', 'internlm/interns2-preview-0509',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls use the official model id

Comment on lines +206 to +238
def openai_function_tool_to_anthropic(openai_style_tool: dict) -> dict:
"""Convert OpenAI ``{'type':'function','function':{...}}`` to Anthropic
``tools[]`` item."""

fn = openai_style_tool['function']
return {
'name': fn['name'],
'description': fn.get('description') or '',
'input_schema': fn['parameters'],
}


def openai_chat_messages_to_anthropic_kwargs(messages: list[dict]) -> dict:
"""Split OpenAI-style *messages* into Anthropic ``system`` plus
``messages`` kwargs."""

system_chunks: list[str] = []
out: list[dict] = []
for m in messages:
role = m['role']
content = m['content']
if role == 'system':
if not isinstance(content, str):
raise TypeError('Anthropic path expects string system message content.')
system_chunks.append(content)
elif role in ('user', 'assistant'):
out.append({'role': role, 'content': content})
else:
raise ValueError(f'Unsupported message role for Anthropic: {role!r}')
kwargs: dict = {'messages': out}
if system_chunks:
kwargs['system'] = '\n\n'.join(system_chunks)
return kwargs

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to convert openai messages to anthropic input?

@littlegy littlegy marked this pull request as draft June 22, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants