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

[Bug] BASE_URL Error1002 #4474

Closed
1 of 3 tasks
A-l-an opened this issue Apr 9, 2024 · 36 comments
Closed
1 of 3 tasks

[Bug] BASE_URL Error1002 #4474

A-l-an opened this issue Apr 9, 2024 · 36 comments
Labels
bug Something isn't working

Comments

@A-l-an
Copy link

A-l-an commented Apr 9, 2024

Bug Description

BASE_URL does not need to include /v1/chat/completions part

Originally posted by @QAbot-zh in #4441 (comment)

It doesn't work. still shows error code: 1002.

The reference code my school provide is as below:
url = "https://gpt-api.【school】.edu.cn/v1/chat/completions"
headers = { "Content-Type": "application/json", "Authorization": "Bearer xxx" }
data = { "model": "gpt-4", # "gpt-3.5-turbo" version in gpt-3.5-turbo-1106, "gpt-4" version in gpt-4-1106-version (gpt-4-vision-preview is NOT available in azure openai), "gpt-3.5-turbo-16k", "gpt-4-32k" "messages": [{"role": "user", "content": "Q"}], "temperature": 0.7 }
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())

I supposed that error is because of the different usage of the api? or sth else?

Steps to Reproduce

/

Expected Behavior

/

Screenshots

No response

Deployment Method

  • Docker
  • Vercel
  • Server

Desktop OS

MacOS

Desktop Browser

Chrom

Desktop Browser Version

No response

Smartphone Device

No response

Smartphone OS

No response

Smartphone Browser

No response

Smartphone Browser Version

No response

Additional Logs

No response

@A-l-an A-l-an added the bug Something isn't working label Apr 9, 2024
@Dean-YZG
Copy link
Contributor

Dean-YZG commented Apr 9, 2024

Please provide a callable, complete, domain-desensitized url
Our concatenation rule of url calling gpt is 'BASE_URL' + 'v1/chat/completions'

@Dean-YZG
Copy link
Contributor

Dean-YZG commented Apr 9, 2024

Please verify that your available urls match our url concatenation rules

@A-l-an
Copy link
Author

A-l-an commented Apr 9, 2024

Please provide a callable, complete, domain-desensitized url Our concatenation rule of url calling gpt is 'BASE_URL' + 'v1/chat/completions'

yes it's https://gpt-api.hkust-gz.edu.cn/v1/chat/completions , but when I changed the BASE_URL to https://gpt-api.hkust-gz.edu.cn/ the error 1002 still existed

@fred-bf
Copy link
Contributor

fred-bf commented Apr 9, 2024

@A-l-an would you mind share the original error response?

@A-l-an
Copy link
Author

A-l-an commented Apr 9, 2024

@A-l-an would you mind share the original error response?

Sure, the error shows as below:
image

@fred-bf
Copy link
Contributor

fred-bf commented Apr 9, 2024

I mean the raw response from the chrome devtools
CleanShot 2024-04-09 at 16 47 56@2x

@A-l-an
Copy link
Author

A-l-an commented Apr 9, 2024

I mean the raw response from the chrome devtools

The response is still the same as below:
image

But I did notice that the request URL is still the original one instead of my school's.
image

And I did change the BASE_URL and redeploy the web as the pic showed below:
image

@QAbot-zh
Copy link

QAbot-zh commented Apr 9, 2024

So, can you successfully get a response using the reference code provided by your school?
Run the school's reference code first to test your network environment.

@A-l-an
Copy link
Author

A-l-an commented Apr 9, 2024

So, can you successfully get a response using the reference code provided by your school? Run the school's reference code first to test your network environment.

Yes, it worked successfully on the reference code .

@QAbot-zh
Copy link

QAbot-zh commented Apr 9, 2024

So it might be necessary to inquire with your school whether they have imposed restrictions on visiting IPs, because the program deployed by Vercel makes requests using the IPs provided by Vercel. You can try downloading the released software of NextChat and use it on your computer to see if the problem still exists.

@Dean-YZG Dean-YZG closed this as completed Apr 9, 2024
@A-l-an
Copy link
Author

A-l-an commented Apr 9, 2024

#4480, In this PR, the user-defined model will use the openai interface protocol instead of the anthropic interface protocol

sorry, but how should I fix this?

@QAbot-zh
Copy link

QAbot-zh commented Apr 9, 2024

You can download the release to use the api if you can run the reference code. release is here

@A-l-an
Copy link
Author

A-l-an commented Apr 9, 2024

You can download the release to use the api if you can run the reference code. release is here

in this case, should I change the OpenAI Endpoint to my school's?
https://gpt-api.hkust-gz.edu.cn/

cause when I did, another error showed up:
{ "error": true, "message": "Load failed" }

