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

How to set a custom client for a chat agent. #133

Closed
shenhai-ran opened this issue Jul 13, 2024 · 6 comments
Closed

How to set a custom client for a chat agent. #133

shenhai-ran opened this issue Jul 13, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request solved For those issues already solved but stay open for more user can see

Comments

@shenhai-ran
Copy link

shenhai-ran commented Jul 13, 2024

Hello,

I am inside corporate networking and I need the self signed certificate to access certain websites. In case of OpenAI API, I can do something like

http_client=httpx.Client(verify=<my/certificate>)
client=OpenAI(http_client=http_client)

I tried to read the documents and I only found settings for proxy. I also tried to use .set_model but it doesn't work either.

How to work with Agently in this case?

Thanks

@Maplemx
Copy link
Owner

Maplemx commented Jul 15, 2024

The offical framework did not support the method yet but you can customize the OAIClient request plugin to do so.

You can find the plugin file by this path: plugins/request/OAIClient.py

And these's a method named _create_client that using httpx to create a request client. You can add verify information there.

I'll update verify support next version too. Thanks for letting me know this case and help us to improve.

@Maplemx Maplemx self-assigned this Jul 15, 2024
@Maplemx Maplemx added the enhancement New feature or request label Jul 15, 2024
@shenhai-ran
Copy link
Author

Hi, thanks for your update...

Just out of curiosity, why do you do you use this way of setting but not expose native, for example, OpenAI client to the user?

@Maplemx
Copy link
Owner

Maplemx commented Jul 15, 2024

updated in bc9aa24

@Maplemx
Copy link
Owner

Maplemx commented Jul 15, 2024

published in version 3.3.2.0

@Maplemx
Copy link
Owner

Maplemx commented Jul 15, 2024

Hi, thanks for your update...

Just out of curiosity, why do you do you use this way of setting but not expose native, for example, OpenAI client to the user?

If we do so, features like agent.input().output().start() won't able to work and developers will have to manage prompt template all by themselves.

Also, we can not promise that developers can switch models without changing codes about how application works but just changing model settings.

We are not only providing model requesting methods but also providing application behaviors management expression with LLMs, that's not the same in many different ways. Don't think it too simple.

@shenhai-ran
Copy link
Author

Hi, thanks for your update...
Just out of curiosity, why do you do you use this way of setting but not expose native, for example, OpenAI client to the user?

If we do so, features like agent.input().output().start() won't able to work and developers will have to manage prompt template all by themselves.

Also, we can not promise that developers can switch models without changing codes about how application works but just changing model settings.

We are not only providing model requesting methods but also providing application behaviors management expression with LLMs, that's not the same in many different ways. Don't think it too simple.

I see. When you have multiple LLM clients, the factory mode is indeed more convenient to switch models. In my case I only have one endpoint from the company, so don't have to worried about it....

I have tested agent.set_settings("model.OAIClient.verify", os.environ["<my-ca>"]) and it works. great work!

@Maplemx Maplemx added the solved For those issues already solved but stay open for more user can see label Jul 22, 2024
@Maplemx Maplemx closed this as completed Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request solved For those issues already solved but stay open for more user can see
Projects
None yet
Development

No branches or pull requests

2 participants