-
Notifications
You must be signed in to change notification settings - Fork 60.2k
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
fix: 修复环境变量BASE_URL设置为Cloudflare AI Gateway时, #4926
Conversation
请求路径错误的问题 报错信息: Unknown request URL: POST /v1/v1/chat/completions?path=v1&path=chat&path=completions. Please check the URL for typos, or see the docs at https://platform.openai.com/docs/api-reference/.
Someone is attempting to deploy a commit to the NextChat Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- app/api/common.ts (2 hunks)
Additional comments not posted (1)
app/api/common.ts (1)
43-51
: Verify the conditional path modification logic.The logic to conditionally modify the
path
based onbaseUrl
looks correct. Ensure that it handles all URL patterns appropriately and doesn't introduce new issues.Verification successful
Verify the conditional path modification logic.
The logic to conditionally modify the
path
based onbaseUrl
looks correct. Thereq.nextUrl.pathname
andreq.nextUrl.search
are used to construct the path, and the replacement logic is applied conditionally based on thebaseUrl
. This should handle the intended URL patterns appropriately.
app/api/common.ts
: TherequestOpenai
function modifies the path based on whether thebaseUrl
corresponds to Cloudflare or other URLs.Given the context and the usage of
requestOpenai
, the logic appears to be sound and should handle the URL patterns correctly.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the conditional path modification logic handles all URL patterns correctly. # Test: Search for all occurrences of the `requestOpenai` function and check the paths being passed to it. rg --type python $'requestOpenai'Length of output: 63
Script:
#!/bin/bash # Description: Verify that the conditional path modification logic handles all URL patterns correctly. # Test: Search for all occurrences of the `requestOpenai` function and check the paths being passed to it. rg --type js requestOpenai rg --type ts requestOpenaiLength of output: 292
Script:
#!/bin/bash # Extract the relevant code from `app/api/openai/[...path]/route.ts` to analyze the paths being passed to `requestOpenai`. rg --type ts --context 10 'requestOpenai' app/api/openai/[...path]/route.tsLength of output: 1287
Script:
#!/bin/bash # Search for the structure of `req.nextUrl` and its usage in the codebase. rg --type ts 'req.nextUrl'Length of output: 408
Script:
#!/bin/bash # Search for the `NextRequest` type definition in the codebase to understand the structure of `req.nextUrl`. rg --type ts 'NextRequest'Length of output: 1201
Your build has completed! |
This comment was marked as spam.
This comment was marked as spam.
https://developers.cloudflare.com/ai-gateway/providers/openai/ 看了下 cloudflare ai gateway的文档,这个修复应该能解决问题。 |
https://developers.cloudflare.com/ai-gateway/providers/openai/ After reading the documentation of cloudflare ai gateway, this fix should solve the problem. |
谢谢大佬的回复,我知道我方式在某些情况下可能会导致代码的可维护性以及可扩展性问题,有没有什么办法能够解决这个问题呢 |
Thank you for your reply. I know that my method may cause code maintainability and scalability problems in some cases. Is there any way to solve this problem? |
@evansuner 最后,非常感谢您积极提交代码维护项目! |
@evansuner |
请求路径错误的问题
报错信息:
Unknown request URL:
POST /v1/v1/chat/completions?path=v1&path=chat&path=completions.
Please check the URL for typos,
or see the docs at https://platform.openai.com/docs/api-reference/.
Summary by CodeRabbit