Git Product home page Git Product logo

gpt4free-ts's Introduction

GPT4Free TypeScript Version 🆓

Providing a free OpenAI GPT-4 API!

English | 中文 | 日本語

Discord Server

You can join our discord: discord.gg/gptgod for further updates. gpt4free Discord

🆓 Free OpenAI Key

Base URL: https://api.gptgod.online

Api Key: sk-OsMMq65tXdfOIlTUYtocSL7NCsmA7CerN77OkEv29dODg1EA

Support Models: gpt-4-all,gpt-3.5-turbo,gpt-3.5-turbo-16k,net-gpt-3.5-turbo,net-gpt-3.5-turbo-16k,claude-1-100k,google-palm,llama-2-70b,llama-2-13b,llama-2-7b,code-llama-34b,code-llama-13b,code-llama-7b,qwen-72b,stable-diffusion,mixtral-8x7b,mistral-medium

🚩 Reverse target

I suggest you fork this project first. Some websites may go offline at any time.

Still striving to keep updating.

Have implemented models here: If you do not want your website to appear here, please raise an issue and I will remove it immediately. Unfortunately, most of the sites here are no longer available.

Update At 2023-09-10

Site Models
you gpt-3.5-turbo
phind net-gpt-3.5-turbo
forefront gpt-3.5-turbo, claude
mcbbs gpt-3.5-turbo, gpt-3.5-turbo-16k
chatdemo gpt-3.5-turbo, gpt-3.5-turbo-16k
vita gpt-3.5-turbo
skailar gpt-4
fakeopen gpt-3.5-turbo, gpt-3.5-turbo-16k, gpt-4
easychat gpt-4
better gpt-3.5-turbo, gpt-3.5-turbo-16k, gpt-4
pweb gpt-3.5-turbo, gpt-3.5-turbo-16k
bai gpt-3.5-turbo
gra gpt-3.5-turbo, gpt-3.5-turbo-16k
magic gpt-3.5-turbo, gpt-4, claude-instance, claude, claude-100k
chim gpt-3.5-turbo, gpt-3.5-turbo-16k, gpt-4
ram gpt-3.5-turbo-16k
chur gpt-3.5-turbo, gpt-3.5-turbo-16k
xun gpt-3.5-turbo, gpt-3.5-turbo-16k
vvm gpt-3.5-turbo, gpt-3.5-turbo-16k, gpt-4
poef
claude claude-2-100k
cursor gpt-3.5-turbo, gpt-4
chatbase gpt-3.5-turbo
ails gpt-3.5-turbo
sincode gpt-3.5-turbo, gpt-4
openai too much
jasper gpt-3.5-turbo, gpt-4
pap
acytoo gpt-3.5-turbo
google search
www url
ddg search

🏃‍♂️ Run

First of all, you should create file .env.

All operation methods require this step.

http_proxy=http://host:port
rapid_api_key=xxxxxxxxxx
EMAIL_TYPE=temp-email44
DEBUG=0
POOL_SIZE=0
PHIND_POOL_SIZE=0
  • http_proxy: config your proxy if you can not access target website directly; If you dont need proxy, delete this line;
  • forefront use env(this site has been removed):
    • rapid_api_key: you should config this if you use forefront api, this apikey is used for receive register email, get api key here
    • EMAIL_TYPE: temp email type includes temp-email temp-email44 tempmail-lol
      • temp-email: soft limit 100req/days, if over use money, need bind credit card! Very Stable!
      • temp-email44: hard limit 100req/days! Stable!
      • tempmail-lol: nothing need, limit 25request/5min. Not Stable.
    • DEBUG: Valid when use forefront You can set =1 when you run local. show reverse process
    • POOL_SIZE: forefront concurrency size. Keep set=1 until you run it successfully!!! You can engage in {POOL_SIZE} conversations concurrently. More pool size, More conversation can be done simultaneously, But use more RAM
  • phind use env:
    • PHIND_POOL_SIZE: phind concurrency size.You can engage in {POOL_SIZE} conversations concurrently. More pool size, More conversation can be done simultaneously, But use more RAM

Run local 🖥️

# install module
yarn
# start server
yarn start

Run with docker(Suggest!) 🐳

docker run -p 3000:3000 --env-file .env xiangsx/gpt4free-ts:latest

Deploy with docker-compose 🎭

first, you should create file .env; Follow step "Run with docker

deploy

docker-compose up --build -d

Clash+one-api+gpt4free-ts Start with one command 😮

gpt4free-ts-deploy

🚀 Let's Use GPT4

Find supports model and site http://127.0.0.1:3000/supports [GET]

The same as openai http://127.0.0.1:3000/:site/v1/chat/completions [POST]

The same as openai http://127.0.0.1:3000/v1/chat/completions?site=xxx [POST]