@QAbot-zh
Copy link

QAbot-zh commented Apr 9, 2024

It's confusing.

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


It's confusing.

@Dean-YZG Dean-YZG reopened this Apr 9, 2024
@Dean-YZG
Copy link
Contributor

Dean-YZG commented Apr 9, 2024

sorry,it's my fault,I closed this issue by mistake,ignore it

@H0llyW00dzZ
Copy link
Contributor

I think there might be something wrong with the header handler. Also, I'm surprised that your school allows the use of AI ?

@A-l-an
Copy link
Author

A-l-an commented Apr 9, 2024

I think there might be something wrong with the header handler. Also, I'm surprised that your school allows the use of AI ?

sorry what do you mean by header handler? and yes we are encouraged to use AI tools.

@A-l-an
Copy link
Author

A-l-an commented Apr 9, 2024

It's confusing.

yeah, all I did just replace the Endpoint and type in my API key...

@H0llyW00dzZ
Copy link
Contributor

I think there might be something wrong with the header handler. Also, I'm surprised that your school allows the use of AI ?

sorry what do you mean by header handler? and yes we are encouraged to use AI tools.

Here's an example:

image

Also, can you take a screenshot of it and censor/hide any contained API keys?

@H0llyW00dzZ
Copy link
Contributor

and censor/hide any other value contained sensitive as well

@A-l-an
Copy link
Author

A-l-an commented Apr 9, 2024

I think there might be something wrong with the header handler. Also, I'm surprised that your school allows the use of AI ?

sorry what do you mean by header handler? and yes we are encouraged to use AI tools.

Here's an example:

Also, can you take a screenshot of it and censor/hide any contained API keys?

here it is, I do not know what went wrong

CleanShot 2024-04-09 at 21 57 49@2x

@H0llyW00dzZ
Copy link
Contributor

H0llyW00dzZ commented Apr 9, 2024

I think there might be something wrong with the header handler. Also, I'm surprised that your school allows the use of AI ?

sorry what do you mean by header handler? and yes we are encouraged to use AI tools.

Here's an example:
Also, can you take a screenshot of it and censor/hide any contained API keys?

here it is, I do not know what went wrong

CleanShot 2024-04-09 at 21 57 49@2x

It could be an issue with your school's https://gpt-api.【school】.edu.cn/v1/chat/completions REST APIs (e.g., permissions related to CORS,region blocked because it used vercel to request into your school REST APIs). The request header is correct.

@A-l-an
Copy link
Author

A-l-an commented Apr 9, 2024

I think there might be something wrong with the header handler. Also, I'm surprised that your school allows the use of AI ?

sorry what do you mean by header handler? and yes we are encouraged to use AI tools.

Here's an example:
Also, can you take a screenshot of it and censor/hide any contained API keys?

here it is, I do not know what went wrong
CleanShot 2024-04-09 at 21 57 49@2x

It could be an issue with your school's https://gpt-api.【school】.edu.cn/v1/chat/completions REST APIs (e.g., permissions related to CORS,region blocked because it used vercel to request into your school REST APIs). The request header is correct.

but I also tried to download the release version and use the api locally before. and another error showed up:
{ "error": true, "message": "Load failed" }

@H0llyW00dzZ
Copy link
Contributor

I think there might be something wrong with the header handler. Also, I'm surprised that your school allows the use of AI ?

sorry what do you mean by header handler? and yes we are encouraged to use AI tools.

Here's an example:
Also, can you take a screenshot of it and censor/hide any contained API keys?

here it is, I do not know what went wrong
CleanShot 2024-04-09 at 21 57 49@2x

It could be an issue with your school's https://gpt-api.【school】.edu.cn/v1/chat/completions REST APIs (e.g., permissions related to CORS,region blocked because it used vercel to request into your school REST APIs). The request header is correct.

but I also tried to download the release version and use the api locally before. and another error showed up: { "error": true, "message": "Load failed" }

try this method:

image

@A-l-an
Copy link
Author

A-l-an commented Apr 9, 2024

I think there might be something wrong with the header handler. Also, I'm surprised that your school allows the use of AI ?

sorry what do you mean by header handler? and yes we are encouraged to use AI tools.

Here's an example:
Also, can you take a screenshot of it and censor/hide any contained API keys?

here it is, I do not know what went wrong
CleanShot 2024-04-09 at 21 57 49@2x

It could be an issue with your school's https://gpt-api.【school】.edu.cn/v1/chat/completions REST APIs (e.g., permissions related to CORS,region blocked because it used vercel to request into your school REST APIs). The request header is correct.

but I also tried to download the release version and use the api locally before. and another error showed up: { "error": true, "message": "Load failed" }

try this method:

image

