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

Use openAiApi but custom request URL #710

Open
Dragonchu opened this issue May 11, 2024 · 2 comments
Open

Use openAiApi but custom request URL #710

Dragonchu opened this issue May 11, 2024 · 2 comments

Comments

@Dragonchu
Copy link

Dragonchu commented May 11, 2024

I'm using a company-specific proxy to interact with OpenAI. Our proxy requires a different URL structure for sending queries, specifically http://gpt-proxy.xx.com/gateway/azure/chat/completions

I can customize the base URL using the spring.ai.openai.base-url configuration, but the OpenAiApi seems to always append /v1/chat/completions to the base URL. This doesn't work with our required URL structure.

Could we have a new configuration property that allows for customization of this appended URI? This way, we could configure our application like this:

spring.ai.openai.base-url=http://gpt-proxy.xx.com/

spring.ai.openai.completions-uri=gateway/azure/chat/completions

This change would make the OpenAiApi more flexible for users with unique URL requirements.

@Dragonchu Dragonchu changed the title Use openAiApi but custom URI Use openAiApi but custom request URL May 11, 2024
@devholic22
Copy link
Contributor

devholic22 commented May 22, 2024

@Dragonchu Hello, I think the reason why v1/chat/completions is automatically added is because the chatCompletionEntity,chatCompletionStream method in OpenAiApi.java automatically added uri as /v1/chat/completions. I think it would be possible to overload the functions to receive additional uri. (ex:chatCompletionEntity(uri, ChatCompletionRequest)))

And I'd like to ask the maintainers if this idea is a good way or if it's okay for me to solve it.

스크린샷 2024-05-22 오후 2 06 23

@devholic22
Copy link
Contributor

devholic22 commented May 22, 2024

Additionally, I think the modification for base-url can be done by overloading the generator for OpenAiConnectionProperties. Can I try this issue?

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

No branches or pull requests

2 participants