Return when chat complete http://127.0.0.1:3000/ask?prompt=***&model=***&site=*** [POST/GET]

Return with eventstream http://127.0.0.1:3000/ask/stream?prompt=***&model=***&site=*** [POST/GET]

Request Params 📝

  • prompt: your question. It can be a string or jsonstr.
    • example jsonstr:[{"role":"user","content":"hello\n"},{"role":"assistant","content":"Hi there! How can I assist you today?"},{"role":"user","content":"who are you"}]
    • example string: who are you
  • model: default gpt3.5-turbo. model include:gpt4 gpt3.5-turbo net-gpt3.5-turbo gpt-3.5-turbo-16k
  • site: default you. target site, include fakeopen better forefront you chatdemo phind vita

Site Support Model 🧩

query supports site and models with api 127.0.0.1:3000/supports

[
  {
    "site": "you",
    "models": [
      "gpt-3.5-turbo"
    ]
  },
  ...
]

Response Params 🔙

Response when chat end(/ask):

interface ChatResponse {
    content: string;
    error?: string;
}

Response with stream like, Suggest!!(/ask/stream):

event: message
data: {"content":"I"}

event: done
data: {"content":"'m"}

event: error
data: {"error":"some thind wrong"}

Example💡

  1. request to site you with history

req:

127.0.0.1:3000/ask?site=you&prompt=[{"role":"user","content":"hello"},{"role":"assistant","content":"Hi there! How can I assist you today?"},{"role":"user","content":"who are you"}]

res:

{
  "content": "Hi there! How can I assist you today?"
}

127.0.0.1:3000/ask?site=you&prompt=[{"role":"user","content":"你好\n"},{"role":"assistant","content":"你好!有什么我可以帮助你的吗?"},{"role":"user","content":"你是谁"}]

  1. request to site you with stream return

req:

127.0.0.1:3000/ask/stream?site=you&prompt=who are you

res:

event: message
data: {"content":"I"}

event: message
data: {"content":"'m"}

event: message
data: {"content":" a"}

event: message
data: {"content":" search"}

event: message
data: {"content":" assistant"}
........
event: done
data: {"content":"done"}

👥 Chat Group

🌟 Star History

Star History Chart

You may join our discord: discord.gg/gpt4free for further updates. gpt4free Discord

This is a replication project for the typescript version of gpt4free

gpt4free logo

Legal Notice

This repository is not associated with or endorsed by providers of the APIs contained in this GitHub repository. This project is intended for educational purposes only. This is just a little personal project. Sites may contact me to improve their security or request the removal of their site from this repository.

Please note the following:

  1. Disclaimer: The APIs, services, and trademarks mentioned in this repository belong to their respective owners. This project is not claiming any right over them nor is it affiliated with or endorsed by any of the providers mentioned.

  2. Responsibility: The author of this repository is not responsible for any consequences, damages, or losses arising from the use or misuse of this repository or the content provided by the third-party APIs. Users are solely responsible for their actions and any repercussions that may follow. We strongly recommend the users to follow the TOS of the each Website.

  3. Educational Purposes Only: This repository and its content are provided strictly for educational purposes. By using the information and code provided, users acknowledge that they are using the APIs and models at their own risk and agree to comply with any applicable laws and regulations.

  4. Copyright: All content in this repository, including but not limited to code, images, and documentation, is the intellectual property of the repository author, unless otherwise stated. Unauthorized copying, distribution, or use of any content in this repository is strictly prohibited without the express written consent of the repository author.

  5. Indemnification: Users agree to indemnify, defend, and hold harmless the author of this repository from and against any and all claims, liabilities, damages, losses, or expenses, including legal fees and costs, arising out of or in any way connected with their use or misuse of this repository, its content, or related third-party APIs.

  6. Updates and Changes: The author reserves the right to modify, update, or remove any content, information, or features in this repository at any time without prior notice. Users are responsible for regularly reviewing the content and any changes made to this repository.

By using this repository or any code related to it, you agree to these terms. The author is not responsible for any copies, forks, or reuploads made by other users. This is the author's only account and repository. To prevent impersonation or irresponsible actions, you may comply with the GNU GPL license this Repository uses.

gpt4free-ts's People

Contributors

abobo7 avatar atorber avatar choogoo avatar dnlinyj avatar eltociear avatar hartosha avatar huanlinoto avatar icethecoder avatar neco86 avatar panxiao81 avatar ta-noshii avatar xchwarze avatar xiangsx avatar xiaoyao20084321 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gpt4free-ts's Issues

site: forefront报错

prompt=你能干什么?&model=gpt4&site=forefront
"error": "not support site: forefront "

浏览器启动失败,没有可用沙盒

DEBUG=1 的错误提示如下:
Error: Failed to launch the browser process! [33:33:0514/000848.532379:FATAL:zygote_host_impl_linux.cc(127)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/main/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox. [0514/000848.536864:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2) [0514/000848.536907:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2) TROUBLESHOOTING: https://pptr.dev/troubleshooting at ChildProcess.onClose (/usr/src/app/node_modules/@puppeteer/browsers/src/launch.ts:398:11) at ChildProcess.emit (node:events:525:35) at ChildProcess.emit (node:domain:489:12) at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)

DEBUG=0 的错误提示如下:
`> [email protected] start

ts-node index.ts
browser pool init size:1
Puppeteer old Headless deprecation warning:
In the near feature headless: true will default to the new Headless mode
for Chrome instead of the old Headless implementation. For more
information, please see https://developer.chrome.com/articles/new-headless/.
Consider opting in early by passing headless: "new" to puppeteer.launch()
If you encounter any bugs, please report them to https://github.com/puppeteer/puppeteer/issues/new/choose.
Error: Failed to launch the browser process!
[0514/001635.232990:FATAL:zygote_host_impl_linux.cc(127)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/main/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
TROUBLESHOOTING: https://pptr.dev/troubleshooting
at Interface.onClose (/usr/src/app/node_modules/@puppeteer/browsers/src/launch.ts:398:11)
at Interface.emit (node:events:525:35)
at Interface.emit (node:domain:489:12)
at Interface.close (node:internal/readline/interface:533:10)
at Socket.onend (node:internal/readline/interface:259:10)
at Socket.emit (node:events:525:35)
at Socket.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1359:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21)`

`version: "3.9"

services:
gpt4free-ts:
image: xiangsx/gpt4free-ts:latest
container_name: gpt4free-ts
ports:
- "3030:3000"
restart: always
cap_add:
- "SYS_ADMIN"
environment:
- http_proxy=http://10.0.0.10:1080
- rapid_api_key=4912c29cecmsh20ef05f89de857ep1c6458jsn4b65bXXXXXX
- DEBUG=1`

其中http://10.0.0.10:1080这个是能够正常访问外网的代理。
镜像是拉取的docker pull xiangsx/gpt4free-ts:latest

an image in Dockerhub

I created an image in Dockerhub that can be run to use the project.

docker run --env rapid_api_key =xxxx atorber/gpt4free-ts:latest

forefront 如何才能用 messages 来传递上下文

如何让 forefront 用上如下 mcbbs 中的 messages,这样才能用上下文,目前只有问一个问题

curl '127.0.0.1:3000/ask/stream?messages=[{"role":"system","content":"IMPORTANT: You are a virtual assistant powered by the gpt-3.5-turbo model, now time is 2023/6/3 13:42:27}"},{"role":"user","content":"你好\n"},{"role":"assistant","content":"你好!有什么我可以帮助你的吗?"},{"role":"user","content":"写个冒泡排序\n"}]&prompt=test&model=mcbbs&parse=false'

Docker container cannot startup

The docker container could not start up successfully.

And here's the log:

> [email protected] start
> ts-node index.ts

browser pool init size:1

  Puppeteer old Headless deprecation warning:
    In the near feature `headless: true` will default to the new Headless mode
    for Chrome instead of the old Headless implementation. For more
    information, please see https://developer.chrome.com/articles/new-headless/.
    Consider opting in early by passing `headless: "new"` to `puppeteer.launch()`
    If you encounter any bugs, please report them to https://github.com/puppeteer/puppeteer/issues/new/choose.

Error: Failed to launch the browser process!
/root/.cache/puppeteer/chrome/linux-113.0.5672.63/chrome-linux64/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory


TROUBLESHOOTING: https://pptr.dev/troubleshooting

    at Interface.onClose (/usr/src/app/node_modules/@puppeteer/browsers/src/launch.ts:398:11)
    at Interface.emit (node:events:525:35)
    at Interface.emit (node:domain:489:12)
    at Interface.close (node:internal/readline/interface:533:10)
    at Socket.onend (node:internal/readline/interface:259:10)
    at Socket.emit (node:events:525:35)
    at Socket.emit (node:domain:489:12)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

Read inbox is empty

你好,Docker 部署后 Temp Mail 后台显示一直在 Read Inbox,但是 Response Body 为空,导致 API 次数直接被刷光了。

Request Headers:

{
"host":"temp-mail44.p.rapidapi.com"
"x-amzn-trace-id":"Root=1-64882424-3eea47853386119c2f6ff716"
"x-forwarded-port":"443"
"x-forwarded-proto":"https"
"x-forwarded-for":"xx.xx.xx.xx"
"user-agent":"axios/1.4.0"
"accept-encoding":"gzip, compress, deflate, br"
"x-rapidapi-host":"temp-mail44.p.rapidapi.com"
"accept":"application/json, text/plain, */*"
}

Request Query Parameters:

{
"0":"{"
"1":"}"
}

Response Headers:

{
"content-type":"application/json; charset=UTF-8"
"x-rapidapi-region":"AWS - ap-southeast-1"
"connection":"close"
"x-ratelimit-requests-reset":"84028"
"x-rapidapi-version":"1.2.8"
"content-length":"3"
"server":"RapidAPI-1.2.8"
"x-ratelimit-requests-remaining":"3"
"x-ratelimit-requests-limit":"100"
}

Response Body:

{ }

forefront.ai 注册失败了

提示:Sign up unsuccessful due to failed security validations. Please refresh the page to try again or reach out to support for more assistance.

temp-email44,tempmail-lol 都是这个提示,不注册成功其他model用不了。

有其他办法在 forefront 注册失败的情况下用其他 model 嘛?

这是什么问题

SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse ()
at Mcbbs. (C:\Users\admin\Desktop\gpt4free-ts-master\model\mcbbs\index.ts:68:28)
at Generator.next ()
at C:\Users\admin\Desktop\gpt4free-ts-master\model\mcbbs\index.ts:8:71
at new Promise ()
at __awaiter (C:\Users\admin\Desktop\gpt4free-ts-master\model\mcbbs\index.ts:4:12)
at Mcbbs.askStream (C:\Users\admin\Desktop\gpt4free-ts-master\model\mcbbs\index.ts:49:16)
at Mcbbs. (C:\Users\admin\Desktop\gpt4free-ts-master\model\mcbbs\index.ts:46:32)
at Generator.next ()
at C:\Users\admin\Desktop\gpt4free-ts-master\model\mcbbs\index.ts:8:71
something error happened,err: Error: Error while obtaining verfication URL!
at Forefrontnew. (C:\Users\admin\Desktop\gpt4free-ts-master\model\forefront\index.ts:253:23)
at Generator.next ()
at fulfilled (C:\Users\admin\Desktop\gpt4free-ts-master\model\forefront\index.ts:28:58)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
init 0a57d7b6-1342-43a0-9d35-eeaf0383133a failed, delete! init new 5d5e38b9-0241-4442-9f9e-2c2ec281a04c
(node:30728) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead
(Use node --trace-deprecation ... to show where the warning was created)
something error happened,err: Error: Error while obtaining verfication URL!
at Forefrontnew. (C:\Users\11525\Desktop\gpt4free-ts-master\model\forefront\index.ts:253:23)
at Generator.next ()
at fulfilled (C:\Users\admin\Desktop\gpt4free-ts-master\model\forefront\index.ts:28:58)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
init 5d5e38b9-0241-4442-9f9e-2c2ec281a04c failed, delete! init new ceb4d3a6-0a7c-442f-bb56-7f663294e92e

Yarn Start Faild

When I try to start the program with Yarn I get the error:

/gpt4free-ts# yarn start
yarn run v1.22.19
$ ts-node index.ts
/gpt4free-ts/node_modules/tls-client/dist/sessions.js:44
this.clientIdentifier = options?.clientIdentifier;
^

SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Object.require.extensions. [as .js] (/var/docker/gpt4free-ts/node_modules/ts-node/src/index.ts:1608:43)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/var/docker/gpt4free-ts/node_modules/tls-client/dist/index.js:3:20)
at Module._compile (internal/modules/cjs/loader.js:999:30)
error Command failed with exit code 1.

佬们,启动报错了,怎么办

mijiangbo@mideMacBook-Pro gpt4free-ts % yarn start
yarn run v1.22.19
warning ../../package.json: No license field
$ ts-node index.ts
Now listening: 127.0.0.1:3000
init one failed, err: ProtocolError: Waiting for selector div > .mt-4 > div > .form-check > .form-check-label failed: Protocol error (Runtime.callFunctionOn): Target closed
at new Callback (/Users/mijiangbo/Downloads/gpt4free-ts/node_modules/puppeteer-core/src/common/Connection.ts:65:12)
at CallbackRegistry.create (/Users/mijiangbo/Downloads/gpt4free-ts/node_modules/puppeteer-core/src/common/Connection.ts:126:22)
at Connection._rawSend (/Users/mijiangbo/Downloads/gpt4free-ts/node_modules/puppeteer-core/src/common/Connection.ts:266:22)
at CDPSessionImpl.send (/Users/mijiangbo/Downloads/gpt4free-ts/node_modules/puppeteer-core/src/common/Connection.ts:525:29)
at ExecutionContext._ExecutionContext_evaluate (/Users/mijiangbo/Downloads/gpt4free-ts/node_modules/puppeteer-core/src/common/ExecutionContext.ts:305:44)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async CDPJSHandle.evaluateHandle (/Users/mijiangbo/Downloads/gpt4free-ts/node_modules/puppeteer-core/src/common/JSHandle.ts:87:12)
at async WaitTask.rerun (/Users/mijiangbo/Downloads/gpt4free-ts/node_modules/puppeteer-core/src/common/WaitTask.ts:159:22)
init f475221a-27a0-4c3f-94ff-5d2fb0b91b0d failed, delete! init new e3ba784c-34e0-42c2-86dc-ca642374ece2
f475221a-27a0-4c3f-94ff-5d2fb0b91b0d has been deleted
init one failed, err: ProtocolError: Waiting for selector div > .mt-4 > div > .form-check > .form-check-label failed: Protocol error (Runtime.callFunctionOn): Target closed
at new Callback (/Users/mijiangbo/Downloads/gpt4free-ts/node_modules/puppeteer-core/src/common/Connection.ts:65:12)
at CallbackRegistry.create (/Users/mijiangbo/Downloads/gpt4free-ts/node_modules/puppeteer-core/src/common/Connection.ts:126:22)
at Connection._rawSend (/Users/mijiangbo/Downloads/gpt4free-ts/node_modules/puppeteer-core/src/common/Connection.ts:266:22)
at CDPSessionImpl.send (/Users/mijiangbo/Downloads/gpt4free-ts/node_modules/puppeteer-core/src/common/Connection.ts:525:29)
at ExecutionContext._ExecutionContext_evaluate (/Users/mijiangbo/Downloads/gpt4free-ts/node_modules/puppeteer-core/src/common/ExecutionContext.ts:305:44)

Error: retry again, will sign up again

Hi. My requests were always rejected by forefront.

  • I'm using the latest commit
  • Using http proxy
  • Changing the UA
Error: retry again, will sign up again
    at Forefront.<anonymous> (C:\gpt4free-ts\model\forefront\index.ts:154:27)
    at Generator.throw (<anonymous>)
    at rejected (C:\gpt4free-ts\model\forefront\index.ts:6:65)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

I'm tracing the exceptions, and it says my request is unauthorized (it was working a few hours ago).

Here is the full exception log (it was too long to put inline here):
https://pastebin.com/XmUWgnRu

ffi-napi: Command failed

Hi,

yarn failed on my ubuntu 22.04, the error shows as below. How to solve it?

# yarn
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[2/2] ⡀ ffi-napi
error /root/workspace/gpt4free-ts/node_modules/ffi-napi: Command failed.
Exit code: 1
Command: node-gyp-build
Arguments:
Directory: /root/workspace/gpt4free-ts/node_modules/ffi-napi
Output:
events.js:291
      throw er; // Unhandled 'error' event
      ^

Error: spawn node-gyp EACCES
    at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
    at onErrorNT (internal/child_process.js:470:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
    at onErrorNT (internal/child_process.js:470:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'EACCES',
  code: 'EACCES',
  syscall: 'spawn node-gyp',
  path: 'node-gyp',
  spawnargs: [ 'rebuild' ]
}

Curl test failed

curl "http://127.0.0.1:3000/ask?prompt=hello"
AxiosError: Request failed with status code 401
AxiosError: Request failed with status code 401
at settle (/$HOME/gpt4free-ts/node_modules/axios/lib/core/settle.js:19:12)
at IncomingMessage.handleStreamEnd (/home/unclebiglu/repostories/gpt4free-ts/node_modules/axios/lib/adapters/http.js:570:11)
at IncomingMessage.emit (node:events:525:35)
at IncomingMessage.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1359:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21)

Internal Server Error

Error: Failed to launch the browser process! [ Podman ]

Bug description
Won't work with docker/podman when you running container
podman run -it --rm gpt4free-ts

Environement
Podman container

stdout:

> [email protected] start
> ts-node index.ts

browser pool init size:1

  Puppeteer old Headless deprecation warning:
    In the near feature `headless: true` will default to the new Headless mode
    for Chrome instead of the old Headless implementation. For more
    information, please see https://developer.chrome.com/articles/new-headless/.
    Consider opting in early by passing `headless: "new"` to `puppeteer.launch()`
    If you encounter any bugs, please report them to https://github.com/puppeteer/puppeteer/issues/new/choose.

Error: Failed to launch the browser process!
Check failed: sys_chroot("/proc/self/fdinfo/") == 0


TROUBLESHOOTING: https://pptr.dev/troubleshooting

    at ChildProcess.onClose (/usr/src/app/node_modules/@puppeteer/browsers/src/launch.ts:398:11)
    at ChildProcess.emit (node:events:525:35)
    at ChildProcess.emit (node:domain:489:12)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)

使用forefront出错:TimeoutError: Waiting for selector

  • 问题描述:

本地启动项目,使用you没问题,使用forefront出错,env设置了rapid_api_key

  • 控制台输出信息:
try find text input
try to find input
found
1
TimeoutError: Waiting for selector `.flex-1 > .flex:nth-child(1) > .relative > .grid > .post-markdown` failed: Waiting failed: 30000ms exceeded
    at Timeout.<anonymous> (/Users/xxxx/Work/gpt4free-ts/node_modules/puppeteer-core/src/common/WaitTask.ts:91:11)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7)

最新的镜像启动服务报错

这两个镜像都试了
xiangsx/gpt4free-ts:latest
xiangsx/gpt4free-ts:v0.0.16

启动报错:
node:internal/modules/cjs/loader:1078
throw err;
^

Error: Cannot find module '/usr/src/app/server'
at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
at Module._load (node:internal/modules/cjs/loader:920:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

Node.js v18.16.0

用npm install yarn后,出这个错误,不懂

ubuntu@ip-172-26-15-236:~/src/gpt4free-ts$ yarn start
yarn run v1.22.19
$ ts-node index.ts
/home/ubuntu/src/gpt4free-ts/node_modules/tls-client/dist/sessions.js:44
this.clientIdentifier = options?.clientIdentifier;
^

SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Object.require.extensions. [as .js] (/home/ubuntu/src/gpt4free-ts/node_modules/ts-node/src/index.ts:1608:43)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/home/ubuntu/src/gpt4free-ts/node_modules/tls-client/dist/index.js:3:20)
at Module._compile (internal/modules/cjs/loader.js:999:30)
error Command failed with exit code 1.

Error: Failed to launch the browser process!

错误如下 .env的DEBUG无论是0还是1都报相同的错误

root@vps2548886:~/gpt# docker run -p 3000:3000 --env-file .env xiangsx/gpt4free-ts:latest

[email protected] start
ts-node index.ts

browser pool init size:1

Puppeteer old Headless deprecation warning:
In the near feature headless: true will default to the new Headless mode
for Chrome instead of the old Headless implementation. For more
information, please see https://developer.chrome.com/articles/new-headless/.
Consider opting in early by passing headless: "new" to puppeteer.launch()
If you encounter any bugs, please report them to https://github.com/puppeteer/puppeteer/issues/new/choose.

Error: Failed to launch the browser process!
[0513/080411.738226:FATAL:zygote_host_impl_linux.cc(127)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/main/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.

TROUBLESHOOTING: https://pptr.dev/troubleshooting

at Interface.onClose (/usr/src/app/node_modules/@puppeteer/browsers/src/launch.ts:398:11)
at Interface.emit (node:events:525:35)
at Interface.emit (node:domain:489:12)
at Interface.close (node:internal/readline/interface:533:10)
at Socket.onend (node:internal/readline/interface:259:10)
at Socket.emit (node:events:525:35)
at Socket.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1359:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21)

Here is my phind.com support test

hello,here is my phind.com support test,windows test pass.

import fs from 'fs';
import puppeteer from 'puppeteer-extra';
import stealthPlugin from 'puppeteer-extra-plugin-stealth';
import TurndownService from 'turndown';
import pLimit from 'p-limit';
puppeteer.use(stealthPlugin());

const searchPhind = async (questions, concurrencyLimit) => {
  const searchTexts = questions.map(q => q.question);

  const search = async (searchText) => {
    const browser = await puppeteer.launch({
      headless: false,
      ignoreDefaultArgs: ["--enable-automation"],
      devtools: true,
      defaultViewport: {
        width: 1440,
        height: 900
      }
    });

    const page = await browser.newPage();
    const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.5615.138 Safari/537.36';
    await page.setUserAgent(userAgent);
    await page.goto('https://www.phind.com/', { waitUntil: 'networkidle2',timeout: 50000 });

    const textAreaSelector = 'textarea.form-control.bg-white.darkmode-light.searchbox-textarea';
    const submitButtonSelector = 'button.btn.p-2.rounded-0[type="submit"]';
    const thumbsUpSelector = 'i.fe.fe-thumbs-up.m-2';

    await page.waitForSelector(textAreaSelector, { timeout: 500000 });
    await page.waitForSelector(submitButtonSelector, { timeout: 500000 });
    await new Promise(r => setTimeout(r, 1500));

    for (const char of searchText) {
      await page.type(textAreaSelector, char);
      await new Promise(r => setTimeout(r, 100));
    }
    await new Promise(r => setTimeout(r, 500));

    await page.click(submitButtonSelector);
    await page.waitForSelector(thumbsUpSelector, { timeout: 50000 });
    await new Promise(r => setTimeout(r, 500));

    let answer = "";
    try {
      const parentDivContent = await page.evaluate(() => {
        const h6Elements = Array.from(document.querySelectorAll('h6.text-uppercase'));
        const answerElement = h6Elements.find(el => el.textContent.trim() === 'Answer');

        if (answerElement && answerElement.parentElement) {
          return answerElement.parentElement.innerHTML;
        }
        return null;
      });
      console.log('Parent Div Content:', parentDivContent);
      answer = parentDivContent;
    }
    catch (e) {
      console.log(e);
    }

    const turndownService = new TurndownService();
    const markdown = turndownService.turndown(answer);
    fs.writeFileSync("./questions/"+searchText + '_output.md', markdown);

    browser.close();
  };

  // 使用 p-limit 限制同时运行的线程数量
  const limit = pLimit(concurrencyLimit);
  //const tasks = searchTexts.map(searchText => limit(() => search(searchText)));
  const tasks = searchTexts.map(searchText => {
    return limit(async () => {
      try {
        await search(searchText);
      } catch (error) {
        console.error(`在搜索 "${searchText}" 时发生错误:`, error);
      }
    });
  });
  await Promise.all(tasks);
};

const questions = [
  { "question": "写一段简单的c++排序" },
  { "question": "如何使用JavaScript实现快速排序" },
  { "question": "Python中如何实现二叉树" },
  { "question": "使用Java实现一个简单的计算器" },
  { "question": "如何在C#中创建一个链表" },
  { "question": "JavaScript中如何实现防抖和节流" },
  { "question": "如何使用Python进行文件读写" },
  { "question": "Go语言中如何实现并发" },
  { "question": "在Ruby中实现一个简单的Web服务器" },
  { "question": "如何使用C++进行图像处理" },
  { "question": "在Node.js中如何搭建一个RESTful API" },
  { "question": "Swift中如何实现一个简单的iOS应用" },
  { "question": "如何在PHP中连接数据库" },
  { "question": "Kotlin中如何实现Android应用的基本功能" },
  { "question": "Rust中如何实现内存安全" },
  { "question": "Scala中如何实现并行计算" },
  { "question": "如何在TypeScript中创建类" },
  { "question": "Lua中如何实现表的操作" },
  { "question": "如何在Elixir中实现简单的并发" },
  { "question": "在Haskell中如何实现函数式编程" }
];
const concurrencyLimit = 1 // 最多同时1
searchPhind(questions, concurrencyLimit);

get crash with model You

the error log here

the strange message is from here,I added into it myself

image

> [email protected] start
> ts-node index.ts
Now listening: 127.0.0.1:3000
�
d
�
d
/usr/src/app/utils/index.ts:27
export function md5(str: string): string {
�
           ^
SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at /usr/src/app/model/you/index.ts:138:36
    at /usr/src/app/utils/index.ts:16:13
    at Generator.next (<anonymous>)
    at /usr/src/app/utils/index.ts:31:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/src/app/utils/index.ts:27:12)
    at /usr/src/app/utils/index.ts:48:16
    at wrappedMapper (/usr/src/app/node_modules/map-stream/index.js:83:19)
    at Stream.stream.write (/usr/src/app/node_modules/map-stream/index.js:95:21)

Cannot use forefront with status code 401

I am in china so I use a US proxy to connect to forefront.ai

this is my log

 3.7.9 ⬢  gpt4free-ts ⚡ master ◉ > yarn start
yarn run v1.22.19
$ ts-node index.ts
Now listening: 127.0.0.1:3000

  AxiosError: Request failed with status code 401
      at settle (D:\Project\gpt4free-ts\node_modules\axios\lib\core\settle.js:19:12)
      at IncomingMessage.handleStreamEnd (D:\Project\gpt4free-ts\node_modules\axios\lib\adapters\http.js:570:11)
      at IncomingMessage.emit (node:events:525:35)
      at IncomingMessage.emit (node:domain:489:12)
      at endReadableNT (node:internal/streams/readable:1359:12)
      at processTicksAndRejections (node:internal/process/task_queues:82:21)

I can use forefront by its webui, so I don't think it's a problem by my proxy

image

It seem that fail on create a temp mail😂

Error: forefront create account failed

I didn't use Docker to package the project. I ran Yarn Start locally and reported an error when using the following command:
curl " http://127.0.0.1:3000/ask?prompt=hello&model=forefront&gptmodel=gpt -4&resignup=1"
I am not very familiar with typescript language and cannot debug any errors. Can you provide me with some help? Thank you!
The error message is as follows:
yarn run v1.22.19 $ ts-node index.ts Now listening: 127.0.0.1:3000 Error: forefront create account failed at Forefront.<anonymous> (/home/gpt4free-ts-master/model/forefront/index.ts:230:19) at Generator.next (<anonymous>) at fulfilled (/home/gpt4free-ts-master/model/forefront/index.ts:5:58)

mac m1芯片运行amd64版本镜像报错,无法启动浏览器

[email protected] start
ts-node index.ts

Now listening: 127.0.0.1:3000
Error: Failed to launch the browser process! undefined
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[78:78:0608/011342.282710:ERROR:nacl_fork_delegate_linux.cc(313)] Bad NaCl helper startup ack (0 bytes)
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[47:128:0608/011342.422367:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[47:47:0608/011342.632939:ERROR:ozone_platform_x11.cc(239)] Missing X server or $DISPLAY
[47:47:0608/011342.633036:ERROR:env.cc(255)] The platform failed to initialize. Exiting.

TROUBLESHOOTING: https://pptr.dev/troubleshooting

at ChildProcess.onClose (/usr/src/app/node_modules/@puppeteer/browsers/src/launch.ts:398:11)
at ChildProcess.emit (node:events:525:35)
at ChildProcess.emit (node:domain:489:12)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)

Error: Failed to launch the browser process!
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[69:69:0608/011342.277389:ERROR:nacl_fork_delegate_linux.cc(313)] Bad NaCl helper startup ack (0 bytes)
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[44:126:0608/011342.418070:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[44:44:0608/011342.633099:ERROR:ozone_platform_x11.cc(239)] Missing X server or $DISPLAY
[44:44:0608/011342.633198:ERROR:env.cc(255)] The platform failed to initialize. Exiting.

TROUBLESHOOTING: https://pptr.dev/troubleshooting

at Interface.onClose (/usr/src/app/node_modules/@puppeteer/browsers/src/launch.ts:398:11)
at Interface.emit (node:events:525:35)
at Interface.emit (node:domain:489:12)
at Interface.close (node:internal/readline/interface:533:10)
at Socket.onend (node:internal/readline/interface:259:10)
at Socket.emit (node:events:525:35)
at Socket.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1359:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21)

Error: Failed to launch the browser process!
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[86:86:0608/011342.303118:ERROR:nacl_fork_delegate_linux.cc(313)] Bad NaCl helper startup ack (0 bytes)
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[50:136:0608/011342.442557:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[50:50:0608/011342.634191:ERROR:ozone_platform_x11.cc(239)] Missing X server or $DISPLAY
[50:50:0608/011342.634299:ERROR:env.cc(255)] The platform failed to initialize. Exiting.

TROUBLESHOOTING: https://pptr.dev/troubleshooting

at Interface.onClose (/usr/src/app/node_modules/@puppeteer/browsers/src/launch.ts:398:11)
at Interface.emit (node:events:525:35)
at Interface.emit (node:domain:489:12)
at Interface.close (node:internal/readline/interface:533:10)
at Socket.onend (node:internal/readline/interface:259:10)
at Socket.emit (node:events:525:35)
at Socket.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1359:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21)

some error

tls-client/dist/sessions.js:44
this.clientIdentifier = options?.clientIdentifier;
^

SyntaxError: Unexpected token '.'
at Object.compileFunction (vm.js:344:18)
at wrapSafe (internal/modules/cjs/loader.js:1048:15)
at Module._compile (internal/modules/cjs/loader.js:1082:27)
at Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
at Object.require.extensions. [as .js] (gpt4free-ts/node_modules/ts-node/src/index.ts:1608:43)
at Module.load (internal/modules/cjs/loader.js:982:32)
at Function.Module._load (internal/modules/cjs/loader.js:875:14)
at Module.require (internal/modules/cjs/loader.js:1022:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object. (gpt4free-ts/node_modules/tls-client/dist/index.js:3:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

docker部署出现错误

在azure vps下使用docker部署出现以下问题:

Now listening: 127.0.0.1:3000
please wait init.....about 1 min
Error: Failed to launch the browser process!
[30:45:0610/024706.490497:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[30:30:0610/024706.962278:ERROR:ozone_platform_x11.cc(239)] Missing X server or $DISPLAY
[30:30:0610/024706.962962:ERROR:env.cc(255)] The platform failed to initialize.  Exiting.
[0610/024707.062028:ERROR:nacl_helper_linux.cc(355)] NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly


TROUBLESHOOTING: https://pptr.dev/troubleshooting

    at Interface.onClose (/usr/src/app/node_modules/@puppeteer/browsers/src/launch.ts:398:11)
    at Interface.emit (node:events:525:35)
    at Interface.emit (node:domain:489:12)
    at Interface.close (node:internal/readline/interface:533:10)
    at Socket.onend (node:internal/readline/interface:259:10)
    at Socket.emit (node:events:525:35)
    at Socket.emit (node:domain:489:12)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.