in this case, should I fill in https://gpt-api.hkust-gz.edu.cn/api/proxy?
if so, the error still exists.

@H0llyW00dzZ
Copy link
Contributor

I think there might be something wrong with the header handler. Also, I'm surprised that your school allows the use of AI ?

sorry what do you mean by header handler? and yes we are encouraged to use AI tools.

Here's an example:
Also, can you take a screenshot of it and censor/hide any contained API keys?

here it is, I do not know what went wrong
CleanShot 2024-04-09 at 21 57 49@2x

It could be an issue with your school's https://gpt-api.【school】.edu.cn/v1/chat/completions REST APIs (e.g., permissions related to CORS,region blocked because it used vercel to request into your school REST APIs). The request header is correct.

but I also tried to download the release version and use the api locally before. and another error showed up: { "error": true, "message": "Load failed" }

try this method:
image

in this case, should I fill in https://gpt-api.hkust-gz.edu.cn/api/proxy? if so, the error still exists.

If your school's REST APIs support /api/proxy, then you can put https://gpt-api.hkust-gz.edu.cn/api/proxy in the API endpoint field. However, if the error still persists, it might indicate an issue with the school's REST APIs or the proxy configuration.

@A-l-an
Copy link
Author

A-l-an commented Apr 9, 2024

url = "https://gpt-api.【school】.edu.cn/v1/chat/completions"

the original reference url is https://gpt-api.【school】.edu.cn**/v1/chat/completions.**
all right, thanks for your considerate answer!! I guess I better check with the school's technician about this part.

@H0llyW00dzZ
Copy link
Contributor

H0llyW00dzZ commented Apr 9, 2024

url = "https://gpt-api.【school】.edu.cn/v1/chat/completions"

the original reference url is https://gpt-api.【school】.edu.cn**/v1/chat/completions.** all right, thanks for your considerate answer!! I guess I better check with the school's technician about this part.

Yes, it seems to be an issue related to permissions(e.g, CORS), which is why you got a forbidden access error.

@A-l-an
Copy link
Author

A-l-an commented Apr 10, 2024

url = "https://gpt-api.【school】.edu.cn/v1/chat/completions"

the original reference url is https://gpt-api.【school】.edu.cn**/v1/chat/completions.** all right, thanks for your considerate answer!! I guess I better check with the school's technician about this part.

Yes, it seems to be an issue related to permissions(e.g, CORS), which is why you got a forbidden access error.

They said the system must access to GPT-API by Campus Network (specified SSID required ).
I was wondering if this means there's no way out for this situation?

@QAbot-zh
Copy link

I think if you can run the reference code in your PC, then you can run it on the release program keeping the same network setting. They should not have any essential differences, both are sending requests to a third-party endpoint. What information will this return using https://gpt-api.hkust-gz.edu.cn on your release nextchat setting.

@A-l-an
Copy link
Author

A-l-an commented Apr 10, 2024

I think if you can run the reference code in your PC, then you can run it on the release program keeping the same network setting. They should not have any essential differences, both are sending requests to a third-party endpoint. What information will this return using https://gpt-api.hkust-gz.edu.cn on your release nextchat setting.

it returns:

{
  "error": true,
  "message": "Load failed"
}

@QAbot-zh
Copy link

which version

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


which version

@QAbot-zh
Copy link

QAbot-zh commented Apr 10, 2024

Perhaps the API offered by your school does not support for streaming responses? You could conduct a test using the subsequent illustration:

import requests
import json
import os

url = "xxxx/v1/chat/completions"
headers = { "Content-Type": "application/json", "Authorization": "Bearer xxx" }
data = { "model": "gpt-4",  "messages": [{"role": "user", "content": "Q"}], "stream": True }

response = requests.post(url, headers=headers, data=json.dumps(data), stream=True)
if response.status_code == 200:
   for chunk in response:
        print(chunk)
else:
    print(f"Error: {response.status_code}")

@A-l-an
Copy link
Author

A-l-an commented Apr 10, 2024

Perhaps the API offered by your school does not support for streaming responses? You could conduct a test using the subsequent illustration:

import requests
import json
import os

url = "xxxx/v1/chat/completions"
headers = { "Content-Type": "application/json", "Authorization": "Bearer xxx" }
data = { "model": "gpt-4",  "messages": [{"role": "user", "content": "Q"}], "stream": True }

response = requests.post(url, headers=headers, data=json.dumps(data), stream=True)
if response.status_code == 200:
   for chunk in response:
        print(chunk)
else:
    print(f"Error: {response.status_code}")

Ok. I got it. The Campus GPT API has been re – encapsulated so I could only access it by the reference code .... Thanks for your help.

@A-l-an A-l-an closed this as completed Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants