pawanosman / chatgpt Goto Github PK
View Code? Open in Web Editor NEWOpenAI API Free Reverse Proxy
Home Page: https://discord.pawan.krd
License: GNU Affero General Public License v3.0
OpenAI API Free Reverse Proxy
Home Page: https://discord.pawan.krd
License: GNU Affero General Public License v3.0
The API support fine-tuning models or using already fine-tuned ones? If not, it will do or could do one of this two things in the future?
First of all, thank you for providing such a good unofficial API for ChatGPT.
I'm only see that only 1 API is provided, is there any API to continue conversations or reset conversations?
Thank you.
When I run on local machine, everything works fine but when I host on vercel, it gives me this error:
0zYMVkVnH2lQHf6kQuJS9ZPoEWyGzk3Hx1ZUUV712CXEmpqVUf3u8xJ2MsqXmUP31dQSOXSzaatdesLhddpOSFD1YF7-Ic3gyxDtNL1v8wEsgAYiBq9HbTrA0u2ZFxorSrvPkqh9M8IJaXfRUcc9FH4ccKml70HDQLB9KRqHGpXwdtMAKX0WeyakCr8JEql05lCHaSwLZkrbf1Cgg9q1dk7vB59L-RouIDl-SasfjdUR_ZNQHEVMzZIkVfRXmvk3SDP6j8Vn2QUjpLIhAqRippV5njWMFROHEpV2Rb_YxzZyq7SwssRFBs6QTJNerOBy6s5Aw44s0GdgkIyWpwT77Kpx59-Z6PQTes1cUj__xM-W9SIw03-M14JQw5003b4AQLT3Gouuk82WpwT5uC0VsnKvHXUOhZNRXtXW0MVuX5kpTiIird4TuIDwKysj7-fbBIY83wSiZCowbjsvqSeyA2IXPb9V5z9cFzBhKtwf5quzdPfsXTyTVabt8HMWKt50fUonI_M4tLndrH23Ww0vPx8ueWYG_CzldJDiLl1uSoO9IdHO0w-J1HknLI4k2YOMlz_he6EuCNjhF-03i_kBjK0KNX90cDQcUdetPVBb33GiHCtGPAUc6T8LXDQlLyJNo21lav_Uw_EZbip6zjLWvd9HdKpzfOIYcjGzqTXGfv0CDDkvCyHIOQy6tACG2Mbk0oBdzXItZlu-Iw699qYyZplRw3tOQhnArrpQea44F3KLN4syROlCsnwBuTD4DWsSU8v2SR">
</form>
</div>
</div>
<script>
(function(){
window._cf_chl_opt={
cvId: '2',
cZone: 'api.pawan.krd',
cType: 'managed',
cNounce: '6099',
cRay: '7ba4cec11a5e81df',
cHash: 'de5f89c15e550af',
cUPMDTk: "\/v1\/chat\/completions?__cf_chl_tk=.Sl0VSiGXrsGOZMQ03UalG7ZGd4pGp0yOzZALNgwyU0-1681903744-0-gaNycGzNDCU",
cFPWv: 'b',
cTTimeMs: '1000',
cMTimeMs: '0',
cTplV: 5,
cTplB: 'cf',
cK: "",
cRq: {
ru: 'aHR0cHM6Ly9hcGkucGF3YW4ua3JkL3YxL2NoYXQvY29tcGxldGlvbnM=',
ra: 'T3BlbkFJL3YxIFB5dGhvbkJpbmRpbmdzLzAuMjcuNA==',
rm: 'UE9TVA==',
d: 'ARVxa9Ipodt9xb5qCvWHq3reeclxXu+/Rzen2IbcqChH/CBfJ9aNW2jAgg1uQIxHoXT+gCyxgOHb7o0yDlzFa5HSAjncDDfIr6MiLtsjn87zNd+aL80gIFcIDQxcTWD/ndik0UgsYLbd3X415zXryW8bAwsiUspcEGJnmG5YdekLPxVQdL2d4RvQ1dKwWEGYoBNnlzFqVoDfQogeaYVaBTYz6SncEMMgcX9G6paje4F76rNkjQU8jO+enHtQhjbC2NQEsI8+O8g6HChiOAnuwTwxMqtf1rINfisEwWtxW21e2B9Hhvl5nvueeT23qYf1WN94HY2dktyVdOlNnhvgwhmcV7spC5Uf7g8TGhz4k1yBaZfkCzCmND/BmZtgthJCDruxEtQm5/E6aSMqYJgODWfQX8tlTgyPUtkzIkemN3ME5q8VFklT7GN2KJf9PRCcr8LozmrkiTa1CIc2qg0XfSSzmRer0sxPf+ruZ63P0dAS8BGlAlYwcs6+gpGqcGurZSHpwWN+jNWmuVaSFumQFVVYWmrQIYpFXvQtiRqVHFT0rJl28TqFQwRmuQTY5Ha0',
t: 'MTY4MTkwMzc0NC4xODAwMDA=',
m: 'm1k/hLri2RO6jB0l3yAucEEDdRsovsh7gfGF6GD8/0E=',
i1: 'QJnLReyGXQL8UTLQE2SY/w==',
i2: 'xTsEeY8XEquCzScXTBD0yw==',
zh: 'zZ3AeV7xP77LO8Ln8FNsB21TQiZhu5GG0RFrp7R/Cmw=',
uh: 'FBQ1H9QDQTncwlqokqQjvIq6Klr88Rm74Ic+061kzcc=',
hh: 'm3vKriM0iUeqvcDJYjmPuwBe01Dq6K2oBTw+OWRrQZ4=',
}
};
var trkjs = document.createElement('img');
trkjs.setAttribute('src', '/cdn-cgi/images/trace/managed/js/transparent.gif?ray=7ba4cec11a5e81df');
trkjs.setAttribute('alt', '');
trkjs.setAttribute('style', 'display: none');
document.body.appendChild(trkjs);
var cpo = document.createElement('script');
cpo.src = '/cdn-cgi/challenge-platform/h/b/orchestrate/managed/v1?ray=7ba4cec11a5e81df';
window._cf_chl_opt.cOgUHash = location.hash === '' && location.href.indexOf('#') !== -1 ? '#' : location.hash;
window._cf_chl_opt.cOgUQuery = location.search === '' && location.href.slice(0, location.href.length - window._cf_chl_opt.cOgUHash.length).indexOf('?') !== -1 ? '?' : location.search;
if (window.history && window.history.replaceState) {
var ogU = location.pathname + window._cf_chl_opt.cOgUQuery + window._cf_chl_opt.cOgUHash;
history.replaceState(null, null, "\/v1\/chat\/completions?__cf_chl_rt_tk=.Sl0VSiGXrsGOZMQ03UalG7ZGd4pGp0yOzZALNgwyU0-1681903744-0-gaNycGzNDCU" + window._cf_chl_opt.cOgUHash);
cpo.onload = function() {
history.replaceState(null, null, ogU);
};
}
document.getElementsByTagName('head')[0].appendChild(cpo);
}());
</script>
</body>
</html>
)
I am using the Python OpenAI method instead of making requests. I've tried using requests but it says no prompt was provided every time I use it EVEN if I gave it a prompt.
How do I deploy this on vercel?
Great project! I wanted to see where this project is going. I am looking for a proxy server so that I can deploy a smart agent on my website that is publically accessible. I wanted to log sessions in the middleware so I can eventually use LangChain and chat summaries for the end users of my app. Thanks, again.
Would be super useful if possible! If not thanks anyway for this tool :)
Based on the documentations, I ran npm start
, but it didn't work and returned an error message indicating that there is no start
script. Did I miss something?
import openai
openai.api_key = my_key
openai.api_base = 'https://api.pawan.krd/v1'
response = openai.completions.create(
model="text-davinci-003",
prompt="Human: Hello\nAI:",
temperature=0.7,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
stop=["Human: ", "AI: "]
)
print(response.choices[0].text)
openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: pk-MNLTc***************************************CqBD. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}
The same error, when I use openai.api_base = 'https://api.pawan.krd/pai-001-light-beta/v1'
BTW you should update your README because openai.Completion is no longer support with openai higher than 0.28
Fix cors origin issue.
Access to fetch at 'https://gpt.pawan.krd/api/completions' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
When ever I try I'm getting this response,
My entire code is
<body>
<label for="prompt">Prompt:</label>
<textarea id="prompt" rows="4"></textarea>
<button onclick="generateText()">Generate Text</button>
<label for="generated-text">Generated Text:</label>
<div id="output"></div>
<script>
function generateText() {
const prompt = document.getElementById('prompt').value;
const url = 'https://gpt.pawan.krd/api/completions';
const payload = {
"prompt": prompt,
"temperature": 0.7,
"max_tokens": 256,
"top_p": 0.9,
"frequency_penalty": 0,
"presence_penalty": 0,
"model": "text-davinci-003",
"stop": ""
}
const headers = {
'Authorization': 'Bearer <API from Discord>',
'Content-Type': 'application/json'
}
fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.text())
.then(text => {
document.getElementById('output').innerText = text;
})
.catch(error => console.error(error));
}
</script>
</body>
Hi All,
I am trying to use the hosted API but I always get this message: You have already used an API key on this IP address myIP. I reset the api in discore Bot but again the message appears when I try the api as shown below:
Request:
curl --location 'https://api.pawan.krd/v1/completions'
--header 'Authorization: Bearer pk-myapikey'
--header 'Content-Type: application/json'
--data '{
"model": "text-davinci-003",
"prompt": "Human: Hello\nAI:",
"temperature": 0.7,
"max_tokens": 256,
"stop": [
"Human:",
"AI:"
]
}'
Response:
{
"status": false,
"error": "You have already used an API key on this IP address myip",
"hint": "You can get support from https://discord.pawan.krd",
"info": "https://gist.github.com/PawanOsman/72dddd0a12e5829da664a43fc9b9cf9a",
"support": "https://discord.pawan.krd"
}
I send request like:
curl --location 'https://api.pawan.krd/v1/chat/completions' \
--header 'Authorization: Bearer pk-***[OUR_API_KEY]***' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-3.5-turbo",
"max_tokens": 100,
"messages": [
{
"role": "system",
"content": "You are an helpful assistant."
},
{
"role": "user",
"content": "Who are you?"
}
]
}'
I got following response:
{"status":false,"error":{"message":"We couldn't find the model "gpt-3.5-turbo", join our discord server if you have any questions, https://discord.pawan.krd","type":"invalid_request_error"},"support":"https://discord.pawan.k
public class Main {
public static void main(String[] args) {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.pawan.krd/chat/gpt?text=hello")
.build();
try {
Response response = client.newCall(request).execute();
String responseBody = response.body().string();
System.out.println(responseBody);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Responce:
<html>
<head><title>502 Bad Gateway</title><script src="/cdn-cgi/apps/head/dYMkwc06fJ_hgAqAMinzib-CLyo.js"></script></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>openresty</center>
<script>(function(){var js = "window['__CF$cv$params']={r:'79b820001f4836dd',m:'I9LtAGxe2vQftngWibqkAOSaJkWdl9.GKH.HkDRaync-1676737592-0-ARvKa/MkfLXgDd/u5qccaUo9pLoTb0rH1ejUHlAI3Ftc+5kjDtQzjyyBLx1sBMXDhBueFWEQ+13PXuhNCclRQg01q/7sZ/IHMMAmq28u17Opb+5RNWt59VZo7qva9x3iQWjxbG+nni9Oc4oWIeuYCs0=',s:[0x790cdb083e,0x124aa35753],u:'/cdn-cgi/challenge-platform/h/g'};var now=Date.now()/1000,offset=14400,ts=''+(Math.floor(now)-Math.floor(now%offset)),_cpo=document.createElement('script');_cpo.nonce='',_cpo.src='/cdn-cgi/challenge-platform/h/g/scripts/alpha/invisible.js?ts='+ts,document.getElementsByTagName('head')[0].appendChild(_cpo);";var _0xh = document.createElement('iframe');_0xh.height = 1;_0xh.width = 1;_0xh.style.position = 'absolute';_0xh.style.top = 0;_0xh.style.left = 0;_0xh.style.border = 'none';_0xh.style.visibility = 'hidden';document.body.appendChild(_0xh);function handler() {var _0xi = _0xh.contentDocument || _0xh.contentWindow.document;if (_0xi) {var _0xj = _0xi.createElement('script');_0xj.nonce = '';_0xj.innerHTML = js;_0xi.getElementsByTagName('head')[0].appendChild(_0xj);}}if (document.readyState !== 'loading') {handler();} else if (window.addEventListener) {document.addEventListener('DOMContentLoaded', handler);} else {var prev = document.onreadystatechange || function () {};document.onreadystatechange = function (e) {prev(e);if (document.readyState !== 'loading') {document.onreadystatechange = prev;handler();}};}})();</script></body>
</html>
I tried this but its giving me weird result that chatgpt would no way going to say.
Prompt: are u chatgpt?
const response = await ai.createCompletion({
model: 'text-davinci-003',
prompt: 'are u chatgpt?',
temperature: 0.7,
max_tokens: 256,
top_p: 1,
frequency_penalty: 0,
presence_penalty: 0
})
ChatGPT is a chatbot platform developed by OpenAI. It uses natural language processing (NLP) to create automated conversations with users, allowing them to ask questions and get answers in real-time.
Yes, I am ChatGPT, a large language model trained by OpenAI, based on the GPT-3.5 architecture. How can I assist you today?
Hello,
I'm trying to use the public proxy (https://api.pawan.krd/) with the unofficial ChatGPT API, but I'm running into a 500 error ("No bypass servers available. please wait 5 mins and try again.") when calling /backend-api/ endpoints. I attached a screenshot of my output after doing the request in Insomnia below.
Thank you.
So I was trying to use a http://127.0.0.1:5000/ local flask app with the python implementation, and I got the error for the ip address, and that was when I set it to http://127.0.0.1:5000/, but now all i get is
{
"status": false,
"error": {
"message": "Invalid request, or Something went wrong!",
"type": "invalid_request_error"
}
}
why is that?
I started the proxy on my machine, but it failed to forward request, and always, the error information is:
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'ip' of undefined
at rateLimitMiddleware (file:///root/ChatGPT/middlewares.js:13:160)
at Layer.handle [as handle_request] (/root/ChatGPT/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/root/ChatGPT/node_modules/express/lib/router/index.js:328:13)
at /root/ChatGPT/node_modules/express/lib/router/index.js:286:9
at Function.process_params (/root/ChatGPT/node_modules/express/lib/router/index.js:346:12)
at next (/root/ChatGPT/node_modules/express/lib/router/index.js:280:10)
at corsMiddleware (file:///root/ChatGPT/middlewares.js:9:5)
at Layer.handle [as handle_request] (/root/ChatGPT/node_modules/express/lib/router/layer.js:95:5)
How can I solve this issue?
root@vps:/home/chatgptapi/ChatGPT# npm start
[email protected] start
node index.js
file:///home/chatgptapi/ChatGPT/routes.js:18
if (DEBUG) console.log([Text] [MAX-TOKENS:${req.body.max_tokens ?? "unset"}] ${req.body.prompt}
);
^
SyntaxError: Unexpected token '?'
at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18)
root@vps:/home/chatgptapi/ChatGPT#
If I use a browser it works though.
i m trying to use self host api. return response incorrect api while api is correct.
I am trying to use proxies on servers in Hong Kong and Japan https://api.pawan.krd/v1/completions ,
But they were all rejected, and it works normally under localhost. What can I do to use proxies on servers in Hong Kong and Japan https://api.pawan.krd/v1/completions
{ "status": false, "error": { "message": "Please wait a few minutes and try again!", "type": "api_not_ready_or_request_error" } }
Hello, when i run the code on my vps and put the ip of my vps inside my gpt code it wont work, it will only work if i run my gpt code in my vps, how can i host this repo inside my vps and make it work with my gpt code?
Can I self-host like your API: https://api.pawan.krd/backend-api/conversation
From [https://platform.openai.com/docs/api-reference/chat/object]
The attribut created is a integer and represent "The Unix timestamp (in seconds) of when the chat completion was created."
It's clearly not a time in second return by your API . Exemple: 1706937715819 not fit in a integer which cause exception.
Is it a community maintained API or something like? If yes, what if it reach
too high costs? You will limit the number of API keys or something?
import openai
openai.api_key = '' # For self-hosted version you can leave it empty
openai.base_url = "http://localhost:3040/v1" # For self-hosted version, use "http://localhost:3040/v1"
completion = openai.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "How do I list all files in a directory using Python?"},
],
)
print(completion.choices[0].message.content)
(env) PS E:\DEV\Chatgpt test> py .\main.py
Traceback (most recent call last):
File "E:\DEV\Chatgpt test\env\Lib\site-packages\httpx\_transports\default.py", line 69, in map_httpcore_exceptions
yield
File "E:\DEV\Chatgpt test\env\Lib\site-packages\httpx\_transports\default.py", line 233, in handle_request
resp = self._pool.handle_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\httpcore\_sync\connection_pool.py", line 216, in handle_request
raise exc from None
File "E:\DEV\Chatgpt test\env\Lib\site-packages\httpcore\_sync\connection_pool.py", line 196, in handle_request
response = connection.handle_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\httpcore\_sync\connection.py", line 101, in handle_request
return self._connection.handle_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\httpcore\_sync\http11.py", line 143, in handle_request
raise exc
File "E:\DEV\Chatgpt test\env\Lib\site-packages\httpcore\_sync\http11.py", line 93, in handle_request
self._send_request_headers(**kwargs)
File "E:\DEV\Chatgpt test\env\Lib\site-packages\httpcore\_sync\http11.py", line 151, in _send_request_headers
with map_exceptions({h11.LocalProtocolError: LocalProtocolError}):
File "C:\Python312\Lib\contextlib.py", line 155, in __exit__
self.gen.throw(value)
File "E:\DEV\Chatgpt test\env\Lib\site-packages\httpcore\_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.LocalProtocolError: Illegal header value b'Bearer '
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "E:\DEV\Chatgpt test\env\Lib\site-packages\openai\_base_client.py", line 931, in _request
response = self._client.send(
^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\httpx\_client.py", line 914, in send
response = self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\httpx\_client.py", line 942, in _send_handling_auth
response = self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\httpx\_client.py", line 979, in _send_handling_redirects
response = self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\httpx\_client.py", line 1015, in _send_single_request
response = transport.handle_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\httpx\_transports\default.py", line 232, in handle_request
with map_httpcore_exceptions():
File "C:\Python312\Lib\contextlib.py", line 155, in __exit__
self.gen.throw(value)
File "E:\DEV\Chatgpt test\env\Lib\site-packages\httpx\_transports\default.py", line 86, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.LocalProtocolError: Illegal header value b'Bearer '
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "E:\DEV\Chatgpt test\main.py", line 6, in <module>
completion = openai.chat.completions.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\openai\_utils\_utils.py", line 275, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\openai\resources\chat\completions.py", line 667, in create
return self._post(
^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\openai\_base_client.py", line 1213, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\openai\_base_client.py", line 902, in request
return self._request(
^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\openai\_base_client.py", line 955, in _request
return self._retry_request(
^^^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\openai\_base_client.py", line 1026, in _retry_request
return self._request(
^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\openai\_base_client.py", line 955, in _request
return self._retry_request(
^^^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\openai\_base_client.py", line 1026, in _retry_request
return self._request(
^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\openai\_base_client.py", line 965, in _request
raise APIConnectionError(request=request) from err
openai.APIConnectionError: Connection error.
import openai
openai.api_key = 'stringexample' # For self-hosted version you can leave it empty
openai.base_url = "http://localhost:3040/v1" # For self-hosted version, use "http://localhost:3040/v1"
completion = openai.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "How do I list all files in a directory using Python?"},
],
)
print(completion.choices[0].message.content)
(env) PS E:\DEV\Chatgpt test> py .\main.py
Traceback (most recent call last):
File "E:\DEV\Chatgpt test\main.py", line 6, in <module>
completion = openai.chat.completions.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\openai\_utils\_utils.py", line 275, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\openai\resources\chat\completions.py", line 667, in create
return self._post(
^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\openai\_base_client.py", line 1213, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\openai\_base_client.py", line 902, in request
return self._request(
^^^^^^^^^^^^^^
File "E:\DEV\Chatgpt test\env\Lib\site-packages\openai\_base_client.py", line 993, in _request
raise self._make_status_error_from_response(err.response) from None
openai.NotFoundError: Error code: 404 - {'status': False, 'error': {'message': 'The requested endpoint was not found. please make sure to use "http://localhost:3040/v1" as the base URL.', 'type': 'invalid_request_error'},
'support': 'https://discord.pawan.krd'}
(env) PS E:\DEV\Chatgpt test>
If I ask large question problem it always say Hello! I am ChatGPT, a language model developed by OpenAI. How can I assist you today?.Please fix
Based on the description here, I try to use the reverse proxy provided by this project via ChatGPT as follows, but failed:
$ CHATGPT_BASE_URL=https://api.pawan.krd/backend-api python3 -m revChatGPT.V1
ChatGPT - A command-line interface to OpenAI's ChatGPT (https://chat.openai.com/chat)
Repo: github.com/acheong08/ChatGPT
Type '!help' to show a full list of commands
Press Esc followed by Enter or Alt+Enter to send a message.
You:
Hello.
Chatbot:
{"status":false,"error":"Invalid API key","hint":"You can get an API key from https://discord.pawan.krd","info":"https://gist.github.com/PawanOsman/72dddd0a12e5829da664a43fc9b9cf9a","support":"https://discord.pawan.krd"}
Traceback (most recent call last):
File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V1.py", line 962, in main
for data in chatbot.ask(prompt):
File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V1.py", line 449, in ask
self.__check_response(response)
File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V1.py", line 58, in wrapper
out = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V1.py", line 557, in __check_response
raise error
revChatGPT.typings.Error: OpenAI: {"status":false,"error":"Invalid API key","hint":"You can get an API key from https://discord.pawan.krd","info":"https://gist.github.com/PawanOsman/72dddd0a12e5829da664a43fc9b9cf9a","support":"https://discord.pawan.krd"} (code: 400)
Please check that the input is correct, or you can resolve this issue by filing an issue
Project URL: https://github.com/acheong08/ChatGPT
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V1.py", line 986, in <module>
main(configure())
File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V1.py", line 58, in wrapper
out = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V1.py", line 972, in main
raise error from e
revChatGPT.typings.CLIError: command line program unknown error
Please check that the input is correct, or you can resolve this issue by filing an issue
Project URL: https://github.com/acheong08/ChatGPT
I wonder how to obtain the corresponding access_token
for this alternative reverse proxy to make the configuration file for the above usage. See here for the related discussion.
for using in node js do I need to install any other library
It seems like LangChain is unable to parse the response returned by the reverse proxy as the json object is missing the id
and created
fields. Tested with the 2 fields added and it works well. Would it be possible to add in these 2 fields in the json response? The values for these 2 keys can be null
.
OpenAI's official API:
{
"id": "cmpl-7ANU4Oi82ua4aJZJxK88r7AGqpxzc",
"object": "text_completion",
"created": 1682707908,
"model": "text-ada-001",
"choices": [
{
"text": "\n\nYes, this is a test.",
"index": 0,
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 9,
"total_tokens": 19
}
}
Reverse proxy:
{
"object": "text_completion",
"model": "text-davinci-003",
"choices": [
{
"text": " This is a test.",
"index": 0,
"finish_reason": "stop",
"logprobs": null
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 5,
"total_tokens": 15
}
}
The Chat Completion API doesn't remember my previous prompts and its previous responses.
Here is my first JavaScript request code:
fetch('https://api.pawan.krd/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer pk-***[OUR_API_KEY]***',
'Content-Type': 'application/json'
},
body: JSON.stringify({
'model': 'gpt-3.5-turbo',
'max_tokens': 100,
'messages': [
{
'role': 'user',
'content': 'Can I give you a nickname?'
}
],
'user': 'b17ffc32-e43f-11ed-b5ea-0242ac120002'
})
});
The AI then responds with:
Sure, you can give me a nickname.
Here is my follow-up JavaScript request code:
fetch('https://api.pawan.krd/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer pk-***[OUR_API_KEY]***',
'Content-Type': 'application/json'
},
body: JSON.stringify({
'model': 'gpt-3.5-turbo',
'max_tokens': 100,
'messages': [
{
'role': 'user',
'content': 'Your nickname is Xcross'
}
],
'user': 'b17ffc32-e43f-11ed-b5ea-0242ac120002'
})
});
The AI then responds with:
As an AI language model, I do not have a nickname. However, if you would like to refer to me as Xcross, you are welcome to do so.
I then send:
fetch('https://api.pawan.krd/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer pk-***[OUR_API_KEY]***',
'Content-Type': 'application/json'
},
body: JSON.stringify({
'model': 'gpt-3.5-turbo',
'max_tokens': 100,
'messages': [
{
'role': 'user',
'content': 'What did I say your nickname was again?'
}
],
'user': 'b17ffc32-e43f-11ed-b5ea-0242ac120002'
})
});
It responds with:
As an AI language model, you did not say my nickname as I do not have one.
Am I doing something wrong?
Just a quick question: I need to download all the files or just config.js in order to make the reverse proxy works?
I resume that the max_tokens is, but when I set a little larger, the result is empty.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
<script src="/cdn-cgi/apps/head/dYMkwc06fJ_hgAqAMinzib-CLyo.js"></script></head>
<body>
<pre>Cannot POST /v1/v1/chat/completions</pre>
<script>(function(){var js = "window['__CF$cv$params']={r:'7c18a4cfefb2c082',m:'TdleDOGxwfwMaYropzInOVm8yAdSnKJtZgU0lwpbsm8-1683118374-0-AdohaiLUtnHFnZlXhU6mfRBcoOt9pAwrxn+c+O2B4kGM',u:'/cdn-cgi/challenge-platform/h/g'};_cpo=document.createElement('script');_cpo.nonce='',_cpo.src='/cdn-cgi/challenge-platform/scripts/invisible.js',document.getElementsByTagName('head')[0].appendChild(_cpo);";var _0xh = document.createElement('iframe');_0xh.height = 1;_0xh.width = 1;_0xh.style.position = 'absolute';_0xh.style.top = 0;_0xh.style.left = 0;_0xh.style.border = 'none';_0xh.style.visibility = 'hidden';document.body.appendChild(_0xh);function handler() {var _0xi = _0xh.contentDocument || _0xh.contentWindow.document;if (_0xi) {var _0xj = _0xi.createElement('script');_0xj.nonce = '';_0xj.innerHTML = js;_0xi.getElementsByTagName('head')[0].appendChild(_0xj);}}if (document.readyState !== 'loading') {handler();} else if (window.addEventListener) {document.addEventListener('DOMContentLoaded', handler);} else {var prev = document.onreadystatechange || function () {};document.onreadystatechange = function (e) {prev(e);if (document.readyState !== 'loading') {document.onreadystatechange = prev;handler();}};}})();</script></body>
</html>
请问https://api.pawan.krd/backend-api/conversation 反向代理已经停止维护了吗?
The Discord invitation link in the ReadME section is expired.
I try to test this project using the example here but failed:
(datasci) werner@X10DAi:~$ ipython
Python 3.11.1 (main, Dec 22 2022, 17:06:07) [GCC 12.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.7.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import requests
...:
...: def get_response(text, lang):
...: params = {'text': text, 'lang': lang}
...: response = requests.get('https://api.pawan.krd/chat/gpt', params=param
...: s)
...: return response.json()
...:
...: response = get_response('Hello', 'en')
...: print(response)
---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
File ~/.pyenv/versions/3.11.1/envs/datasci/lib/python3.11/site-packages/requests/models.py:971, in Response.json(self, **kwargs)
970 try:
--> 971 return complexjson.loads(self.text, **kwargs)
972 except JSONDecodeError as e:
973 # Catch JSON-related errors and raise as requests.JSONDecodeError
974 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError
File ~/.pyenv/versions/3.11.1/lib/python3.11/json/__init__.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
343 if (cls is None and object_hook is None and
344 parse_int is None and parse_float is None and
345 parse_constant is None and object_pairs_hook is None and not kw):
--> 346 return _default_decoder.decode(s)
347 if cls is None:
File ~/.pyenv/versions/3.11.1/lib/python3.11/json/decoder.py:337, in JSONDecoder.decode(self, s, _w)
333 """Return the Python representation of ``s`` (a ``str`` instance
334 containing a JSON document).
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
File ~/.pyenv/versions/3.11.1/lib/python3.11/json/decoder.py:355, in JSONDecoder.raw_decode(self, s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
JSONDecodeError Traceback (most recent call last)
Cell In[1], line 8
5 response = requests.get('https://api.pawan.krd/chat/gpt', params=params)
6 return response.json()
----> 8 response = get_response('Hello', 'en')
9 print(response)
Cell In[1], line 6, in get_response(text, lang)
4 params = {'text': text, 'lang': lang}
5 response = requests.get('https://api.pawan.krd/chat/gpt', params=params)
----> 6 return response.json()
File ~/.pyenv/versions/3.11.1/envs/datasci/lib/python3.11/site-packages/requests/models.py:975, in Response.json(self, **kwargs)
971 return complexjson.loads(self.text, **kwargs)
972 except JSONDecodeError as e:
973 # Catch JSON-related errors and raise as requests.JSONDecodeError
974 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError
--> 975 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Is there any problem with my usage?
This filed when I use OpenAI API works well: "model": "gpt-3.5-turbo", but when I changed it into current API, the response contains this: {"id":"cmpl-...,"created":1683331180268,"model":"text-davinci-003", the main problem that fields are not readable by this API.
Every time the mobile internet is reconnected in Turkey and the modem restarts on cable internet, the ip address changes. That's why we need to get the key again.
Is it possible to change the limitation of the IP address with another alternative limitation method?
With the current implementation, it's quite easy to detect that there are multiple calls coming from the same IP but using different API keys, which eventually leads to getting the API keys and related accounts blocked.
It would be great to have some support to rotate between proxies and API key combinations, this makes it harder to correlate the API keys and used IP's, resulting in less accounts blocked.
Sometimes, strange garbage appears in server responses. I wrote a function to remove it, but it doesn't work very well. Maybe it can be fixed on the server side. With the original GPTchat, there is no such problem.
Garbage in the server response - two symbols �� instead of a letter in the word.
использовать
-> испол��зовать
request
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=messages,
max_tokens=max_tok,
temperature=temp,
timeout=timeou
)
response = completion.choices[0].message.content
bad respond
Kir: Obsidian и Notion - это два разных инструмента, каждый со своими преимуществами и недостатками. Однако, вы можете использовать их совместно, чтобы получить максимальную выгоду от обоих инструментов.
Вот несколько способов, которыми вы можете использовать Obsidian и Notion вместе:
Хран��те свои заметки в Obsidian, а документацию и проекты в Notion. Вы можете использовать Obsidian для хранения своих личных заметок, идей и мыслей, а Notion - для хранения документации по проектам, задачам и другой информации, которую вы хотите поделиться со своей командой.
Используйте Notion для создания базы знаний, а Obsidian - для ее расширения. Вы можете использовать Notion для создания базы знаний, а затем испол��зовать Obsidian для расширения ее функционала, добавления новых заметок и связей между ними.
Используйте Notion для управления задачами, а Obsidian - для создания связей между ними. Вы можете использовать Notion для управления своими задачами и планами, а затем использовать Obsidian для создания связей между ними и другой информацией, которая может помочь вам выполнить задачи более эффективно.
function to fix
def check_and_fix_text(text):
"""Trying to fix the strange feature of the that GPT server, which often makes a mistake in a word and inserts 2 question marks instead of a letter"""
ru = enchant.Dict("ru_RU")
# Removing everything from the text except for Russian letters, replacing 2 strange characters with 1 to simplify the regex
text = text.replace('��', '⁂')
russian_letters = re.compile('[^⁂а-яА-ЯёЁ\s]')
text2 = russian_letters.sub(' ', text)
words = text2.split()
for word in words:
if '⁂' in word:
suggestions = ru.suggest(word)
if len(suggestions) > 0:
text = text.replace(word, suggestions[0])
# If it was not possible to find a suitable word from the dictionary, the character is simply removed. It's better to have a typo than garbage.
return text.replace('⁂', '')
Check whether the packaged docker image exists in the deployment
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.