Skip to content
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

01.ai Yi Client #3048

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

01.ai Yi Client #3048

wants to merge 8 commits into from

Conversation

uukuguy
Copy link

@uukuguy uukuguy commented Jun 30, 2024

Why are these changes needed?

To enhance the support of non-OpenAI models with AutoGen. The 01.ai Yi family of models includes yi-large etc.
Developers can utilize the AI capabilities of the Yi series LLMs to perform a variety of tasks, such as text generation, language translation, content summarization, logical reasoning, mathematical calculation, and code generation.

  • Pricing Implemented
  • API Checks
  • Create
  • Tool calls
  • get_usage

Checks

@uukuguy
Copy link
Author

uukuguy commented Jun 30, 2024

@microsoft-github-policy-service agree

Copy link
Collaborator

@Hk669 Hk669 left a comment

Choose a reason for hiding this comment

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

I couldn't find the pricing as well. please feel free to share some references. Thanks

api_key
), "Please include the api_key in your config list entry for Yi or set the YI_API_KEY env variable."

self._oai_client = OpenAI(api_key=api_key, base_url=base_url)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand, why are we initializing an OpenAI client again? can you please explain this.

Copy link
Author

Choose a reason for hiding this comment

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

According to the official documentation, 01.AI provides an HTTP request interface highly compatible with OpenAI API, but no SDKs for Python or other languages have been found so far.
I'm undecided, so I'll first use the method of the OpenAI API client that I usually use. Other possible implementations include:

  • Using requests
  • Inheriting the autogen.oai.OpenAIClient
    Any suggestions?

Copy link
Collaborator

@Hk669 Hk669 Jul 1, 2024

Choose a reason for hiding this comment

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

i think this looks good. please let us know the status of the tests using the model. a notebook/ tutorial on this is appreciated. thanks @uukuguy

cc @marklysze @qingyun-wu

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible just to use base_url and api_key on a standard config and use the normal OpenAI client rather than use a specific class for Yi.

Copy link
Author

Choose a reason for hiding this comment

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

I also agree with directly using the OpenAI client to access the Yi API. The only major difference is that the Yi API can only use some of the parameters from the OpenAI API. So, still need Yi client?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep, that's a good point and I think it's useful to be able to handle client specific parameters. Okay, we move forward with testing then.

@qingyun-wu or @sonichi, let us know if you think this okay to proceed with or if there's another approach.


# Cost per thousand tokens - Input / Output (NOTE: Convert $/Million to $/K)
YI_PRICING_1K = {
"yi-large": (0.003, 0.003),
Copy link
Collaborator

Choose a reason for hiding this comment

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

are these models not open sourced? do they have a separate client that could be accessed with the OpenAI python SDK and API key?

Copy link
Author

Choose a reason for hiding this comment

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

According to the official documentation, 01.AI provides an HTTP request interface highly compatible with OpenAI API, but no SDKs for Python or other languages have been found so far.

Copy link
Collaborator

Choose a reason for hiding this comment

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

According to the official documentation, 01.AI provides an HTTP request interface highly compatible with OpenAI API, but no SDKs for Python or other languages have been found so far.

How should we run and test the client? Can you provide a code sample?

Copy link
Author

@uukuguy uukuguy Jul 1, 2024

Choose a reason for hiding this comment

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

# You can get an account with a $5 free credit at https://platform.01.ai/apikeys to create your own YI_API_KEY.

# Use openai client
import os
from openai import OpenAI
client = OpenAI(api_key=os.getenv("YI_API_KEY"), base_url=os.getenv("YI_BASE_URL", "https://api.01.ai/v1"))

# Use autogen.oai client
from autogen.oai.yi import YiClient
client = YiClient(api_key=os.getenv("YI_API_KEY"))

Copy link
Collaborator

@marklysze marklysze Jul 1, 2024

Choose a reason for hiding this comment

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

Thanks, are you able to test it with these sample autogen scripts?

https://github.com/marklysze/AutoGenCodeTesting

I use them when developing client classes.

@marklysze
Copy link
Collaborator

Hey @uukuguy, thanks so much for putting this together. In line with @Hk669's questions, can you describe how you use this client?

I can see there's an official Yi API but it's limited to Beta Testers - is this designed to use that?

I'd love to test it but I'm not sure how to get started and whether I need an account somewhere.

@uukuguy
Copy link
Author

uukuguy commented Jul 1, 2024

Hey @uukuguy, thanks so much for putting this together. In line with @Hk669's questions, can you describe how you use this client?

I can see there's an official Yi API but it's limited to Beta Testers - is this designed to use that?

I'd love to test it but I'm not sure how to get started and whether I need an account somewhere.

01.AI's LLM API is located at https://platform.01.ai/, currently featuring only the yi-large model, with plans to deliver multiple models such as yi-large-turbo, yi-medium, and yi-vision. The Yi series of open-source models can be found at https://huggingface.co/01-ai, including several popular models like Yi-1.5-34B.

According to the official documentation, 01.AI provides an HTTP request interface highly compatible with OpenAI API, but no SDKs for Python or other languages have been found so far.

@uukuguy
Copy link
Author

uukuguy commented Jul 1, 2024

I couldn't find the pricing as well. please feel free to share some references. Thanks

@Hk669 https://platform.01.ai/docs#models-and-pricing

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.

None yet

3 participants