autogen icon indicating copy to clipboard operation
autogen copied to clipboard

Add Llama API OAI compatible endpoint support

Open WuhanMonkey opened this issue 7 months ago • 2 comments

Why are these changes needed?

To add the latest support for using Llama API offerings with AutoGen

Checks

WuhanMonkey avatar Apr 30 '25 16:04 WuhanMonkey

Llama support is cool! could you adding register_transformer at _message_transfrom to? https://github.com/microsoft/autogen/blob/main/python/packages/autogen-ext/src/autogen_ext/models/openai/_message_transform.py

You could start with __BASE_TRANSFORMER_MAP or build __LLAMA_TRANSFROMER_MAP same as __BASE_TRANSFORMER_MAP for future modified.

https://github.com/microsoft/autogen/blob/c7757de59eaa6cf3a7cd039ccddcdb7ceadd724f/python/packages/autogen-ext/src/autogen_ext/models/openai/_message_transform.py#L413-L432

and...

https://github.com/microsoft/autogen/blob/c7757de59eaa6cf3a7cd039ccddcdb7ceadd724f/python/packages/autogen-ext/src/autogen_ext/models/openai/_message_transform.py#L470-L492


I think you are expert of Llama. If you know about Llama's message limited, could support more well with _message_transfrom.

In Anthropic case, Claude does not support empty message, so this message transformer remove empty messages.

SongChiYoung avatar Apr 30 '25 23:04 SongChiYoung

@WuhanMonkey thanks for the PR. Could you address @SongChiYoung 's comments?

ekzhu avatar May 06 '25 21:05 ekzhu

@WuhanMonkey thanks for the PR. Could you address @SongChiYoung 's comments?

Hey yes, just updated it.

We are still pending on CLA review from our legal side.

WuhanMonkey avatar May 06 '25 22:05 WuhanMonkey

@microsoft-github-policy-service agree company="Meta"

WuhanMonkey avatar May 14 '25 19:05 WuhanMonkey

We finally get the CLA approved and signed. @SongChiYoung and @ekzhu would you mind help me review and approve this PR? Thanks

WuhanMonkey avatar May 14 '25 19:05 WuhanMonkey

One more question, @SongChiYoung, does AutoGen allows extra headers in the request for customized x-title or http-referer for tracking purpose?

WuhanMonkey avatar May 14 '25 19:05 WuhanMonkey

One more question, @SongChiYoung, does AutoGen allows extra headers in the request for customized x-title or http-referer for tracking purpose?

You can pass in default_headers as part of the OpenAIChatCompletionClient. https://microsoft.github.io/autogen/stable/reference/python/autogen_ext.models.openai.html#autogen_ext.models.openai.OpenAIChatCompletionClient

ekzhu avatar May 15 '25 21:05 ekzhu

Codecov Report

Attention: Patch coverage is 76.47059% with 4 lines in your changes missing coverage. Please review.

Project coverage is 79.52%. Comparing base (1eb7f93) to head (5413c51). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...xt/src/autogen_ext/models/openai/_openai_client.py 20.00% 4 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6442      +/-   ##
==========================================
- Coverage   79.53%   79.52%   -0.01%     
==========================================
  Files         225      225              
  Lines       16644    16661      +17     
==========================================
+ Hits        13237    13249      +12     
- Misses       3407     3412       +5     
Flag Coverage Δ
unittests 79.52% <76.47%> (-0.01%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar May 15 '25 22:05 codecov[bot]

@WuhanMonkey I will bring it to finish. Thanks. For local checks you can see python/README.md for guides.

ekzhu avatar May 15 '25 23:05 ekzhu

@WuhanMonkey I will bring it to finish. Thanks. For local checks you can see python/README.md for guides.

Thanks appreciate it.

WuhanMonkey avatar May 16 '25 00:05 WuhanMonkey