Showing preview only (1,661K chars total). Download the full file or copy to clipboard to get everything.
Repository: xiangsx/gpt4free-ts
Branch: master
Commit: 9eb7eca33e32
Files: 175
Total size: 1.6 MB
Directory structure:
gitextract_6_d41i1o/
├── .dockerignore
├── .github/
│ └── workflows/
│ └── docker-image.yml
├── .gitignore
├── .prettierrc
├── Dockerfile
├── HowToUse.md
├── LICENSE.txt
├── README.md
├── README_ja.md
├── README_zh.md
├── asyncstore.ts
├── docker-compose.yaml
├── index.ts
├── koa.d.ts
├── model/
│ ├── acytoo/
│ │ └── index.ts
│ ├── ails/
│ │ └── index.ts
│ ├── airoom/
│ │ └── index.ts
│ ├── airops/
│ │ └── index.ts
│ ├── askx/
│ │ └── index.ts
│ ├── auto.ts
│ ├── bai/
│ │ └── index.ts
│ ├── base.ts
│ ├── better/
│ │ └── index.ts
│ ├── bibi/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── bing/
│ │ └── index.ts
│ ├── bingcopilot/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── chatbase/
│ │ └── index.ts
│ ├── chatdemo/
│ │ └── index.ts
│ ├── chatgateai/
│ │ ├── index.ts
│ │ └── test.js
│ ├── chim/
│ │ └── index.ts
│ ├── chur/
│ │ └── index.ts
│ ├── claude/
│ │ └── index.ts
│ ├── claudeapi/
│ │ └── index.ts
│ ├── claudeauto/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── copilot/
│ │ └── index.ts
│ ├── cursor/
│ │ └── index.ts
│ ├── ddg/
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── test.js
│ ├── define.ts
│ ├── discord/
│ │ ├── child.ts
│ │ └── define.ts
│ ├── doc2x/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── domo/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ ├── prompt.ts
│ │ └── test.js
│ ├── easychat/
│ │ └── index.ts
│ ├── fakeopen/
│ │ └── index.ts
│ ├── fireworks/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── flux/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── forefront/
│ │ └── index.ts
│ ├── freegpt35/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── freegpt4/
│ │ ├── define.ts
│ │ └── index.ts
│ ├── gemini/
│ │ ├── define.ts
│ │ └── index.ts
│ ├── glm/
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── google/
│ │ └── index.ts
│ ├── gptgod/
│ │ └── index.ts
│ ├── gra/
│ │ └── index.ts
│ ├── groq/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── hypotenuse/
│ │ └── index.ts
│ ├── ideogram/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── index.ts
│ ├── izea/
│ │ └── index.ts
│ ├── jasper/
│ │ └── index.ts
│ ├── langdock/
│ │ └── index.ts
│ ├── magic/
│ │ └── index.ts
│ ├── mcbbs/
│ │ └── index.ts
│ ├── merlin/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── merlingmail/
│ │ ├── child.ts
│ │ └── index.ts
│ ├── midjourney/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── mixer/
│ │ └── index.ts
│ ├── mjplus/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── mjweb/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── myshell/
│ │ └── index.ts
│ ├── navit/
│ │ └── index.ts
│ ├── oneapi/
│ │ └── index.ts
│ ├── openai/
│ │ └── index.ts
│ ├── openaiauto/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── openprompt/
│ │ └── index.ts
│ ├── opensess/
│ │ └── index.ts
│ ├── pap/
│ │ └── index.ts
│ ├── perauto/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── perlabs/
│ │ ├── cfpool.ts
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── perplexity/
│ │ └── index.ts
│ ├── phind/
│ │ └── index.ts
│ ├── pika/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── poe/
│ │ └── define.ts
│ ├── pweb/
│ │ └── index.ts
│ ├── ram/
│ │ └── index.ts
│ ├── runway/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── sincode/
│ │ └── index.ts
│ ├── skailar/
│ │ └── index.ts
│ ├── stack/
│ │ └── index.ts
│ ├── suno/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── takeoff/
│ │ └── index.ts
│ ├── td/
│ │ └── index.ts
│ ├── toyy/
│ │ └── index.ts
│ ├── vanus/
│ │ └── index.ts
│ ├── vidu/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── vita/
│ │ └── index.ts
│ ├── vvm/
│ │ └── index.ts
│ ├── www/
│ │ └── index.ts
│ └── xun/
│ └── index.ts
├── package.json
├── router.ts
├── tsconfig.json
└── utils/
├── cache.ts
├── captcha.ts
├── config.ts
├── emailFactory.ts
├── file.ts
├── index.ts
├── log.ts
├── middleware.ts
├── pool.ts
├── proxyAgent.ts
├── puppeteer.ts
└── web.ts
================================================
FILE CONTENTS
================================================
================================================
FILE: .dockerignore
================================================
run/
node_modules/
.git
.idea
================================================
FILE: .github/workflows/docker-image.yml
================================================
# docker-image.yml
name: Publish Docker image # workflow名称,可以在Github项目主页的【Actions】中看到所有的workflow
on: # 配置触发workflow的事件
push:
tags: # tag更新时触发此workflow
- '*'
jobs: # workflow中的job
push_to_registry: # job的名字
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest # job运行的基础环境
steps: # 一个job由一个或多个step组成
- name: Check out the repo
uses: actions/checkout@v2 # 官方的action,获取代码
- name: Log in to Docker Hub
uses: docker/login-action@v1 # 三方的action操作, 执行docker login
with:
username: ${{ secrets.DOCKERHUB_USERNAME }} # 配置dockerhub的认证,在Github项目主页 【Settings】 -> 【Secrets】 添加对应变量
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3 # 抽取项目信息,主要是镜像的tag
with:
images: ${{ secrets.DOCKER_IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v2 # docker build & push
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
================================================
FILE: .gitignore
================================================
.idea/
.vscode/
yarn-error.log
package-lock.json
node_modules/
.env
run/
,
================================================
FILE: .prettierrc
================================================
{
"printWidth": 80,
"singleQuote": true,
"trailingComma": "all",
"proseWrap": "never",
"overrides": [{ "files": ".prettierrc", "options": { "parser": "json" } }],
"plugins": ["prettier-plugin-organize-imports", "prettier-plugin-packagejson"]
}
================================================
FILE: Dockerfile
================================================
FROM xiangsx/chrome:118.0.5993.70
USER root
WORKDIR /usr/src/build
COPY package.json /usr/src/build/
ENV NODE_ENV=dev
RUN npm i --registry=https://registry.npmmirror.com
COPY . /usr/src/build
RUN npm run build && \
find ./dist -name "*.js" -exec npx terser {} -o {} \; && \
mkdir -p /usr/src/app && \
cp -r ./dist/* /usr/src/app/ && \
cp -r ./node_modules /usr/src/app/ && \
rm -rf /usr/src/build
WORKDIR /usr/src/app
VOLUME [ "/usr/src/app/run" ]
EXPOSE 3000
CMD ["node", "index.js"]
================================================
FILE: HowToUse.md
================================================
## 1. 项目接口介绍
- /supports 查询项目支持哪些站点和哪些model
- /ask 简化后的请求和返回参数格式,后面会说明参数格式,等整个对话完成再返回
- /ask/stream 简化后的请求和返回参数格式,流式返回
- /:site/v1/chat/completions 和openai一致的请求和返回格式,需要把`:site`更换成`/supports`查询出来的`site`和`model`
## 2. 环境变量以及配置文件详细解释
### 2.1 环境变量
`.env`,运行之前需要删掉所有注释,不然会有问题,这里为了方便直接写在字段后面了,注意如果使用`docker-compose` 请直接把环境变量写到`docker-compose.yaml`中
```
http_proxy=http://127.0.0.1:7890 #这里改为你的代理地址
RETRY=1 # 请求失败自动重试1次
rapid_api_key=${rapid_api_key} # 临时邮箱需要的key
EMAIL_TYPE=tempmail-lol # 使用的临时邮箱类型
COPILOT_POOL_SIZE=0 # copilot 账号数目
POE_POOL_SIZE=0 # 同上
# 多个用|分割
POE_PB=xxxxx|xxxxxx # poe的登录pb
#是否使用免费账号 1:不会校验账号是否是会员直接使用
POE_ALLOW_FREE=1
#是否忽略剩余数直接使用,1: 不论剩余多少都会尝试发送消息 0:剩余0之后就不发送了
POE_USE_IGNORE_LEFT=1
OEPNPROMPT_POOL_SIZE=0
#perplexity 需要的配置是下面3个
CHROME_PATH=google-chrome # 如果在容器中运行固定配置这个,不用修改
PERPLEXITY_POOL_SIZE=0
# 多个用|分割
PERPLEXITY_TOKEN=xxxxxx|xxxxxxx
# sincode站点相关变量,注意email和password要一一对应,多个用|分割
SINCODE_EMAIL=xxx|xxx|xxx
SINCODE_PASSWORD=xxx|xxx|xxx
SINCODE_POOL_SIZE=4
```
### 2.2 配置文件解释
run/config.json 负载均衡配置文件,需要把docker文件映射出来, 映射示例 `./run:/usr/src/app/run`,**此文件可以在运行时修改,修改会实时生效**
配置好之后,接口site的值传auto
配置文件示例:
```
{
"site_map": {
"gpt-4": [
{
"site": "poe",
"priority": 20
},
{
"site": "perplexity",
"priority": 20
}
],
"gpt-3.5-turbo": [
{
"site": "bai",
"priority": 50
},
{
"site": "copilot",
"priority": 0
},
{
"site": "pweb",
"priority": 0
},
{
"site": "chur",
"priority": 10
},
{
"site": "poe",
"priority": 20
},
{
"site": "chatbase",
"priority": 30
}
],
"gpt-3.5-turbo-16k": [
{
"site": "chur",
"priority": 20
},
{
"site": "openprompt",
"priority": 30
},
{
"site": "poe",
"priority": 30
}
]
}
}
```
## 3. 部署教程
### 3.1 Docker
### 3.2 Docker Compose(推荐)
安装docker-compose 自行寻找教程安装
私人镜像需要运行命令
```shell
docker login
# 输入用户名密码
```
以使用poe为例,首先创建`docker-compose.yaml`文件
```
version: "3.9"
services:
gpt4free:
image: gpt4freets/gpt4free-ts:v0.0.46-private
ports:
- "3000:3000"
restart: always
volumes:
- ./run:/usr/src/app/run
environment:
- http_proxy=http://127.0.0.1:7890
- POE_PB=xxxxxxx|xxxxxxxxxxxxx
- POE_POOL_SIZE=1
```
在`docker-compose.yaml`同级目录下,使用命令
```
docker-compose up -d
```
成功运行!访问 `服务地址:3000/poe/v1/chat/completions` 即可使用api
### 3.3 Sealos
### 3.4 Windows 版本docker
## 4. 接口参数说明
## 5. 接入其他平台教程
### 5.1 接入one api平台
### 5.2 接入沉浸式翻译
================================================
FILE: LICENSE.txt
================================================
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
================================================
FILE: README.md
================================================
<div align="center">
# GPT4Free TypeScript Version 🆓
###### Providing a free OpenAI GPT-4 API!
English | [中文](README_zh.md) | [日本語](README_ja.md)
[](https://discord.gg/cYUU8mCDMd)
<p>You can join our discord: <a href="https://discord.gg/cYUU8mCDMd">discord.gg/gptgod<a> for further updates. <a href="https://discord.gg/cYUU8mCDMd"><img align="center" alt="gpt4free Discord" width="22px" src="https://raw.githubusercontent.com/peterthehan/peterthehan/master/assets/discord.svg" /></a></p>
</div>
## 🆓 Free OpenAI Key
WebSite: [https://gptgod.online](https://gptgod.online)
Api 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.***
```env
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](https://rapidapi.com/Privatix/api/temp-mail): soft limit 100req/days, if over use money, need bind credit card! Very Stable!
- [temp-email44](https://rapidapi.com/calvinloveland335703-0p6BxLYIH8f/api/temp-mail44): 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 🖥️
```shell
# 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](https://github.com/xiangsx/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`
```json
[
{
"site": "you",
"models": [
"gpt-3.5-turbo"
]
},
...
]
```
### Response Params 🔙
Response when chat end(/ask):
```typescript
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:
```json
{
"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":"你是谁"}]]()
2. 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
<image src="https://github.com/xiangsx/gpt4free-ts/assets/29322721/311ba62d-e611-4aed-98f6-b34cf115866a" width=240 />
## 🌟 Star History
[](https://star-history.com/#xiangsx/gpt4free-ts&&type=Date)
<p>You may join our discord: <a href="https://discord.com/invite/gpt4free">discord.gg/gpt4free<a> for further updates. <a href="https://discord.gg/gpt4free"><img align="center" alt="gpt4free Discord" width="22px" src="https://raw.githubusercontent.com/peterthehan/peterthehan/master/assets/discord.svg" /></a></p>
This is a replication project for the typescript version of [gpt4free](https://github.com/xtekky/gpt4free)
<img alt="gpt4free logo" src="https://user-images.githubusercontent.com/98614666/233799515-1a7cb6a3-b17f-42c4-956d-8d2a0664466f.png">
## Legal Notice <a name="legal-notice"></a>
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.
================================================
FILE: README_ja.md
================================================
<div align="center">
# GPT4Free の TypeScript バージョン 🆓
###### OpenAI GPT-4 API を無償で提供!
[English](README.md) | [中文](README_zh.md) | 日本語
[](https://discord.gg/bbH68Kzm)
<p>私達の discord: <a href="https://discord.gg/bbH68Kzm">discord.gg/gptgod<a> で続報を確認してください。 <a href="https://discord.gg/bbH68Kzm"><img align="center" alt="gpt4free Discord" width="22px" src="https://raw.githubusercontent.com/peterthehan/peterthehan/master/assets/discord.svg" /></a></p>
</div>
## 👍 GPT4 ウェブサイト 本企画のベース [GPTGOD](http://gptgod.site)
<details>
<summary><strong>ウェブサイトの特徴(クリックすると拡大します)</strong></summary>
### GPTGOD サポート
- [x] Midjourney 史上最強の AI 描画システム。
- [x] Stable Diffusion
- [x] Claude
- [x] ChatGPT
- [x] インターネット接続可能な ChatGPT
- [x] wechat の AI ロボットを自分で作ろう
今後 2 週間で、GPTGOD の全コードをオープンソース化する予定です。もし必要であれば、このプロジェクトを見るか、私をフォローして通知を受け取ってください。
をフォローしてください。
なぜ今なのかというと、このプロジェクトにはまだいくつかの秘密設定が残っていて、それを削除する必要があるからです。
</details>
## 🚩 リバースターゲット
今も更新を続けている。
ここにモデルを実装しています:
もし、あなたのウェブサイトがここに表示されることを望まないなら、問題を提起してください、私はすぐにそれを削除します。
|モデル|サポート|ステータス|アクティブタイム|
|--|--|--|--|
|[ai.mcbbs.gq](https://ai.mcbbs.gq)|gpt3.5||after 2023-06-03|
|[forefront.ai](https://chat.forefront.ai)|👍GPT-4/gpt3.5||after 2023-06-03|
|[aidream](http://aidream.cloud)|GPT-3.5||after 2023-05-12|
|[you.com](you.com)|GPT-3.5||after 2023-05-12
|[phind.com](https://www.phind.com/)|GPT-4 / Internet / good search||
|[bing.com/chat](bing.com/chat)|GPT-4/3.5||
|[poe.com](poe.com)| GPT-4/3.5||
|[writesonic.com](writesonic.com)| GPT-3.5 / Internet||
|[t3nsor.com](t3nsor.com)|GPT-3.5||
## 🏃♂️ 実行
まず、`.env` というファイルを作成する必要があります。
> ***すべての操作方法において、このステップが必要です。***
```env
http_proxy=http://host:port
rapid_api_key=xxxxxxxxxx
EMAIL_TYPE=temp-email44
DEBUG=0
POOL_SIZE=3
```
- `http_proxy`: 直接アクセスできない場合は、プロキシを設定してください
- `rapid_api_key`: forefront の api を使用する場合、この設定を行う必要があります。この api キーは登録メールの受信に使用されます
- `EMAIL_TYPE`: temp email type には `temp-email` `temp-email44` `tempmail-lol` があります
- [temp-email](https://rapidapi.com/Privatix/api/temp-mail): soft limit 100 req/日、使い過ぎるとクレジットカードの縛りが必要です!非常に安定しています!
- [temp-email44](https://rapidapi.com/calvinloveland335703-0p6BxLYIH8f/api/temp-mail44): hard limit 100 req/days!安定している!
- [tempmail-lol](): 25 req/5 分まで。安定しない。
- `DEBUG`: `forefront` 使用時に有効 local 実行時に =1 が設定できます。リバースプロセスを表示します。
- `POOL_SIZE`: `forefront` の同時実行サイズです。同時に {POOL_SIZE} の会話をすることができます。プールサイズを大きくすると、より多くの会話を同時に行うことができますが、より多くの RAM を使用します
### ローカル実行 🖥️
```shell
# install module
yarn
# start server
yarn start
```
### docker で実行する 🐳
```
docker run -p 3000:3000 --env-file .env xiangsx/gpt4free-ts:latest
```
### docker-compose でデプロイする 🎭
まず、.env ファイルを作成します; "docker で実行する"の手順に従ってください
デプロイ
```
docker-compose up --build -d
```
## 🚀 GPT4 を使ってみよう
> チャットが完了したらリターン http://127.0.0.1:3000/ask?prompt=***&model=***
> イベントストリームで返す http://127.0.0.1:3000/ask/stream?prompt=***&model=***
### 共通パラメータ📝
- `prompt`: あなたの質問
- `model`: ターゲット Web サイト:`forefront` `you` `mcbbs`
### WebSite Unique パラメータ🔒
- mcbbs
- `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"}]`
- `temperature`: 0~1
### 例
- `forefront`
- http://127.0.0.1:3000/ask?prompt=whoareyou&model=forefront
- http://127.0.0.1:3000/ask/stream?prompt=whoareyou&model=forefront
- `mcbbs`
- [http://127.0.0.1:3000/ask?prompt=nothing&model=mcbbs&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"}]](http://127.0.0.1:3000/ask?prompt=nothing&model=mcbbs&messages=[{%22role%22:%22system%22,%22content%22:%22IMPORTANT:%20You%20are%20a%20virtual%20assistant%20powered%20by%20the%20gpt-3.5-turbo%20model,%20now%20time%20is%202023/6/3%2013:42:27}%22},{%22role%22:%22user%22,%22content%22:%22%E4%BD%A0%E5%A5%BD\n%22},{%22role%22:%22assistant%22,%22content%22:%22%E4%BD%A0%E5%A5%BD%EF%BC%81%E6%9C%89%E4%BB%80%E4%B9%88%E6%88%91%E5%8F%AF%E4%BB%A5%E5%B8%AE%E5%8A%A9%E4%BD%A0%E7%9A%84%E5%90%97%EF%BC%9F%22},{%22role%22:%22user%22,%22content%22:%22%E5%86%99%E4%B8%AA%E5%86%92%E6%B3%A1%E6%8E%92%E5%BA%8F\n%22}])
- `you`
- http://127.0.0.1:3000/ask?prompt=whoareyou&model=you
- http://127.0.0.1:3000/ask/stream?prompt=whoareyou&model=you
## 🌟 Star History
[](https://star-history.com/#xiangsx/gpt4free-ts&&type=Date)
<p>You may join our discord: <a href="https://discord.com/invite/gpt4free">discord.gg/gpt4free<a> for further updates. <a href="https://discord.gg/gpt4free"><img align="center" alt="gpt4free Discord" width="22px" src="https://raw.githubusercontent.com/peterthehan/peterthehan/master/assets/discord.svg" /></a></p>
This is a replication project for the typescript version of [gpt4free](https://github.com/xtekky/gpt4free)
<img alt="gpt4free logo" src="https://user-images.githubusercontent.com/98614666/233799515-1a7cb6a3-b17f-42c4-956d-8d2a0664466f.png">
## Legal Notice <a name="legal-notice"></a>
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.
================================================
FILE: README_zh.md
================================================
<div align="center">
# GPT4Free TypeScript Version 🆓
###### 提供免费的GPT4 API
[English](README.md) | 中文 | [日本語](README_ja.md)
[](https://discord.gg/cYUU8mCDMd)
<p>你可以加入discord: <a href="https://discord.gg/cYUU8mCDMd">discord.gg/gptgod<a> 以获取项目最新进展. <a href="https://discord.gg/cYUU8mCDMd"><img align="center" alt="gpt4free Discord" width="22px" src="https://raw.githubusercontent.com/peterthehan/peterthehan/master/assets/discord.svg" /></a></p>
</div>
## 🆓 免费OpenAI key
如果你不想部署,直接用下面的key
官网: [https://gptgod.online](https://gptgod.online)
API 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`
## 👍 基于此项目的最强网站 [GPTGOD](http://gptgod.online)
### GPTGOD Support
下面所有功能可以直接在网站内使用,也可创建api调用,并且可以直接扫码集成到微信机器人上
- [x] Midjourney 史上最强AI画图
- [x] Stable Diffusion 史上最强开源AI画图
- [x] Claude 仅次于GPT4的AI对话模型
- [x] gpt3.5-turbo 都知道
- [x] gpt4 都知道
- [x] gpt-4-32k 都知道
- [x] claude-2-100k 无敌的上下文
- [x] Chatgpt with internet 联网版本GPT
- [x] 🔥 GPT-4-All alltools版本,集成识图、画图、联网和code interpreter
- [x] 🔥 GPTS 可以使用openai的所有的GPTs
在未来的一段时间GPTGOD将开源,进入网站左下角有入群二维码,入群时刻关注最新动态
## 🚩 Reverse target
仍在努力保持更新,使用人数太多, 更新赶不上封的速度
现不公开部分站点了
⭐最新站点支持,部分站点未公开,加群获取, 点击展开⭐
这里是已经实现转换成api的网站列表以及支持的对话模型,如果你不幸发现你的网站也在其中,请联系我,我会立刻下线
***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 |
## 🏃♂️ 运行
首先,你需要创建环境变量文件 `.env`.
> ***所有运行部署方式都需要这个步骤,包括运行在本地.***
```env
http_proxy=http://host:port
rapid_api_key=xxxxxxxxxx
EMAIL_TYPE=temp-email44
DEBUG=0
POOL_SIZE=0
PHIND_POOL_SIZE=3
```
- `http_proxy`: 你的本地代理,目前仅支持http协议,如果是国外的机器不需要配置此行,直接删除;如果是国内的,必须配置,请务必注意。
- 使用`forefront`才需要配置的env(该站点已被移除,下面可以不用配置):
- `rapid_api_key`: 如果你使用forefront,这个必填,为了接收临时邮箱
- `EMAIL_TYPE`: `forefront`临时邮箱类型 `temp-email` `temp-email44` `tempmail-lol`
- [temp-email](https://rapidapi.com/Privatix/api/temp-mail): 软限制 免费100请求/days 如果超过了 每条收0.0038$ 具体查看下方网站,官方api非常稳定
- [temp-email44](https://rapidapi.com/calvinloveland335703-0p6BxLYIH8f/api/temp-mail44): 硬限制 免费100req/days! 超过就会报错,也很稳定
- [tempmail-lol](): 什么都不需要配置 硬限制 25request/5min. 不怎么稳定.
- `DEBUG`: `forefront`专属配置 设置成1,会显示运行过程
- `POOL_SIZE`: 默认配置成1,修改之前确定你可以运行成功,并且知道此值的含义!!!`forefront` 可以同时进行的对话数目,数值越大,同时进行的对话数越多,但是使用的内存越大,如果个人使用设置1即可
- 使用`phind`才需要的配置
- `PHIND_POOL_SIZE`: 默认配置成=3,`phind` 可以同时进行的对话数目,数值越大,同时进行的对话数越多,但是使用的内存越大,如果个人使用设置1即可
### 本地运行 🖥️
```shell
# install module
yarn
# start server
yarn start
```
### 使用Docker运行 🐳
```
docker run -p 3000:3000 --env-file .env xiangsx/gpt4free-ts:latest
```
### 使用 docker-compose 运行 🎭
```
docker-compose up --build -d
```
### 一站式整合clash+one-api+gpt4free-ts 无脑一键启动 😮
该项目整合了onapi(开箱即用的api售卖平台) + clash(项目运行所需代理) + upma(项目监控) + gpt4free-ts(项目本体)
[gpt4free-ts-deploy](https://github.com/xiangsx/gpt4free-ts-deploy)
### 使用Sealos详细部署教程 🌐
[详细教程](https://icloudnative.io/posts/completely-free-to-use-gpt4/)
## 🚀 Let's Use GPT4
> 查看目前支持的site以及model http://127.0.0.1:3000/supports [GET]
> 和openai一致的返回格式 http://127.0.0.1:3000/:site/v1/chat/completions [POST]
>
> 和openai一致的返回格式 http://127.0.0.1:3000/v1/chat/completions?site=xxx [POST]
> 会话完成之后返回示例 http://127.0.0.1:3000/ask?prompt=***&model=***&site=*** [POST/GET]
> 以stream模式返回示例 http://127.0.0.1:3000/ask/stream?prompt=***&model=***&site=*** [POST/GET]
### 请求参数,请放在query里 📝
- `prompt`: 你的问题,类型是`string` 或者 `jsonstr`.
- `jsonstr`:包含上下文的json字符串,例如:`[{"role":"user","content":"你好\n"},{"role":"assistant","content":"你好!有什么我可以帮助你的吗?"},{"role":"user","content":"你是谁"}]`
- `string`: 单次对话 例如:`你是谁`
- `model`: 默认 `gpt3.5-turbo`. 模型:`gpt4` `gpt3.5-turbo`
- `site`: 默认 `you`. 目标网站 `fakeopen` `better` `forefront` `you` `chatdemo`
### 网站支持模型类型 🧩
查询当前支持的站点和模型 `127.0.0.1:3000/supports` 站点随时会更新,加微信群吧
```json
[
{
"site": "you",
"models": [
"gpt-3.5-turbo"
]
},
{
"site": "phind",
"models": [
"net-gpt3.5-turbo"
]
},
{
"site": "mcbbs",
"models": [
"gpt-3.5-turbo",
"gpt-3.5-turbo-16k"
]
},
{
"site": "chatdemo",
"models": [
"gpt-3.5-turbo"
]
},
{
"site": "vita",
"models": [
"gpt-3.5-turbo"
]
},
{
"site": "fakeopen",
"models": [
"gpt-3.5-turbo-16k"
]
},
{
"site": "better",
"models": [
"gpt-3.5-turbo",
"gpt-3.5-turbo-16k",
"gpt-4"
]
},
{
"site": "xun",
"models": [
"gpt-3.5-turbo",
"gpt-3.5-turbo-16k"
]
}
]
```
### 返回参数 🔙
当对话结束时返回参数(/ask):
```typescript
interface ChatResponse {
content: string;
error?: string;
}
```
stream模式返回参数示例Suggest!!(/ask/stream):
```
event: message
data: {"content":"I"}
event: done
data: {"content":"'m"}
event: error
data: {"error":"some thind wrong"}
```
### 真实请求示例💡
1. 请求you.com, 包含上下文
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:
```json
{
"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":"你是谁"}]]()
2. 以stream模式请求you.com
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"}
```
## 👥 加群细聊
<image src="https://github.com/xiangsx/gpt4free-ts/assets/29322721/311ba62d-e611-4aed-98f6-b34cf115866a" width=240 />
## 🌟 Star History
[](https://star-history.com/#xiangsx/gpt4free-ts&&type=Date)
<p>You may join our discord: <a href="https://discord.com/invite/gpt4free">discord.gg/gpt4free<a> for further updates. <a href="https://discord.gg/gpt4free"><img align="center" alt="gpt4free Discord" width="22px" src="https://raw.githubusercontent.com/peterthehan/peterthehan/master/assets/discord.svg" /></a></p>
This is a replication project for the typescript version of [gpt4free](https://github.com/xtekky/gpt4free)
<img alt="gpt4free logo" src="https://user-images.githubusercontent.com/98614666/233799515-1a7cb6a3-b17f-42c4-956d-8d2a0664466f.png">
## Legal Notice <a name="legal-notice"></a>
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.
================================================
FILE: asyncstore.ts
================================================
import { AsyncLocalStorage } from 'async_hooks';
export type StoreSN = {
sn?: string;
};
export const AsyncStoreSN = new AsyncLocalStorage<StoreSN>();
================================================
FILE: docker-compose.yaml
================================================
version: "3.9"
services:
gpt4free-ts:
build:
context: .
dockerfile: Dockerfile
container_name: gpt4free-ts
image: gpt4free-ts:latest
ports:
- "13000:3000"
restart: always
volumes:
- ./run:/usr/src/app/run
cap_add:
- "SYS_ADMIN"
environment:
# - TZ=Asia/Shanghai
- http_proxy=${http_proxy}
- https_proxy=${http_proxy}
- rapid_api_key=${rapid_api_key}
================================================
FILE: index.ts
================================================
import { initLog } from './utils/log';
require('dotenv').config();
require('elastic-apm-node').start({
serverUrl: process.env['apm.serverUrl'],
serviceName: process.env['apm.serviceName'],
environment: process.env['apm.environment'],
transactionSampleRate: parseInt(
process.env['apm.transactionSampleRate'] || '1',
),
});
import 'heapdump';
import cluster from 'node:cluster';
import { Config } from './utils/config';
import { initCache } from './utils/cache';
process.setMaxListeners(1000); // 将限制提高到20个
initLog();
Config.load();
Config.watchFile();
initCache();
if (cluster.isPrimary) {
console.log(`Master ${process.pid} is running`);
const workers = +(process.env.WORKERS || 1);
// Fork workers.
for (let i = 0; i < workers; i++) {
cluster.fork();
}
cluster.on('exit', (worker, code, signal) => {
console.log(`worker ${worker.process.pid} died,sig: ${signal}`);
console.log('Forking a new process...');
cluster.fork(); // Fork a new process if a worker dies
});
} else {
require('./router').registerApp();
}
process.on('uncaughtException', (err) => {
console.error('Uncaught exception:', err);
setTimeout(() => process.exit(1), 5000); // It's up to you whether to exit here or not
});
process.on('unhandledRejection', (reason, promise) => {
console.error('Unhandled rejection at ', promise, `reason: ${reason}`);
setTimeout(() => process.exit(1), 5000); // It's up to you whether to exit here or not
});
================================================
FILE: koa.d.ts
================================================
import { Context } from 'koa';
import { TraceLogger } from './utils/log';
declare module 'koa' {
interface Context {
logger?: TraceLogger;
}
}
================================================
FILE: model/acytoo/index.ts
================================================
import {
Chat,
ChatOptions,
ChatRequest,
contentToString,
ModelType,
} from '../base';
import { AxiosInstance, AxiosRequestConfig, CreateAxiosDefaults } from 'axios';
import { CreateAxiosProxy } from '../../utils/proxyAgent';
import es from 'event-stream';
import { Event, EventStream } from '../../utils';
import moment from 'moment';
interface Message {
role: string;
content: string;
createdAt: number;
}
interface RealReq {
key: string;
model: string;
messages: Message[];
temperature: number;
password: string;
}
export class AcyToo extends Chat {
private client: AxiosInstance;
constructor(options?: ChatOptions) {
super(options);
this.client = CreateAxiosProxy({
baseURL: 'https://chat.acytoo.com',
headers: {
'Content-Type': 'text/plain;charset=UTF-8',
accept: '*/*',
'Cache-Control': 'no-cache',
'Proxy-Connection': 'keep-alive',
},
} as CreateAxiosDefaults);
}
support(model: ModelType): number {
switch (model) {
case ModelType.GPT3p5Turbo:
return 4000;
default:
return 0;
}
}
async preHandle(
req: ChatRequest,
options?: { token?: boolean; countPrompt?: boolean },
): Promise<ChatRequest> {
return super.preHandle(req, { token: true, countPrompt: false });
}
public async askStream(req: ChatRequest, stream: EventStream) {
let i = 10;
const data: RealReq = {
temperature: 1.0,
model: req.model,
key: '',
messages: req.messages.map((v) => ({
role: v.role,
content: contentToString(v.content),
createdAt: moment().valueOf() + i++ * 100,
})),
password: '',
};
try {
const res = await this.client.post('/api/completions', data, {
responseType: 'stream',
} as AxiosRequestConfig);
res.data.pipe(
es.map(async (chunk: any, cb: any) => {
const content: string = chunk.toString();
const idx = content.indexOf('\n\nY');
if (idx > -1) {
stream.write(Event.message, { content: content.slice(0, idx) });
res.data.destroy();
return;
}
stream.write(Event.message, { content: chunk.toString() });
}),
);
res.data.on('close', () => {
stream.write(Event.done, { content: '' });
stream.end();
});
} catch (e: any) {
console.error(e.message);
stream.write(Event.error, { error: e.message });
stream.end();
}
}
}
================================================
FILE: model/ails/index.ts
================================================
import {
Chat,
ChatOptions,
ChatRequest,
ChatResponse,
contentToString,
Message,
ModelType,
} from '../base';
import { AxiosInstance, AxiosRequestConfig, CreateAxiosDefaults } from 'axios';
import { CreateAxiosProxy } from '../../utils/proxyAgent';
import es from 'event-stream';
import {
ErrorData,
Event,
EventStream,
MessageData,
parseJSON,
} from '../../utils';
import { createHash } from 'crypto';
import moment from 'moment';
import { v4 } from 'uuid';
interface RealReq {
messages: Message[];
model: string;
temperature: number;
presence_penalty: number;
top_p: number;
frequency_penalty: number;
stream: boolean;
}
class Utils {
static hash(json_data: { t: number; m: string }): string {
const secretKey: number[] = [
79, 86, 98, 105, 91, 84, 80, 78, 123, 83, 35, 41, 99, 123, 51, 54, 37, 57,
63, 103, 59, 117, 115, 108, 41, 67, 76,
];
const base_string: string = `${json_data['t']}:${json_data['m']}:'WI,2rU#_r:r~aF4aJ36[.Z(/8Rv93Rf':${json_data['m'].length}`;
return createHash('sha256').update(base_string).digest('hex');
}
static format_timestamp(timestamp: number): string {
const e = timestamp;
const n = e % 10;
const r = n % 2 === 0 ? n + 1 : n;
return String(e - n + r);
}
}
export class AILS extends Chat {
private client: AxiosInstance;
constructor(options?: ChatOptions) {
super(options);
this.client = CreateAxiosProxy(
{
baseURL: 'https://api.caipacity.com',
headers: {
authority: 'api.caipacity.com',
accept: '*/*',
'accept-language':
'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
authorization: 'Bearer free',
'client-id': v4(),
'client-v': '0.1.249',
'content-type': 'application/json',
origin: 'https://ai.ls',
referer: 'https://ai.ls/',
'sec-ch-ua':
'"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'cross-site',
'user-agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
},
} as CreateAxiosDefaults,
false,
);
}
support(model: ModelType): number {
switch (model) {
case ModelType.GPT3p5Turbo:
return 2500;
default:
return 0;
}
}
public async askStream(req: ChatRequest, stream: EventStream) {
const now = moment().valueOf();
const data = {
model: 'gpt-3.5-turbo',
temperature: 1,
stream: true,
messages: req.messages,
d: moment().format('YYYY-MM-DD'),
t: `${now}`,
s: Utils.hash({
t: now,
m: contentToString(req.messages[req.messages.length - 1].content),
}),
};
try {
const res = await this.client.post('/v1/chat/completions', data, {
responseType: 'stream',
} as AxiosRequestConfig);
res.data.pipe(es.split(/\r?\n\r?\n/)).pipe(
es.map(async (chunk: any, cb: any) => {
const dataStr = chunk.replace('data: ', '');
if (!dataStr) {
return;
}
if (dataStr === '[DONE]') {
stream.write(Event.done, { content: '' });
stream.end();
return;
}
const data = parseJSON(dataStr, {} as any);
if (!data?.choices) {
stream.write(Event.error, { error: 'not found data.choices' });
stream.end();
return;
}
const [
{
delta: { content = '' },
finish_reason,
},
] = data.choices;
if (finish_reason === 'stop') {
return;
}
stream.write(Event.message, { content });
}),
);
} catch (e: any) {
console.error(e.message);
stream.write(Event.error, { error: e.message });
stream.end();
}
}
}
================================================
FILE: model/airoom/index.ts
================================================
import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';
import { ComError, Event, EventStream, randomStr } from '../../utils';
import {
ChildOptions,
ComChild,
ComInfo,
DestroyOptions,
Pool,
} from '../../utils/pool';
import { Config } from '../../utils/config';
import { CreateAxiosProxy, CreateNewAxios } from '../../utils/proxyAgent';
import moment from 'moment/moment';
import { Page } from 'puppeteer';
import { AxiosInstance } from 'axios';
type Room = {
rid: string;
sid: string;
};
interface Account extends ComInfo {
email: string;
password: string;
token: string;
roomMap: Partial<Record<ModelType, Room[]>>;
}
const ModelMap: Partial<Record<ModelType, string>> = {
[ModelType.GPT3p5_16k]: '87Xacu8D07CL',
[ModelType.GPT41106Preview]: '87Xacu8D07C2',
};
class Child extends ComChild<Account> {
public client: AxiosInstance;
public page?: Page;
constructor(label: string, info: any, options?: ChildOptions) {
super(label, info, options);
this.client = CreateAxiosProxy(
{
baseURL: 'https://packdir.com',
headers: {
Referer: 'https://airoom.chat/',
},
},
true,
);
}
async init(): Promise<void> {
if (this.info.token) {
return;
}
try {
const email = `${randomStr(
10 + Math.floor(Math.random() * 10),
)}@gmail.com`;
const password = randomStr(10 + Math.floor(Math.random() * 10));
this.update({ email, password });
await this.signup();
await this.login();
if (!this.info.roomMap) {
this.update({
roomMap: {
[ModelType.GPT3p5_16k]: [],
[ModelType.GPT41106Preview]: [],
},
});
}
await this.newRoom(ModelType.GPT41106Preview, true);
await this.newRoom(ModelType.GPT3p5_16k, true);
} catch (e: any) {
if (e?.response?.status === 403 || e?.response?.status === 401) {
this.destroy({ delFile: true, delMem: true });
}
throw e;
}
}
async signup() {
const res = await this.client.post('/api/airoom/signup', {
email: this.info.email,
password: this.info.password,
});
if (res.data.message !== 'success') {
throw new Error('sign up error');
}
}
async login() {
const res: { data: { token: string; message: string } } =
await this.client.post(
'/api/airoom/login',
{
email: this.info.email,
password: this.info.password,
},
{ timeout: 10 * 1000 },
);
if (res.data.message !== 'ok') {
throw new Error('login failed');
}
if (!res.data.token) {
throw new Error('no token');
}
this.update({
token: res.data.token,
});
}
async popRoom(model: ModelType) {
const rooms = this.info.roomMap[model]!;
const room = rooms.shift();
this.update({ roomMap: this.info.roomMap });
if (room) {
this.newRoom(model, true).catch((e) => this.logger.error(e.message));
return room;
} else {
this.newRoom(model, true).catch((e) => this.logger.error(e.message));
return await this.newRoom(model, false);
}
}
async newRoom(model: ModelType, save: boolean) {
if (!ModelMap[model]) {
throw new Error(`not support model:${model}`);
}
const res: {
data: { message: string; room_uuid: string; session_uuid: string };
} = await this.client.post(
'/api/airoom/room',
{
botUuid: ModelMap[model],
botType: 0,
roomName: 'Untitled',
},
{
headers: { Authorization: `Bearer ${this.info.token}` },
},
);
if (!res.data.room_uuid || !res.data.session_uuid) {
throw new ComError('can not get room info', ComError.Status.Forbidden);
}
const room = {
sid: res.data.session_uuid,
rid: res.data.room_uuid,
};
if (save) {
this.info.roomMap[model]!.push(room);
this.update({ roomMap: this.info.roomMap });
}
return room;
}
initFailed() {
this.page?.browser().close();
this.destroy({ delFile: true, delMem: true });
}
destroy(options?: DestroyOptions) {
super.destroy(options);
}
use(): void {
this.update({
lastUseTime: moment().unix(),
useCount: (this.info.useCount || 0) + 1,
});
}
}
export class AIRoom extends Chat {
private pool: Pool<Account, Child> = new Pool(
this.options?.name || '',
() => Config.config.airoom.size,
(info, options) => {
return new Child(this.options?.name || '', info, options);
},
(v) => {
if (!v.email || !v.password) {
return false;
}
return true;
},
{ delay: 1000, serial: () => Config.config.airoom.serial || 1 },
);
constructor(options?: ChatOptions) {
super(options);
}
support(model: ModelType): number {
switch (model) {
case ModelType.GPT3p5_16k:
return 12000;
case ModelType.GPT41106Preview:
return 28000;
default:
return 0;
}
}
async preHandle(req: ChatRequest): Promise<ChatRequest> {
return super.preHandle(req, {
token: false,
countPrompt: true,
forceRemove: true,
});
}
async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
const child = await this.pool.pop();
try {
const { sid, rid } = await child.popRoom(req.model);
const res = await child.client.post(
'/api/airoom/message',
{
prompt: req.prompt,
rid,
sid,
},
{
headers: { Authorization: `Bearer ${child.info.token}` },
responseType: 'stream',
},
);
res.data.on('data', (chunk: string) => {
stream.write(Event.message, { content: chunk.toString() });
});
res.data.on('close', () => {
stream.write(Event.done, { content: '' });
stream.end();
this.logger.info('Recv msg ok');
});
} catch (e: any) {
stream.write(Event.error, { error: e.message });
stream.write(Event.done, { content: '' });
stream.end();
child.update({ token: '' });
if (e.response?.status === 403 || e.response?.status === 401) {
child.destroy({ delFile: true, delMem: true });
} else {
child.destroy({ delFile: false, delMem: true });
}
}
}
}
================================================
FILE: model/airops/index.ts
================================================
import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';
import {
Event,
EventStream,
getRandomOne,
parseJSON,
randomStr,
sleep,
} from '../../utils';
import {
ChildOptions,
ComChild,
ComInfo,
DestroyOptions,
Pool,
} from '../../utils/pool';
import { Config } from '../../utils/config';
import { CreateAxiosProxy, CreateNewPage, WSS } from '../../utils/proxyAgent';
import { AxiosInstance } from 'axios';
import moment from 'moment/moment';
import { v4 } from 'uuid';
import { CreateEmail } from '../../utils/emailFactory';
import { Page } from 'puppeteer';
import { loginGoogle } from '../../utils/puppeteer';
const APP_KEY = 'af9e46318302fccfc6db';
const APP_CLUSTER = 'mt1';
interface Account extends ComInfo {
email: string;
password: string;
recovery_mail: string;
company_name: string;
app_name: string;
app_uuid: string;
api_key: string;
left: number;
failed_times: number;
}
class Child extends ComChild<Account> {
public client!: AxiosInstance;
public ws!: WSS;
private channelMap: Record<
string,
((event: string, data: string) => void) | null
> = {};
constructor(label: string, info: any, options?: ChildOptions) {
super(label, info, options);
}
public setMsgListener(cb: (event: string, data: string) => void) {
for (const channel in this.channelMap) {
if (!this.channelMap[channel]) {
this.channelMap[channel] = cb;
return channel;
}
}
const channel = v4();
this.ws.send(
JSON.stringify({
event: 'pusher:subscribe',
data: {
auth: '',
channel: `public-${channel}`,
},
}),
);
this.channelMap[channel] = cb;
return channel;
}
public removeMsgListener(channel: string) {
this.channelMap[channel] = null;
}
async init(): Promise<void> {
try {
if (!this.info.api_key) {
const page = await CreateNewPage(
'https://app.airops.com/users/sign_up',
);
await page.waitForSelector(
'.min-h-screen > .rounded-lg > .mt-8 > form > .inline-flex',
);
await page.click(
'.min-h-screen > .rounded-lg > .mt-8 > form > .inline-flex',
);
const gmail = getRandomOne(Config.config.gmail_list);
await loginGoogle(
page,
gmail.email,
gmail.password,
gmail.recovery_email,
);
this.update({
email: gmail.email,
password: gmail.password,
recovery_mail: gmail.recovery_email,
});
this.logger.info('login google ok');
await sleep(3000);
const company_name = randomStr(10);
await page.waitForSelector('#companyName');
await page.click('#companyName');
await page.keyboard.type(company_name);
this.update({ company_name });
await page.waitForSelector('#role');
await page.click('#role');
await page.waitForSelector(
'.mt-10 > .grid > .flex > .z-50 > .text-body-sm:nth-child(1)',
);
await page.click(
'.mt-10 > .grid > .flex > .z-50 > .text-body-sm:nth-child(1)',
);
await page.waitForSelector(
'.flex > .box-border > .mt-10 > .mt-8 > .relative:nth-child(2)',
);
await page.click(
'.flex > .box-border > .mt-10 > .mt-8 > .relative:nth-child(2)',
);
await sleep(3000);
await this.createNewApp(page);
await sleep(3000);
const app = await this.getApp(page);
if (!app) {
throw new Error('get app failed');
}
this.logger.info(`get app ok, app_uuid: ${app.uuid}`);
this.update({ app_uuid: app.uuid });
const api_key = await this.getApiKey(page);
if (!api_key) {
throw new Error('get api key failed');
}
this.update({ api_key });
this.logger.info('get api key ok, api_key: ' + api_key);
this.update({ left: 5000 });
await page.browser().close();
}
this.client = CreateAxiosProxy(
{
baseURL: `https://app.airops.com/public_api/`,
headers: {
accept: 'application/json',
'content-type': 'application/json',
Authorization: `Bearer ${this.info.api_key}`,
},
},
false,
);
this.ws = new WSS(
`wss://ws-${APP_CLUSTER}.pusher.com/app/${APP_KEY}?protocol=7&client=js&version=8.1.0&flash=false`,
{
onOpen: () => {
this.logger.info('ws on open');
setInterval(() => {
this.ws.send(
JSON.stringify({
event: 'pusher:ping',
data: {},
}),
);
}, 2 * 60 * 1000);
},
onMessage: (data) => {
const msg = parseJSON<{
event: string;
data: string;
channel: string;
}>(data, {} as any);
if (msg.channel) {
msg.channel = msg.channel.replace('public-', '');
}
this.logger.debug(JSON.stringify(data));
const cb = this.channelMap[msg.channel];
if (cb) {
cb(msg.event, msg.data);
}
},
onError: (err: any) => {
this.logger.error('ws on error, ', err);
this.destroy({ delFile: false, delMem: true });
},
onClose: () => {
this.logger.error('ws on close');
this.destroy({ delFile: false, delMem: true });
},
},
);
} catch (e) {
this.options?.onInitFailed({
delFile: true,
delMem: true,
});
throw e;
}
}
async getApiKey(page: Page) {
try {
page.goto(
`https://app.airops.com/${this.info.company_name.toLowerCase()}-0/account/workspace`,
);
const res = await page.waitForResponse(
(res) => res.url().indexOf('/customer_apis/current') > -1,
);
const data: { base: string } = await res.json();
return data.base;
} catch (e) {
this.logger.error('get api key failed, ', e);
}
}
async getApp(page: Page) {
try {
page.goto('https://app.airops.com/');
const res = await page.waitForResponse(
(res) => res.url().indexOf('airops_app_bases') > -1,
);
const data: {
active_version_id: number;
active_version_number: number;
uuid: string;
}[] = await res.json();
return data[0];
} catch (e) {
this.logger.error(e);
}
}
async createNewApp(page: Page) {
try {
await page.goto(
`https://app.airops.com/${this.info.company_name.toLowerCase()}-0/apps/new-chat?template=blank_chat`,
);
await sleep(10 * 1000);
await page.waitForSelector(
'.relative > .grid > .grid > .flex > .relative:nth-child(2)',
);
await page.click(
'.relative > .grid > .grid > .flex > .relative:nth-child(2)',
);
await sleep(3000);
await page.click(
'.relative > .grid > .grid > .flex > .relative:nth-child(2)',
);
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
const app_name = randomStr(10);
await page.keyboard.type(app_name, { delay: 20 });
this.update({ app_name });
await page.waitForSelector(
'.ReactModal__Content > .flex > .flex > .mt-3 > .relative:nth-child(2)',
);
await page.click(
'.ReactModal__Content > .flex > .flex > .mt-3 > .relative:nth-child(2)',
);
this.logger.info('save draft ok');
await sleep(3000);
await page.waitForSelector(
'.react-flow__nodes > .react-flow__node > #initial > .flex:nth-child(2) > .flex',
);
await page.click(
'.react-flow__nodes > .react-flow__node > #initial > .flex:nth-child(2) > .flex',
);
await page.waitForSelector('#model');
await page.click('#model');
await page.waitForSelector(
'.flex > .flex > .z-50 > .text-body-sm:nth-child(3) > .flex',
);
await page.click(
'.flex > .flex > .z-50 > .text-body-sm:nth-child(3) > .flex',
);
await page.waitForSelector('#initial-show-tool-usage');
await page.click('#initial-show-tool-usage');
await page.waitForSelector(
'.flex > .h-fit > #initial-system > .ace_scroller > .ace_content',
);
await page.click(
'.flex > .h-fit > #initial-system > .ace_scroller > .ace_content',
);
await page.waitForSelector(
'.flex > .h-fit > #initial-system > .ace_scroller > .ace_content',
);
await page.click(
'.flex > .h-fit > #initial-system > .ace_scroller > .ace_content',
);
await page.waitForSelector(
'.flex > .h-fit > #initial-system > .ace_scroller > .ace_content',
);
await page.click(
'.flex > .h-fit > #initial-system > .ace_scroller > .ace_content',
);
await page.keyboard.type('You are AI model made by openai');
await page.waitForSelector(
'.absolute > .flex > .flex:nth-child(1) > .flex > .relative',
);
await page.click(
'.absolute > .flex > .flex:nth-child(1) > .flex > .relative',
);
await page.waitForSelector(
'.grid > .grid > .flex > .flex > .relative:nth-child(1)',
);
await page.click(
'.grid > .grid > .flex > .flex > .relative:nth-child(1)',
);
await page.waitForSelector(
'.absolute > .relative > .inline-flex > .relative > .peer:nth-child(2)',
);
await page.click(
'.absolute > .relative > .inline-flex > .relative > .peer:nth-child(2)',
);
this.logger.info('publish app ok');
} catch (e) {
this.logger.error('create new app failed, ', e);
}
}
use(): void {
this.update({
lastUseTime: moment().unix(),
useCount: (this.info.useCount || 0) + 1,
});
}
destroy(options?: DestroyOptions) {
super.destroy(options);
this.ws?.close();
}
}
export class Airops extends Chat {
private pool: Pool<Account, Child> = new Pool(
this.options?.name || '',
() => Config.config.airops.size,
(info, options) => {
return new Child(this.options?.name || '', info, options);
},
(v) => {
return !!v.api_key && !!v.app_uuid && v.left >= 5;
},
{
delay: 1000,
serial: 1,
},
);
constructor(options?: ChatOptions) {
super(options);
}
support(model: ModelType): number {
switch (model) {
case ModelType.GPT4:
return 4000;
default:
return 0;
}
}
async preHandle(req: ChatRequest): Promise<ChatRequest> {
req.messages = req.messages.filter((v) => v.role !== 'system');
return super.preHandle(req, {
token: true,
countPrompt: true,
forceRemove: true,
});
}
async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
const child = await this.pool.pop();
if (!child) {
stream.write(Event.error, { error: 'No valid connections', status: 429 });
stream.write(Event.done, { content: '' });
stream.end();
return;
}
try {
let output = '';
const channel = child.setMsgListener((event, data) => {
if (event !== 'agent-response') {
return;
}
const { token, stream_finished } = parseJSON<{
token: string;
stream_finished: boolean;
}>(data, {
token: '',
stream_finished: false,
});
if (stream_finished) {
stream.write(Event.done, { content: '' });
stream.end();
this.logger.info('recv msg ok');
return;
}
stream.write(Event.message, { content: token });
output += token;
});
const res: { data: { credits_used: number } } = await child.client.post(
`agent_apps/${child.info.app_uuid}/chat`,
{
message: req.prompt,
session_id: v4(),
user_current_time: moment().format(),
inputs: {},
stream_channel_id: channel,
},
);
if (output.indexOf('We have noticed you') > -1) {
this.logger.error(`We have noticed you, ${req.messages}`);
// child.destroy({ delFile: true, delMem: true });
return;
}
child.update({
left: child.info.left - (res.data.credits_used || 1),
failed_times: 0,
});
child.removeMsgListener(channel);
if (child.info.left < 5) {
child.destroy({ delFile: false, delMem: true });
}
this.logger.info(JSON.stringify(res.data));
} catch (e: any) {
child.update({ failed_times: (child.info.failed_times || 0) + 1 });
this.logger.error(
`ask failed mail:${child.info.email},failed_times:${child.info.failed_times}`,
e,
);
stream.write(Event.error, { error: e.message, status: 500 });
stream.write(Event.done, { content: '' });
stream.end();
if (child.info.failed_times >= 10) {
child.destroy({ delFile: false, delMem: true });
}
}
}
}
================================================
FILE: model/askx/index.ts
================================================
import {
Chat,
ChatOptions,
ChatRequest,
messagesToPrompt,
ModelType,
} from '../base';
import {
Event,
EventStream,
getTokenCount,
parseJSON,
randomStr,
sleep,
} from '../../utils';
import {
ChildOptions,
ComChild,
ComInfo,
DestroyOptions,
Pool,
} from '../../utils/pool';
import { Config } from '../../utils/config';
import { CreateAxiosProxy, CreateNewPage } from '../../utils/proxyAgent';
import moment from 'moment/moment';
import { Page } from 'puppeteer';
import { AxiosInstance } from 'axios';
import es from 'event-stream';
interface Account extends ComInfo {
email: string;
password: string;
xsrf_token: string;
askx_session: string;
}
class Child extends ComChild<Account> {
public client: AxiosInstance;
public page?: Page;
constructor(label: string, info: any, options?: ChildOptions) {
super(label, info, options);
this.client = CreateAxiosProxy(
{
baseURL: 'https://askx.ai',
},
false,
);
}
async init(): Promise<void> {
try {
let page;
if (this.info.xsrf_token && this.info.askx_session) {
this.logger.info('login...');
page = await CreateNewPage('https://askx.ai/login');
this.page = page;
await page.waitForSelector(`input[name="email"]`);
await page.click(`input[name="email"]`);
await page.keyboard.type(this.info.email);
await page.waitForSelector(`input[name="password"]`);
await page.click(`input[name="password"]`);
await page.keyboard.type(this.info.password);
await page.waitForSelector(`button[type="submit"]`);
await page.click(`button[type="submit"]`);
} else {
this.logger.info('register new account ...');
page = await CreateNewPage('https://askx.ai/register');
this.page = page;
await page.waitForSelector(`input[name="name"]`);
await page.click(`input[name="name"]`);
await page.keyboard.type(
randomStr(10 + Math.floor(Math.random() * 10)),
);
await page.waitForSelector(`input[name="email"]`);
await page.click(`input[name="email"]`);
const email = `${randomStr(20)}@gmail.com`;
await page.keyboard.type(email);
this.update({ email });
await page.waitForSelector(`input[type="password"]`);
await page.click(`input[type="password"]`);
const password = randomStr(20);
await page.keyboard.type(password);
this.update({ password });
await page.waitForSelector(`button[type="submit"]`);
await page.click(`button[type="submit"]`);
}
await page.waitForSelector(`a[href="https://askx.ai/dashboard/chat"]`);
await sleep(3000);
await this.updateToken(page);
page.browser().close();
} catch (e) {
throw e;
}
}
async updateToken(page: Page) {
const cookies = await page.cookies();
const xsrf = cookies.find((v) => v.name === 'XSRF-TOKEN');
if (!xsrf) {
throw new Error('get xsrf failed');
}
this.update({ xsrf_token: xsrf.value });
const askx = cookies.find((v) => v.name === 'askx_session');
if (!askx) {
throw new Error('get askx failed');
}
this.update({ askx_session: askx.value });
this.logger.info('update token ok');
}
initFailed() {
this.page
?.browser()
.close()
.catch((e) => this.logger.error(e.message));
this.destroy({ delFile: true, delMem: true });
}
destroy(options?: DestroyOptions) {
super.destroy(options);
}
use(): void {
this.update({
lastUseTime: moment().unix(),
useCount: (this.info.useCount || 0) + 1,
});
}
}
export class Askx extends Chat {
private pool: Pool<Account, Child> = new Pool(
this.options?.name || '',
() => Config.config.askx.size,
(info, options) => {
return new Child(this.options?.name || '', info, options);
},
(v) => {
if (!v.askx_session || !v.xsrf_token) {
return false;
}
return true;
},
{ delay: 1000, serial: () => Config.config.askx.serial || 1 },
);
constructor(options?: ChatOptions) {
super(options);
}
support(model: ModelType): number {
switch (model) {
case ModelType.GPT3p5Turbo:
return 850;
default:
return 0;
}
}
async preHandle(req: ChatRequest): Promise<ChatRequest> {
return super.preHandle(req, {
token: false,
countPrompt: true,
forceRemove: true,
});
}
async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
const child = await this.pool.pop();
if (!child) {
stream.write(Event.error, { error: 'No valid connections', status: 429 });
stream.write(Event.done, { content: '' });
stream.end();
return;
}
let tokenSize =
1 +
getTokenCount(req.messages.reduce((prev, cur) => prev + cur.content, ''));
try {
const res = await child.client.get('/dashboard/chat/stream', {
params: {
role: 'user',
content: req.prompt,
},
headers: {
Cookie: `XSRF-TOKEN=${child.info.xsrf_token}; askx_session=${child.info.askx_session}`,
},
responseType: 'stream',
});
res.data
.pipe(
es.map((chunk: any, cb: any) => {
const content = chunk
.toString()
.replace('data: ', '')
.replace('finishReasonstop', '');
cb(null, parseJSON(content, ''));
}),
)
.on('data', (chunk: string | { message: string }) => {
res.data.pause();
if (typeof chunk !== 'string') {
stream.write(Event.error, { error: chunk?.message });
child.destroy({ delFile: true, delMem: true });
} else {
stream.write(Event.message, { content: chunk });
}
res.data.resume();
});
res.data.on('close', () => {
this.logger.info('Msg recv ok');
stream.write(Event.done, { content: '' });
stream.end();
});
} catch (e: any) {
this.logger.error('ask failed, ', e.message);
e.response.data.on('data', (chunk: any) =>
this.logger.info(chunk.toString()),
);
stream.write(Event.error, {
error: 'Something error, please retry later',
status: 500,
});
stream.write(Event.done, { content: '' });
stream.end();
child.destroy({ delFile: true, delMem: true });
}
}
}
================================================
FILE: model/auto.ts
================================================
import {
Chat,
ChatOptions,
ChatRequest,
contentToString,
ImageGenerationRequest,
messagesToPrompt,
ModelType,
Site,
SpeechRequest,
TextEmbeddingRequest,
} from './base';
import {
ComError,
Event,
EventStream,
matchPattern,
parseJSON,
ThroughEventStream,
TimeFormat,
} from '../utils';
import { Config, SiteCfg } from '../utils/config';
import { OpenAI } from './openai';
import { ClaudeAPI } from './claudeapi';
import moment from 'moment';
import Application, { Context } from 'koa';
import { GLM } from './glm';
import {
CreateVideoTaskRequest,
ImageEditRequest,
QueryVideoTaskRequest,
TranscriptionRequest,
} from './define';
import { SongOptions } from './suno/define';
interface AutoOptions extends ChatOptions {
ModelMap: Map<Site, Chat>;
}
export class Auto extends Chat {
private modelMap: Map<Site, Chat>;
private openAIChatMap: Map<string, OpenAI> = new Map();
private claudeAIChatMap: Map<string, ClaudeAPI> = new Map();
private glmAIChatMap: Map<string, GLM> = new Map();
constructor(options: AutoOptions) {
super(options);
this.modelMap = options.ModelMap;
}
getOpenAIChat = (v: SiteCfg) => {
const key = JSON.stringify(v);
if (!this.openAIChatMap.has(key)) {
this.logger.info(`create openai chat: ${key}`);
this.openAIChatMap.set(
key,
new OpenAI({
api_key: v.api_key,
base_url: v.base_url,
name: v.label || v.site,
proxy: v.proxy,
model_map: v.model_map,
}),
);
}
return this.openAIChatMap.get(key) as OpenAI;
};
getGLMChat = (v: SiteCfg) => {
const key = JSON.stringify(v);
if (!this.glmAIChatMap.has(key)) {
this.logger.info(`create openai chat: ${key}`);
this.glmAIChatMap.set(
key,
new GLM({
api_key: v.api_key,
base_url: v.base_url,
name: v.label || v.site,
proxy: v.proxy,
model_map: v.model_map,
}),
);
}
return this.glmAIChatMap.get(key) as GLM;
};
getClaudeAIChat = (v: SiteCfg) => {
const key = JSON.stringify(v);
if (!this.claudeAIChatMap.has(key)) {
this.logger.info(`create claudeai chat: ${key}`);
this.claudeAIChatMap.set(
key,
new ClaudeAPI({
api_key: v.api_key,
base_url: v.base_url,
name: v.label || v.site,
proxy: v.proxy,
model_map: v.model_map,
}),
);
}
return this.claudeAIChatMap.get(key) as ClaudeAPI;
};
getRandomModel(req: {
model: ModelType;
prompt_tokens?: number;
prompt_length?: number;
}): Chat {
const { model, prompt_tokens, prompt_length } = req;
const list: SiteCfg[] = [];
for (const m in Config.config.site_map) {
const v = Config.config.site_map[m as ModelType] || [];
// 通配符
if (!matchPattern(m, model)) {
continue;
}
for (const cfg of v) {
if (!cfg.priority) {
continue;
}
if (cfg.condition && eval(cfg.condition) !== true) {
continue;
}
this.logger.debug(`auto site match ${m} ${model}`);
list.push(cfg);
}
}
if (!list) {
throw new ComError(
`not cfg ${model} in site_map}`,
ComError.Status.NotFound,
);
}
let sum = 0;
for (const item of list) {
sum += item.priority;
}
let rand = Math.random() * sum;
let v: SiteCfg | undefined;
for (let i = 0; i < list.length; i++) {
rand -= list[i].priority;
if (rand < 0) {
v = list[i];
break;
}
}
if (!v) {
throw new ComError(
`not cfg ${model} in site_map}`,
ComError.Status.NotFound,
);
}
const label = v.label || v.site;
this.logger.info(`${model} auto site choose site [${label}]`, {
label,
model,
});
if (v.site === Site.OpenAI) {
return this.getOpenAIChat(v);
}
if (v.site === Site.Claude) {
return this.getClaudeAIChat(v);
}
if (v.site === Site.GLM) {
return this.getGLMChat(v);
}
return this.modelMap.get(v.site) as Chat;
}
async tryAskStream(
req: ChatRequest,
stream: EventStream,
tried: number = 0,
): Promise<void> {
const es = new ThroughEventStream(
(event, data) => {
switch (event) {
case Event.error:
this.logger.error(
`auto ask failed(${tried}), got error event: ${JSON.stringify(
data,
)}`,
);
if (tried >= (Config.config.global.retry_max_times || 0)) {
stream.write(event, data);
stream.write(Event.done, { content: '' });
stream.end();
return;
}
es.destroy();
this.tryAskStream(req, stream, tried + 1).catch((e) => {
this.logger.error(`event error & retry failed ${e.message}`);
});
break;
default:
stream.write(event, data);
break;
}
},
() => {
stream.end();
},
);
const chat = this.getRandomModel(req);
if (!chat) {
es.destroy();
throw new ComError(
`not support model: ${req.model}`,
ComError.Status.NotFound,
);
}
try {
if (tried === 0) {
await chat.preHandle(req, { stream });
}
await chat.askStream(req, es);
} catch (e: any) {
this.logger.error(`auto ask failed(${tried}) ${e.message}`);
if (tried >= (Config.config.global.retry_max_times || 0)) {
stream.write(Event.error, { error: e.message });
stream.write(Event.done, { content: '' });
stream.end();
return;
}
this.tryAskStream(req, stream, tried + 1).catch((e) =>
this.logger.error(`retry failed ${e.message}`),
);
}
}
async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
return this.tryAskStream(req, stream);
}
support(model: ModelType): number {
// auto站点不处理
return Number.MAX_SAFE_INTEGER;
}
async preHandle(req: ChatRequest, options: any): Promise<ChatRequest> {
if (req.search) {
const searchStr = contentToString(
req.messages[req.messages.length - 1].content,
);
const searchRes = await this.ask({
model: ModelType.Search,
messages: [{ role: 'user', content: searchStr }],
prompt: searchStr,
});
if (!searchRes.content) {
return req;
}
let searchParsed = parseJSON<
{ title: string; link: string; description: string }[]
>(searchRes.content || '', []);
if (searchParsed.length === 0) {
return req;
}
searchParsed = searchParsed.slice(0, 5);
if (options?.stream) {
options.stream.write(Event.message, {
content: `${searchParsed
.map((v) => `- [${v.title}](${v.link})`)
.join('\n')}\n\n`,
});
}
const searchResStr = searchParsed
.map(
(item) =>
`<link title='${item.title}' href='${item.link}'>${item.description}</link>`,
)
.join('\n');
const urlParse = await this.ask({
model: ModelType.URL,
messages: [{ role: 'user', content: searchParsed[0].link }],
prompt: searchParsed[0].link,
max_tokens: 1000,
});
const urlContent = urlParse.content;
req.messages = [
...req.messages.slice(0, -1),
{
role: 'user',
content: `I need you to act as an intelligent assistant, refer to the search results I provided, and ignore some search content that does not relate to my question, then summarize, and answer my question in detail. \n\nCurrent Date:${moment().format(
TimeFormat,
)}\n\nMy question is:<question>${searchStr}</question>\n\n The search results are:\n<search>${searchResStr}</search>\n<firstsearchlink>${
urlContent || ''
}</firstsearchlink> \n\n The answer is as follows(The most important, the language of the answer must be the same of my question's language.):`,
},
];
}
// auto站点不处理
// req.prompt_tokens = countMessagesToken(req.messages);
req.prompt_length = messagesToPrompt(req.messages).length;
return req;
}
async speech(ctx: Application.Context, req: SpeechRequest): Promise<void> {
const chat = this.getRandomModel(req);
await chat.speech(ctx, req);
}
async generations(
ctx: Application.Context,
req: ImageGenerationRequest,
): Promise<void> {
const chat = this.getRandomModel(req);
await chat.generations(ctx, req);
}
async embeddings(
ctx: Application.Context,
req: TextEmbeddingRequest,
): Promise<void> {
const chat = this.getRandomModel(req);
await chat.embeddings(ctx, req);
}
public async transcriptions(ctx: Context, req: TranscriptionRequest) {
const chat = this.getRandomModel(req);
await chat.transcriptions(ctx, req);
}
public async createVideoTask(ctx: Context, req: CreateVideoTaskRequest) {
const chat = this.getRandomModel(req);
await chat.createVideoTask(ctx, req);
}
public async queryVideoTask(
ctx: Application.Context,
req: QueryVideoTaskRequest,
): Promise<void> {
const chat = this.getRandomModel(req);
await chat.queryVideoTask(ctx, req);
}
async createSong(ctx: Application.Context, req: SongOptions) {
const chat = this.getRandomModel({ model: req.mv });
await chat.createSong(ctx, req);
}
async feedSong(
ctx: Application.Context,
req: { ids: string[]; server_id: string },
) {
const chat = this.getRandomModel({ model: ModelType.ChirpV3_0 });
await chat.feedSong(ctx, req);
}
async ImagesEdits(
ctx: Application.Context,
req: ImageEditRequest,
): Promise<void> {
const chat = this.getRandomModel({ model: req.model || ModelType.DallE2 });
await chat.ImagesEdits(ctx, req);
}
}
================================================
FILE: model/bai/index.ts
================================================
import {
Chat,
ChatOptions,
ChatRequest,
ChatResponse,
ModelType,
} from '../base';
import {
DoneData,
ErrorData,
Event,
EventStream,
MessageData,
parseJSON,
} from '../../utils';
import { CreateAxiosProxy } from '../../utils/proxyAgent';
import { AxiosInstance, AxiosRequestConfig, CreateAxiosDefaults } from 'axios';
import es from 'event-stream';
interface RealReq {
prompt: string;
}
export class Bai extends Chat {
private client: AxiosInstance;
constructor(options?: ChatOptions) {
super(options);
this.client = CreateAxiosProxy({
baseURL: 'https://chatbot.theb.ai/api/',
headers: {
Accept: 'application/json, text/plain, */*',
Origin: 'https://chatbot.theb.ai',
},
} as CreateAxiosDefaults);
}
support(model: ModelType): number {
switch (model) {
case ModelType.GPT3p5Turbo:
return 3000;
default:
return 0;
}
}
public async askStream(req: ChatRequest, stream: EventStream) {
const data: RealReq = {
prompt: req.prompt,
};
try {
const res = await this.client.post('/chat-process', data, {
responseType: 'stream',
} as AxiosRequestConfig);
let old = '';
res.data.pipe(es.split(/\r?\n/)).pipe(
es.map(async (chunk: any, cb: any) => {
try {
const dataStr = chunk.toString();
const data = parseJSON(dataStr, {} as any);
const { delta = '' } = data;
if (!delta) {
return;
}
stream.write(Event.message, { content: delta });
} catch (e: any) {
console.error(e.message);
}
}),
);
res.data.on('close', () => {
stream.write(Event.done, { content: '' });
stream.end();
});
} catch (e: any) {
console.error(e.message);
stream.write(Event.error, { error: e.message });
stream.end();
}
}
}
================================================
FILE: model/base.ts
================================================
import {
ComError,
ErrorData,
Event,
EventStream,
extractHttpFileURLs,
extractHttpImageFileURLs,
getTokenCount,
MessageData,
removeRandomChars,
} from '../utils';
import winston from 'winston';
import { newLogger } from '../utils/log';
import { Context } from 'koa';
import {
TranscriptionRequest,
CreateVideoTaskRequest,
QueryVideoTaskRequest,
ImageEditRequest,
} from './define';
import { SongOptions } from './suno/define';
import { Chatgateai } from './chatgateai';
import { MJPlus } from './mjplus';
import Router from 'koa-router';
import { Vidu } from './vidu';
export interface ChatOptions {
name: string;
}
export interface ChatResponse {
content?: string;
role?: string;
function_call?: { name: string; arguments: string };
error?: string;
}
export type MessageContent =
| string
| (
| {
type: 'image_url' | 'text';
text?: string;
image_url?:
| string
| {
url: string;
detail?: 'auto' | 'high' | 'low';
};
}
| string
)[];
export type Message = {
role: string;
content: MessageContent;
};
export function getImagesFromContent(content: MessageContent): string[] {
if (typeof content === 'string') {
return [...extractHttpImageFileURLs(content)];
}
return content.reduce((prev: string[], cur) => {
if (typeof cur === 'string') {
return [...prev, ...extractHttpImageFileURLs(cur)];
}
if (cur.type === 'image_url') {
if (typeof cur.image_url === 'string') {
return [...prev, cur.image_url];
}
return [...prev, cur.image_url!.url];
}
return [...prev, ...extractHttpImageFileURLs(cur.text || '')];
}, []);
}
export function getFilesFromContent(content: MessageContent): string[] {
if (typeof content === 'string') {
return [...extractHttpFileURLs(content)];
}
return content.reduce((prev: string[], cur) => {
if (typeof cur === 'string') {
return [...prev, ...extractHttpFileURLs(cur)];
}
if (cur.type === 'image_url') {
if (typeof cur.image_url === 'string') {
return [...prev, cur.image_url];
}
return [...prev, cur.image_url!.url];
}
return [...prev, ...extractHttpFileURLs(cur.text || '')];
}, []);
}
export enum ModelType {
GPT3p5Turbo = 'gpt-3.5-turbo',
GPT3p5Turbo0125 = 'gpt-3.5-turbo-0125',
Assistant = 'assistant',
GPT3p5TurboInstruct = 'gpt-3.5-turbo-instruct',
GPT3p5_16k = 'gpt-3.5-turbo-16k',
GPT4 = 'gpt-4',
GPT4V = 'gpt-4-v',
GPT4o = 'gpt-4o',
GPT4oAll = 'gpt-4o-all',
GPT4All = 'gpt-4-all',
GPT4Dalle = 'gpt-4-dalle',
GPT4DalleEdit = 'gpt-4-dalle-edit',
GPT4Gizmo = 'gpt-4-gizmo',
GPT4AllSource = 'gpt-4-all-source',
GPT4oAllSource = 'gpt-4o-all-source',
GPT4VisionPreview = 'gpt-4-vision-preview',
GPT41106Preview = 'gpt-4-1106-preview',
GPT40125Preview = 'gpt-4-0125-preview',
GPT4TurboPreview = 'gpt-4-turbo-preview',
GPT4_32k = 'gpt-4-32k',
GPT4oMini = 'gpt-4o-mini',
NetGPT4 = 'net-gpt-4',
DallE3 = 'dall-e-3',
DallE2 = 'dall-e-2',
Sage = 'sage',
NetGpt3p5 = 'net-gpt-3.5-turbo',
ClaudeInstant = 'claude-instant',
Claude = 'claude',
ClaudeInstant_100k = 'claude-instant-100k',
Claude100k = 'claude-100k',
Claude2 = 'claude-2',
Gpt4free = 'gpt-4-free',
GooglePalm = 'google-palm',
Llama_2_70b = 'llama-2-70b',
Llama_2_13b = 'llama-2-13b',
Llama_2_7b = 'llama-2-7b',
Code_Llama_70b_fw = 'code-llama-34b-fw',
Code_Llama_34b = 'code-llama-34b',
Code_Llama_13b = 'code-llama-13b',
Code_Llama_7b = 'code-llama-7b',
StableDiffusion = 'stable-diffusion',
Search = 'search',
URL = 'url',
ErnieBotTurbo = 'ernie-bot-turbo',
ErnieBot = 'ernie-bot',
Bard = 'bard',
MetaLlama = 'meta-llama',
Solar_0_70b = 'solar-0-70b',
Fw_mistral_7b = 'fw-mistral-7b',
PlaygroundV2 = 'playground-v2',
GeminiPro = 'gemini-pro',
Gemini1p5Pro = 'gemini-1.5-pro',
Gemini1p5Flash = 'gemini-1.5-flash',
GeminiProVision = 'gemini-pro-vision',
Qwen72bChat = 'qwen-72b',
Mixtral8x7BChat = 'mixtral-8x7b',
MistralMedium = 'mistral-medium',
Claude3Opus20240229 = 'claude-3-opus-20240229',
Claude3Sonnet20240229 = 'claude-3-sonnet-20240229',
Claude3Haiku20240307 = 'claude-3-haiku-20240307',
Claude3p5Sonnet20240620 = 'claude-3-5-sonnet-20240620',
Claude3p5Sonnet = 'claude-3-5-sonnet',
Claude3Sonnet = 'claude-3-sonnet',
Claude3Opus = 'claude-3-opus',
Claude3Haiku = 'claude-3-haiku',
Claude3Haiku200k = 'claude-3-haiku-200k',
Claude3Sonnet200k = 'claude-3-sonnet-200k',
Claude3Opus200k = 'claude-3-opus-200k',
GetGizmoInfo = 'get-gizmo-info',
GetGPTs = 'get-gpts',
BatchGetGPTs = 'batch-get-gpts',
SearchGPTS = 'search-gpts',
SearchGPTSChat = 'search-gpts-chat',
MJChat = 'mj-chat',
DomoChatGen = 'domo-chat-gen',
DomoChatAnimate = 'domo-chat-animate',
Gemma7bFW = 'gemma-7b-fw',
TTS1 = 'tts-1',
TTS1HD = 'tts-1-hd',
Bing = 'bing',
Whisper1 = 'whisper-1',
PikaVideo = 'pika-video',
DomoImgToVideo = 'domo-img-to-video',
DomoVideoToVideo = 'domo-video-to-video',
PikaTextToVideo = 'pika-text-to-video',
LumaVideo = 'luma-video',
RunwayVideo = 'runway-video',
ViduVideo = 'vidu-video',
SunoV3p5 = 'suno-v3.5',
SunoV3 = 'suno-v3',
SunoV2 = 'suno-v2',
ChirpV2XXLAlpha = 'chirp-v2-xxl-alpha',
ChirpV3_0 = 'chirp-v3-0',
ChirpV3_5 = 'chirp-v3-5',
Sonar = 'sonar',
MistralLarge = 'mistral-large',
SonalSmallOnline = 'sonar-small-online',
SonalMediumOnline = 'sonar-medium-online',
SonalSmallChat = 'sonar-small-chat',
SonalMediumChat = 'sonar-medium-chat',
DbrxInstruct = 'dbrx-instruct',
Codellama70bInstruct = 'codellama-70b-instruct',
Mistral7bInstruct = 'mistral-7b-instruct',
LlavaV15_7b = 'llava-v1.5-7b-wrapper',
LlavaV16_34b = 'llava-v1.6-34b',
Mixtral8x7bInstruct = 'mixtral-8x7b-instruct',
Mixtral8x22bInstruct = 'mixtral-8x22b-instruct',
Mixtral8x22b = 'mixtral-8x22b',
Gemma2bIt = 'gemma-2b-it',
Gemma7bIt = 'gemma-7b-it',
GPT4Turbo = 'gpt-4-turbo',
GPT4Turbo20240409 = 'gpt-4-turbo-2024-04-09',
Llama3_8bInstruct = 'llama-3-8b-instruct',
Llama3_70bInstruct = 'llama-3-70b-instruct',
Llama3SonarLarge32kOnline = 'llama-3-sonar-large-32k-online',
Llama3SonarSmall32kOnline = 'llama-3-sonar-small-32k-online',
Llama3SonarLarge32kChat = 'llama-3-sonar-large-32k-chat',
Llama3SonarSmall32kChat = 'llama-3-sonar-small-32k-chat',
Pdf2Text = 'pdf-to-text',
Pdf2TextOcr = 'pdf-to-text-ocr',
pdf2textProgress = 'pdf-to-text-progress',
pdf2textProgressOcr = 'pdf-to-text-progress-ocr',
Pdf2Json = 'pdf-to-json',
Pdf2JsonOCR = 'pdf-to-json-ocr',
LLama_3_70b_chat = 'llama-3-70b-chat',
UrlAnalysis = 'url-analysis',
Llama370BT = 'llama-3-70b-t',
DeepSeekLLM67BT = 'deepseek-llm-67b-t',
DeepSeekCoder33BT = 'deepseek-coder-33b-t',
Llama370BGroq = 'llama-3-70b-groq',
PlaygroundV2_5 = 'playground-v2.5',
StableDiffusion3_2B = 'stable-diffusion-3-2b',
CogVideoX = 'cogvideox',
Flux = 'flux',
Ideogram = 'ideogram',
FluxPro = 'flux-pro',
FluxDev = 'flux-dev',
FluxSchnell = 'flux-schnell',
Llama3_1_8b = 'llama-3.1-8b',
Llama3_1_70b = 'llama-3.1-70b',
Llama3_1_405b = 'llama-3.1-405b',
Llama3_8b = 'llama-3-8b',
Llama3_70b = 'llama-3-70b',
}
export enum Site {
// define new model here
You = 'you',
Phind = 'phind',
Forefront = 'forefront',
ForefrontNet = 'forefront_net',
Mcbbs = 'mcbbs',
ChatDemo = 'chatdemo',
Vita = 'vita',
Copilot = 'copilot',
Skailar = 'skailar',
FakeOpen = 'fakeopen',
EasyChat = 'easychat',
Better = 'better',
PWeb = 'pweb',
Bai = 'bai',
Gra = 'gra',
Magic = 'magic',
Chim = 'chim',
Poe = 'poe',
Ram = 'ram',
Chur = 'chur',
Xun = 'xun',
VVM = 'vvm',
Poef = 'poef',
PoeAuto = 'poeauto',
PoeVIP = 'poevip',
Claude = 'claude',
GLM = 'glm',
ClaudeChat = 'claudechat',
Cursor = 'cursor',
Auto = 'auto',
ChatBase = 'chatbase',
OpenPrompt = 'openprompt',
AiLs = 'ails',
Perplexity = 'perplexity',
SinCode = 'sincode',
OpenAI = 'openai',
OneAPI = 'oneapi',
Jasper = 'jasper',
OpenChat = 'openchat',
OpenChat3 = 'openchat3',
Pap = 'pap',
MyShell = 'myshell',
AcyToo = 'acytoo',
Google = 'google',
WWW = 'www',
Bing = 'bing',
DDG = 'ddg',
Vanus = 'vanus',
Mixer = 'mixer',
Merlin = 'merlin',
Airops = 'airops',
Langdock = 'langdock',
Toyy = 'toyy',
TakeOff = 'takeoff',
Navit = 'navit',
Stack = 'stack',
TD = 'td',
OpenChat4 = 'openchat4',
Izea = 'izea',
Askx = 'askx',
OpenSess = 'opensess',
Hypotenuse = 'hypotenuse',
Gemini = 'gemini',
AIRoom = 'airoom',
GPTGOD = 'gptgod',
Arkose = 'arkose',
Midjourney = 'midjourney',
FreeGPT4 = 'freegpt4',
Domo = 'domo',
Pika = 'pika',
Suno = 'suno',
PerAuto = 'perauto',
BingCopilot = 'bingcopilot',
ClaudeAuto = 'claudeauto',
OpenAIAuto = 'openaiauto',
FreeGPT35 = 'freegpt35',
PerLabs = 'perlabs',
MerlinGmail = 'merlingmail',
Chatgateai = 'chatgateai',
MJPlus = 'mjplus',
FindPlus = 'findplus',
Doc2x = 'doc2x',
OpenchatGateway = 'openchatgateway',
Luma = 'luma',
Groq = 'groq',
Bibi = 'bibi',
Vidu = 'vidu',
Flux = 'flux',
MJWeb = 'mjweb',
Fireworks = 'fireworks',
XyChat = 'xychat',
Runway = 'runway',
Ideogram = 'ideogram',
}
export interface ChatRequest {
prompt: string;
model: ModelType;
messages: Message[];
search?: boolean;
temperature?: number;
max_tokens?: number;
secret?: string;
images?: { width: number; height: number; url?: string }[];
prompt_tokens?: number;
prompt_length?: number;
response_format?: {
type: 'json_object' | 'text';
};
}
export interface SpeechRequest {
model: ModelType;
input: string;
voice: string;
secret?: string;
response_format?: 'mp3' | 'opus' | 'aac' | 'flac';
speed?: number;
}
export interface TextEmbeddingRequest {
/**
* The input text to embed, which can be a single string or an array of strings or tokens.
* For multiple inputs in a single request, an array of strings or array of token arrays can be used.
* The input size is limited, and the maximum size for certain models (e.g., text-embedding-ada-002)
* is 8192 tokens. The input cannot be empty, and any array must have 2048 dimensions or less.
*/
input: string | string[] | Array<Array<string | number>>;
/**
* The unique identifier for the model to be used for embedding.
* Use the List models API to fetch all available models or refer to the Model overview for descriptions.
*/
model: ModelType;
/**
* The format for the returned embeddings, which can either be a float or base64 encoded string.
* This parameter is optional and defaults to 'float' if not specified.
*/
encoding_format?: 'float' | 'base64';
/**
* The number of dimensions for the output embeddings.
* This is an optional parameter and is only supported in 'text-embedding-3' and later models.
*/
dimensions?: number;
/**
* A unique string that identifies the end-user.
* This helps OpenAI to monitor and detect potential misuse of the service.
* This parameter is optional.
*/
user?: string;
}
export interface ImageGenerationRequest {
// 'prompt' is a required field and it's a string.
prompt: string;
// 'model' is an optional field that defaults to a specific model version.
model: Partial<ModelType>;
// 'n' is an optional field that determines the number of images to generate.
n?: number;
// 'quality' defines the quality of the image and has specific options.
quality?: 'standard' | 'hd';
// 'response_format' indicates the format in which the images are returned.
response_format?: 'url' | 'b64_json';
// 'size' is an optional field that specifies the size of the generated images.
size?: '256x256' | '512x512' | '1024x1024' | '1792x1024' | '1024x1792';
// 'style' defines the style of the generated images.
style?: 'vivid' | 'natural';
// 'user' is an optional string that represents a unique identifier for the user.
user?: string;
}
export function contentToString(content: MessageContent): string {
if (!content) {
return '';
}
if (typeof content === 'string') {
return content;
}
return content.reduce((prev: string, cur) => {
if (typeof cur === 'string') {
return prev + cur;
}
if (cur.type === 'image_url') {
return prev;
}
return prev + (cur?.text || '');
}, '');
}
// 结构体message转换为prompt
export function messagesToPrompt(messages: Message[]): string {
if (messages.length === 1) {
return contentToString(messages[0].content);
}
return (
messages
.map((item) => `${item.role}: ${contentToString(item.content)}`)
.join('\n') +
'\n' +
'assistant: '
);
}
export function randomRemoveContentChars(
content: MessageContent,
percentage: number,
) {
if (typeof content === 'string') {
return removeRandomChars(content, percentage);
}
return content.map((item) => {
if (typeof item === 'string') {
return removeRandomChars(item, percentage);
}
if (item.type === 'image_url') {
return item;
}
return {
...item,
text: removeRandomChars(item.text || '', percentage),
};
});
}
export function countMessagesToken(messages: Message[]): number {
let token = 0;
for (const v of messages) {
if (typeof v.content === 'string') {
token += getTokenCount(v.content);
continue;
}
for (const item of v.content) {
if (typeof item === 'string') {
token += getTokenCount(item);
continue;
}
if (item.type === 'text') {
token += getTokenCount(item.text || '');
continue;
}
if (item.type === 'image_url') {
token += 85;
continue;
}
}
}
return token;
}
export function sliceMessagesByToken(
messages: Message[],
limitSize: number,
countPrompt: boolean = false,
forceRemove: boolean = false,
): Message[] {
const size = getTokenCount(
countPrompt
? messagesToPrompt(messages)
: messages.reduce((prev, cur) => prev + cur.content, ''),
);
console.debug(
`${
countPrompt ? 'prompt' : 'messages.content'
} token count ${size} / ${limitSize}`,
);
if (size < limitSize) {
return messages;
}
const newMessage =
size / limitSize > 2 && messages.length > 21
? messages.slice(-20)
: messages.slice(1, messages.length);
if (newMessage.length === 0) {
if (!forceRemove) {
throw new ComError('message too long', ComError.Status.RequestTooLarge);
}
messages[0].content = randomRemoveContentChars(
messages[0].content,
(size - limitSize || 1) / size,
);
return sliceMessagesByToken(messages, limitSize, countPrompt, forceRemove);
}
return sliceMessagesByToken(newMessage, limitSize, countPrompt, forceRemove);
}
export function sliceMessagesByLength(
messages: Message[],
limitSize: number,
countPrompt: boolean = false,
forceRemove: boolean = false,
): Message[] {
const size = (
countPrompt
? messagesToPrompt(messages)
: messages.reduce((prev, cur) => prev + cur.content, '')
).length;
console.debug(
`${
countPrompt ? 'prompt' : 'messages.content'
} length ${size} / ${limitSize}`,
);
if (size < limitSize) {
return messages;
}
const newMessage =
size / limitSize > 2 && messages.length > 21
? messages.slice(-20)
: messages.slice(1, messages.length);
if (newMessage.length === 0) {
if (!forceRemove) {
throw new ComError('message too long', ComError.Status.RequestTooLarge);
}
messages[0].content = randomRemoveContentChars(
messages[0].content,
(size - limitSize || 1) / size,
);
return sliceMessagesByLength(messages, limitSize, countPrompt, forceRemove);
}
return sliceMessagesByLength(newMessage, limitSize, countPrompt, forceRemove);
}
export class Chat {
protected options?: ChatOptions;
protected logger: winston.Logger;
constructor(options?: ChatOptions) {
this.options = options;
this.logger = newLogger(options?.name);
}
public support(model: ModelType): number {
throw new ComError('not implement', ComError.Status.InternalServerError);
}
public async preHandle(
req: ChatRequest,
options?: {
token?: boolean;
countPrompt?: boolean;
forceRemove?: boolean;
stream?: EventStream;
},
): Promise<ChatRequest> {
const {
token = false,
countPrompt = true,
forceRemove = false,
} = options || {};
const size = this.support(req.model);
if (!size) {
throw new ComError(
`not support model: ${req.model}`,
ComError.Status.NotFound,
);
}
if (size !== Number.MAX_SAFE_INTEGER) {
req.messages = token
? sliceMessagesByToken(req.messages, size, countPrompt, forceRemove)
: sliceMessagesByLength(req.messages, size, countPrompt, forceRemove);
}
req.prompt = messagesToPrompt(req.messages);
return req;
}
public async ask(req: ChatRequest): Promise<ChatResponse> {
const stream = new EventStream();
await this.askStream(req, stream);
const result: ChatResponse = {
content: '',
};
return new Promise((resolve) => {
stream.read(
(event, data) => {
switch (event) {
case Event.done:
break;
case Event.message:
data = data as MessageData;
result.content += data.content || '';
if (data.role) {
result.role = data.role;
}
if (data.function_call) {
if (!result.function_call) {
result.function_call = data.function_call;
}
if (data.function_call.name) {
result.function_call = data.function_call;
}
if (data.function_call.arguments) {
result.function_call.arguments +=
data.function_call.arguments;
}
}
break;
case Event.error:
result.error = (data as ErrorData).error;
break;
}
},
() => {
resolve(result);
},
);
});
}
public async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
throw new ComError('not implement', ComError.Status.InternalServerError);
}
public async webshow(ctx: Context) {
ctx.body = 'not implement';
}
public async speech(ctx: Context, req: SpeechRequest) {
throw new ComError('not implement', ComError.Status.InternalServerError);
}
public async ImagesEdits(ctx: Context, req: ImageEditRequest) {
throw new ComError('not implement', ComError.Status.InternalServerError);
}
public async generations(ctx: Context, req: ImageGenerationRequest) {
throw new ComError('not implement', ComError.Status.InternalServerError);
}
public async embeddings(ctx: Context, req: TextEmbeddingRequest) {
throw new ComError('not implement', ComError.Status.InternalServerError);
}
public async transcriptions(ctx: Context, req: TranscriptionRequest) {
throw new ComError('not implement', ComError.Status.InternalServerError);
}
public async createVideoTask(ctx: Context, req: CreateVideoTaskRequest) {
throw new ComError('not implement', ComError.Status.InternalServerError);
}
public async queryVideoTask(ctx: Context, req: QueryVideoTaskRequest) {
throw new ComError('not implement', ComError.Status.InternalServerError);
}
public async createSong(ctx: Context, req: SongOptions) {
throw new ComError('not implement', ComError.Status.InternalServerError);
}
public async feedSong(
ctx: Context,
req: { ids: string[]; server_id: string },
) {
throw new ComError('not implement', ComError.Status.InternalServerError);
}
public dynamicRouter(router: Router): boolean {
return false;
}
}
================================================
FILE: model/better/index.ts
================================================
import {
Chat,
ChatOptions,
ChatRequest,
ChatResponse,
ModelType,
} from '../base';
import { AxiosInstance, AxiosRequestConfig, CreateAxiosDefaults } from 'axios';
import { CreateAxiosProxy } from '../../utils/proxyAgent';
import es from 'event-stream';
import {
ErrorData,
Event,
EventStream,
MessageData,
parseJSON,
} from '../../utils';
interface Message {
role: string;
content: string;
}
const modelMap = {
[ModelType.GPT3p5_16k]: 'gpt-3.5-turbo-16k',
[ModelType.GPT4]: 'gpt-4',
[ModelType.GPT3p5Turbo]: 'gpt-3.5-turbo',
} as Record<ModelType, string>;
interface RealReq {
messages: Message[];
temperature: number;
stream: boolean;
model: string;
}
export class Better extends Chat {
private client: AxiosInstance;
constructor(options?: ChatOptions) {
super(options);
this.client = CreateAxiosProxy({
baseURL: 'https://openai-proxy-api.vercel.app/v1/',
headers: {
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.58',
Referer: 'https://chat.ylokh.xyz/',
Origin: 'https://chat.ylokh.xyz',
'Content-Type': 'application/json',
},
} as CreateAxiosDefaults);
}
support(model: ModelType): number {
switch (model) {
case ModelType.GPT3p5_16k:
return 15000;
case ModelType.GPT4:
return 5000;
case ModelType.GPT3p5Turbo:
return 4000;
default:
return 0;
}
}
public async askStream(req: ChatRequest, stream: EventStream) {
const data: RealReq = {
messages: [{ role: 'user', content: req.prompt }],
temperature: 1.0,
model: modelMap[req.model],
stream: true,
};
try {
const res = await this.client.post('/chat/completions', data, {
responseType: 'stream',
} as AxiosRequestConfig);
res.data.pipe(es.split(/\r?\n\r?\n/)).pipe(
es.map(async (chunk: any, cb: any) => {
const dataStr = chunk.replace('data: ', '');
if (!dataStr) {
return;
}
const data = parseJSON(dataStr, {} as any);
if (!data?.choices) {
stream.write(Event.error, { error: 'not found data.choices' });
stream.end();
return;
}
const [
{
delta: { content = '' },
finish_reason,
},
] = data.choices;
if (finish_reason === 'stop') {
stream.write(Event.done, { content: '' });
stream.end();
return;
}
stream.write(Event.message, { content });
}),
);
} catch (e: any) {
console.error(e.message);
stream.write(Event.error, { error: e.message });
stream.end();
}
}
}
================================================
FILE: model/bibi/child.ts
================================================
import { ComChild } from '../../utils/pool';
import {
Account,
ChapterSummaryReq,
ChapterSummaryRes,
ChatReq,
ChatRes,
ExpressReq,
ExpressRes,
PageData,
StatusData,
SubtitleReq,
SubtitleRes,
SummaryReq,
SummaryRes,
VisionReq,
VisionRes,
} from './define';
import { CreateNewAxios } from '../../utils/proxyAgent';
import moment from 'moment/moment';
import { AxiosInstance } from 'axios';
export class Child extends ComChild<Account> {
client!: AxiosInstance;
async init(): Promise<void> {
this.client = CreateNewAxios(
{
baseURL: `https://bibigpt.co/api/open/${this.info.api_key}`,
timeout: 5 * 60 * 1000,
},
{
errorHandler: (e) => {
this.logger.error(`axios failed: ${e.message}`);
},
},
);
}
async summary(req: SummaryReq) {
req.limitation = { maxDuration: 60 * 60 };
const res: { data: SummaryRes } = await this.client.post('/', req);
// 如果最后一行包含有bibigpt链接,则去掉最后一行
const lastLine = res.data.summary.split('\n').pop();
delete res.data.htmlUrl;
if (lastLine && lastLine.includes('bibigpt')) {
res.data.summary = res.data.summary.split('\n').slice(0, -1).join('\n');
}
return res.data as SummaryRes;
}
async chapterSummary(req: ChapterSummaryReq) {
const res = await this.client.get('/chapter-summary', { params: req });
delete res.data.htmlUrl;
return res.data as ChapterSummaryRes;
}
async subtitle(req: SubtitleReq) {
const res = await this.client.get('/subtitle', { params: req });
return res.data as SubtitleRes;
}
async chat(req: ChatReq) {
const res = await this.client.get('/chat', { params: req });
return res.data as ChatRes;
}
async express(req: ExpressReq) {
const res = await this.client.get('/express', { params: req });
return res.data as ExpressRes;
}
async vision(req: VisionReq) {
const res = await this.client.get('/express', { params: req });
return res.data as VisionRes;
}
use() {
this.update({
lastUseTime: moment().unix(),
useCount: (this.info.useCount || 0) + 1,
});
}
}
================================================
FILE: model/bibi/define.ts
================================================
import { ComInfo } from '../../utils/pool';
import exp from 'constants';
import Joi from 'joi';
export interface Account extends ComInfo {
api_key: string;
}
export interface PageData {
url: string;
page_idx: number;
page_width: number;
page_height: number;
md: string;
}
export interface ProcessingData {
pages: number | PageData[];
progress: number;
msg: string;
remain: number;
}
export interface StatusData {
uuid: string;
status: 'processing' | 'success';
data: ProcessingData;
}
export type SummaryReq = {
url: string;
limitation?: {
maxDuration: number;
};
prompt?: string;
promptConfig?: {
showEmoji?: boolean;
showTimestamp?: boolean;
outlineLevel?: number;
sentenceNumber?: number;
detailLevel?: number;
outputLanguage?: string;
customPrompt?: string;
isRefresh?: boolean;
};
includeDetail?: boolean;
};
export const SummaryReqJoi = {
url: Joi.string().required(),
limitation: Joi.object({
maxDuration: Joi.number().required(),
}),
prompt: Joi.string(),
promptConfig: Joi.object({
showEmoji: Joi.boolean(),
showTimestamp: Joi.boolean(),
outlineLevel: Joi.number(),
sentenceNumber: Joi.number(),
detailLevel: Joi.number(),
outputLanguage: Joi.string(),
customPrompt: Joi.string(),
isRefresh: Joi.boolean(),
}),
includeDetail: Joi.boolean(),
};
interface Subtitle {
end: number;
text: string;
index: number;
startTime: number;
}
interface VideoDetail {
dbId: string;
id: string;
author: string;
authorId: string;
embedId: string;
pageId: string;
url: string;
type: string;
title: string;
chapters: any[];
cover: string;
duration: number;
subtitlesArray: Subtitle[];
rawLang: string;
descriptionText: string;
contentText: string;
}
export type SummaryRes = {
success: boolean;
id: string;
service: string;
sourceUrl: string;
htmlUrl?: string;
summary: string;
costDuration: number;
remainingTime: number;
detail: VideoDetail;
};
export type ChapterSummaryReq = {};
export type ChapterSummaryReqJoi = {};
export type ChapterSummaryRes = {};
export type SubtitleReq = {
url: string;
};
export const SubtitleReqJoi = {
url: Joi.string().required(),
};
export type SubtitleRes = {
success: boolean;
id: string;
service: string;
sourceUrl: string;
htmlUrl?: string;
costDuration: number;
remainingTime: number;
summary: string;
detail: {
title: string;
descriptionText: string;
};
};
export type ChatReq = {
url: string;
question: string;
history: string[][];
language: string;
includeDetail: boolean;
};
export const ChatReqJoi = {
url: Joi.string().required(),
question: Joi.string().required(),
history: Joi.array().items(Joi.array().items(Joi.string())).required(),
};
export type ChatRes = {
success: boolean;
id: string;
service: string;
sourceUrl: string;
htmlUrl: string;
costDuration: number;
remainingTime: number;
answer: string;
sourceDocuments: {
pageContent: string;
metadata: Record<string, any>;
}[];
};
export type ExpressReq = {
url: string;
articleConfig: {
outputLanguage: string;
showEmoji: boolean;
isRefresh: boolean;
};
};
export const ExpressReqJoi = {
url: Joi.string().required(),
articleConfig: Joi.object({
outputLanguage: Joi.string().required(),
showEmoji: Joi.boolean().required(),
isRefresh: Joi.boolean().required(),
}).required(),
};
export type ExpressRes = {
success: boolean;
id: string;
service: string;
sourceUrl: string;
htmlUrl: string;
costDuration: number;
remainingTime: number;
article: string;
};
export type VisionReq = {};
export const VisionReqJoi = {};
export type VisionRes = {};
export interface PromptRes {
type: 'subtitle' | 'summary'; // 行为类型
url: string; // 链接地址
customPrompt?: string; // 自定义提示,仅当type="summary"时有效
}
================================================
FILE: model/bibi/index.ts
================================================
import { Chat, ChatRequest, ModelType, Site } from '../base';
import {
Event,
EventStream,
extractJSON,
MessageData,
retryFunc,
ThroughEventStream,
} from '../../utils';
import {
Account,
ChatReq,
ChatReqJoi,
ExpressReq,
ExpressReqJoi,
PromptRes,
SubtitleReq,
SubtitleReqJoi,
SummaryReq,
SummaryReqJoi,
VisionReq,
VisionReqJoi,
} from './define';
import { Pool } from '../../utils/pool';
import { Config } from '../../utils/config';
import { v4 } from 'uuid';
import { Child } from './child';
import Router from 'koa-router';
import { checkBody, checkQuery } from '../../utils/middleware';
import { chatModel } from '../index';
import { BibiPrompt } from './prompt';
export class Bibi extends Chat {
pool = new Pool<Account, Child>(
this.options?.name || 'claude-api',
() => Config.config.bibi?.size || 0,
(info, options) => {
return new Child(this.options?.name || '', info, options);
},
(v) => {
if (!v.api_key) {
return false;
}
return true;
},
{
delay: 1000,
serial: () => Config.config.bibi?.serial || 1,
needDel: (info) => !info.api_key,
preHandleAllInfos: async (allInfos) => {
const oldSet = new Set(allInfos.map((v) => v.api_key));
for (const v of Config.config.bibi?.apikey_list || []) {
if (!oldSet.has(v)) {
allInfos.push({
id: v4(),
api_key: v,
} as Account);
}
}
return allInfos;
},
},
);
support(model: ModelType): number {
switch (model) {
case ModelType.UrlAnalysis:
return 32000;
default:
return 0;
}
}
async summaryStream(req: PromptRes, stream: EventStream) {
const child = await this.pool.pop();
const sReq: SummaryReq = {
url: req.url,
};
if (req.customPrompt) {
sReq.promptConfig = {
customPrompt: req.customPrompt,
isRefresh: true,
};
}
stream.write(Event.message, { content: '\n\n> 正在分析中,请稍候...' });
const res = await child.summary({
url: req.url,
});
stream.write(Event.message, {
content: `\n\n\`\`\`\n${JSON.stringify(res, null, 4)}\n\`\`\``,
});
stream.write(Event.message, {
content: `\n\n ${res.summary}`,
});
}
async subtitleStream(req: SubtitleReq, stream: EventStream) {
const child = await this.pool.pop();
const sReq: SubtitleReq = { url: req.url };
stream.write(Event.message, { content: '\n\n> 正在分析中,请稍候...' });
const res = await child.subtitle(sReq);
stream.write(Event.message, {
content: `\n\n\`\`\`\n${JSON.stringify(res, null, 4)}\n\`\`\``,
});
}
async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
const auto = chatModel.get(Site.Auto);
let old = '';
const pt = new ThroughEventStream(
(event, data) => {
stream.write(event, data);
if ((data as MessageData).content) {
old += (data as MessageData).content;
}
},
async () => {
try {
await retryFunc(
async () => {
stream.write(Event.message, { content: '\n\n' });
const action = extractJSON<PromptRes>(old);
if (!action) {
stream.write(Event.message, {
content: 'Generate action failed',
});
stream.write(Event.done, { content: '' });
stream.end();
return;
}
switch (action.type) {
case 'subtitle':
await this.subtitleStream(action, stream);
break;
case 'summary':
await this.summaryStream(action, stream);
break;
default:
break;
}
},
3,
{ label: 'bibi action', delay: 100 },
);
stream.write(Event.done, { content: '' });
stream.end();
} catch (e: any) {
this.logger.error(e.message);
stream.write(Event.message, { content: `生成失败: ${e.message}` });
stream.write(Event.done, { content: '' });
stream.end();
}
},
);
req.messages = [{ role: 'system', content: BibiPrompt }, ...req.messages];
await auto?.askStream(
{
...req,
model: Config.config.bibi?.model || ModelType.GPT4_32k,
} as ChatRequest,
pt,
);
}
dynamicRouter(router: Router): boolean {
router.post('/summary', checkBody(SummaryReqJoi), async (ctx) => {
const child = await this.pool.pop();
const res = await child.summary(ctx.request.body as SummaryReq);
ctx.body = res;
});
router.get('/subtitle', checkQuery(SubtitleReqJoi), async (ctx) => {
const child = await this.pool.pop();
const res = await child.subtitle(ctx.query as SubtitleReq);
ctx.body = res;
});
router.post('/chat', checkBody(ChatReqJoi), async (ctx) => {
const child = await this.pool.pop();
const res = await child.chat(ctx.request.body as ChatReq);
ctx.body = res;
});
router.post('/express', checkBody(ExpressReqJoi), async (ctx) => {
const child = await this.pool.pop();
const res = await child.express(ctx.request.body as ExpressReq);
ctx.body = res;
});
router.post('/vision', checkBody(VisionReqJoi), async (ctx) => {
const child = await this.pool.pop();
const res = await child.vision(ctx.request.body as VisionReq);
ctx.body = res;
});
return true;
}
}
================================================
FILE: model/bibi/prompt.ts
================================================
export const BibiPrompt = `
你是专业的AI链接总结工具助手
Do not include any explanations, only provide a RFC8259 compliant JSON response following this format without deviation.
Output json should be in code block format.
你需要根据用户的提示词生成如下格式的json
\`\`\`
{
type: "subtitle"|"summary";// 行为类型
url:string; // 链接地址
customPrompt?: string; // 自定义提示,仅当type="summary"时有效
}
\`\`\`
`;
================================================
FILE: model/bing/index.ts
================================================
import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';
import { Event, EventStream, sleep } from '../../utils';
import puppeteer from 'puppeteer-extra';
import StealthPlugin from 'puppeteer-extra-plugin-stealth';
import { CreateNewBrowser } from '../../utils/proxyAgent';
import { Browser } from 'puppeteer';
import { simplifyPageAll } from '../../utils/puppeteer';
puppeteer.use(StealthPlugin());
export class Bing extends Chat {
private browser?: Browser;
constructor(options?: ChatOptions) {
super(options);
}
async init() {
this.browser = await CreateNewBrowser();
this.logger.info('init ok');
}
async newPage() {
if (!this.browser) throw new Error('browser not init');
const page = await this.browser.newPage();
await simplifyPageAll(page);
return page;
}
support(model: ModelType): number {
switch (model) {
case ModelType.Search:
return 2000;
default:
return 0;
}
}
async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
if (!this.browser) {
await this.init();
}
const page = await this.newPage();
try {
await page.goto(
`https://www.bing.com/search?q=${req.prompt}&form=QBLH&sp=-1&lq=0&pq=${req.prompt}&sc=1-9&qs=n&sk=&&ghsh=0&ghacc=0&ghpl=`,
{ waitUntil: 'domcontentloaded' },
);
await page.waitForSelector('.b_algo');
// 提取搜索结果的标题和链接
const results = await page.evaluate(() => {
const nodes = document.querySelectorAll('.b_algo');
// @ts-ignore
const extractedResults = [];
nodes.forEach((node) => {
const titleNode = node.querySelector('h2 a');
const linkNode = node.querySelector('.b_title h2 a');
const descriptionNode = node.querySelector('.b_caption p');
if (!titleNode || !linkNode || !descriptionNode) return;
// @ts-ignore
const title = titleNode ? titleNode.innerText : 'N/A';
const link = linkNode ? linkNode.getAttribute('href') : 'N/A';
const description = descriptionNode
? // @ts-ignore
descriptionNode.innerText
: 'N/A';
extractedResults.push({ title, link, description });
});
// @ts-ignore
return extractedResults;
});
stream.write(Event.message, { content: JSON.stringify(results) });
} catch (e: any) {
this.logger.error('ask stream failed', e);
stream.write(Event.error, { error: e.message });
await this.browser?.close();
await this.init();
} finally {
stream.write(Event.done, { content: '' });
stream.end();
await page.close();
}
}
}
================================================
FILE: model/bingcopilot/child.ts
================================================
import { ComChild } from '../../utils/pool';
import { Account } from './define';
import { Page } from 'puppeteer';
import { CreateNewPage, WSS } from '../../utils/proxyAgent';
import { v4 } from 'uuid';
import { randomStr } from '../../utils';
import moment from 'moment';
export class Child extends ComChild<Account> {
private page!: Page;
private wss!: WSS;
async init(): Promise<void> {
const page = await CreateNewPage('https://www.bing.com/chat');
this.page = page;
await this.createConversation();
}
async getIP(): Promise<string> {
const ipInfo: any = await this.page.evaluate(
() =>
new Promise((resolve, reject) =>
fetch('https://api.ipify.org?format=json')
.then((res) => res.json().then(resolve).catch(reject))
.catch(reject),
),
);
return ipInfo.ip;
}
async createConversation() {
const res = await this.fetch<{
data: {
conversationId: string;
clientId: string;
result: { value: string; message: null | string };
};
sign: string;
}>('/turing/conversation/create?bundleVersion=1.1573.3');
return res;
}
async createMessage(
conversationId: string,
clientId: string,
prompt: string,
) {
const requestId = v4();
return `{"arguments":[{"source":"cib","optionsSets":["nlu_direct_response_filter","deepleo","disable_emoji_spoken_text","responsible_ai_policy_235","enablemm","dv3sugg","iyxapbing","iycapbing","galileo","saharagenconv5","bicfluxv3","langdtwb","papynoapi","gndlogcf","gndbfptlw","eredirecturl"],"allowedMessageTypes":["ActionRequest","Chat","ConfirmationCard","Context","InternalSearchQuery","InternalSearchResult","Disengaged","InternalLoaderMessage","Progress","RenderCardRequest","RenderContentRequest","AdsQuery","SemanticSerp","GenerateContentQuery","SearchQuery","GeneratedCode"],"sliceIds":["sappbcbt","rankcf","291encacheas","designer2cf","defred","cmcpupsalltf","cdxsyddp2","0209bicv3","130memrevs0","116langwb","etlogcf","0131onthda","0208papynoa","sapsgrds0","0131gndbfpr","enter4nlcf","exptone","cacfastapis"],"verbosity":"verbose","scenario":"SERP","plugins":[],"traceId":"${randomStr(
32,
)}","conversationHistoryOptionsSets":["autosave","savemem","uprofupd","uprofgen"],"isStartOfSession":true,"requestId":"${requestId}","message":{"locale":"en-US","market":"en-US","region":"US","location":"lat:47.639557;long:-122.128159;re=1000m;","locationHints":[{"SourceType":1,"RegionType":2,"Center":{"Latitude":40.75849914550781,"Longitude":-111.88809967041016},"Radius":24902,"Name":"Salt Lake City, Utah","Accuracy":24902,"FDConfidence":0.5,"CountryName":"United States","CountryConfidence":8,"Admin1Name":"Utah","PopulatedPlaceName":"Salt Lake City","PopulatedPlaceConfidence":5,"PostCodeName":"84189","UtcOffset":-7,"Dma":770}],"userIpAddress":"23.142.200.157","timestamp":"${new Date().toString()}","author":"user","inputMethod":"Keyboard","text":"${prompt}","messageType":"Chat","requestId":"${requestId}","messageId":"${requestId}"},"tone":"Balanced","spokenTextMode":"None","conversationId":"${conversationId}","participant":{"id":"${clientId}"}}],"invocationId":"5","target":"chat","type":4}`;
}
async fetch<T>(url: string): Promise<T> {
return (await this.page.evaluate(
(url) =>
new Promise((resolve, reject) => {
fetch(`https://www.bing.com${url}`, {
headers: {
accept: 'application/json',
'accept-language': 'en-US,en;q=0.9',
'cache-control': 'no-cache',
pragma: 'no-cache',
preferanonymous: '1',
// 'x-edge-shopping-flag': '0',
// 'x-ms-client-request-id': '3dca6648-4808-4f6e-a624-460bd6f0b87c',
// 'x-ms-useragent':
// 'azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.12.3 OS/macOS',
},
referrer: 'https://www.bing.com/chat?q=Bing+AI&FORM=hpcodx',
referrerPolicy: 'origin-when-cross-origin',
body: null,
method: 'GET',
mode: 'cors',
credentials: 'include',
})
.then((res) =>
res
.json()
.then((v) =>
resolve({
data: v,
sign: res.headers.get(
'X-Sydney-Encryptedconversationsignature',
),
}),
)
.catch(reject),
)
.catch(reject);
}),
url,
)) as T;
}
use() {
this.update({
lastUseTime: moment().unix(),
useCount: (this.info.useCount || 0) + 1,
});
}
}
================================================
FILE: model/bingcopilot/define.ts
================================================
import { ComInfo } from '../../utils/pool';
export interface Account extends ComInfo {}
export interface MessageUpdate {
text: string;
author: string;
createdAt: string;
timestamp: string;
messageId: string;
requestId: string;
offense: string;
adaptiveCards: AdaptiveCard[];
sourceAttributions: any[];
feedback: {
tag: null | string;
updatedOn: null | string;
type: string;
};
contentOrigin: string;
suggestedResponses: SuggestedResponse[];
}
interface AdaptiveCard {
type: string;
version: string;
body: TextBlock[];
}
interface TextBlock {
type: string;
text: string;
wrap: boolean;
}
interface SuggestedResponse {
text: string;
author: string;
createdAt: string;
timestamp: string;
messageId: string;
messageType: string;
offense: string;
feedback: {
tag: null | string;
updatedOn: null | string;
type: string;
};
contentOrigin: string;
}
export interface Message {
type: 1 | 2 | 6;
target: string;
arguments: [
{
messages: MessageUpdate[];
},
];
}
================================================
FILE: model/bingcopilot/index.ts
================================================
import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';
import { Pool } from '../../utils/pool';
import { Account, Message } from './define';
import { Child } from './child';
import { Config } from '../../utils/config';
import { Event, EventStream, parseJSON } from '../../utils';
import { WSS } from '../../utils/proxyAgent';
export class BingCopilot extends Chat {
private pool: Pool<Account, Child> = new Pool(
this.options?.name || '',
() => Config.config.bingcopilot.size,
(info, options) => {
return new Child(this.options?.name || '', info, options);
},
() => true,
{
serial: Config.config.bingcopilot.serial,
},
);
constructor(options?: ChatOptions) {
super(options);
}
support(model: ModelType): number {
switch (model) {
case ModelType.Bing:
return 2000;
default:
return 0;
}
}
async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
const child = await this.pool.pop();
const c = await child.createConversation();
const wss = new WSS(
`wss://sydney.bing.com/sydney/ChatHub?sec_access_token=${c.sign}`,
{
onOpen: () => {
this.logger.info('open');
wss.send(`{"protocol":"json","version":1}`);
},
onMessage: async (v) => {
this.logger.info(v);
const data = parseJSON<Message | undefined>(
v.slice(0, v.length - 1),
undefined,
);
if (!data) {
return;
}
if (!data.type) {
wss.send(`{"type":6}`);
wss.send(
await child.createMessage(
c.data.conversationId,
c.data.clientId,
req.prompt,
),
);
}
switch (data.type) {
case 1:
for (const v of data.arguments) {
for (const m of v.messages) {
stream.write(Event.message, { content: m.text });
}
}
break;
case 2:
stream.write(Event.done, { content: '' });
stream.end();
break;
default:
break;
}
},
onClose: () => {},
onError: (e: any) => {
console.error(e);
},
},
);
}
}
================================================
FILE: model/chatbase/index.ts
================================================
import {
Chat,
ChatOptions,
ChatRequest,
ChatResponse,
ModelType,
} from '../base';
import { AxiosInstance, AxiosRequestConfig, CreateAxiosDefaults } from 'axios';
import { CreateAxiosProxy } from '../../utils/proxyAgent';
import es from 'event-stream';
import {
ErrorData,
Event,
EventStream,
MessageData,
randomStr,
} from '../../utils';
export class ChatBase extends Chat {
private client: AxiosInstance;
constructor(options?: ChatOptions) {
super(options);
this.client = CreateAxiosProxy({
baseURL: 'https://www.chatbase.co/api',
headers: {
'Content-Type': 'application/json',
accept: 'text/event-stream',
'Cache-Control': 'no-cache',
'Proxy-Connection': 'keep-alive',
},
} as CreateAxiosDefaults);
}
support(model: ModelType): number {
switch (model) {
case ModelType.GPT3p5Turbo:
return 3000;
default:
return 0;
}
}
public async askStream(req: ChatRequest, stream: EventStream) {
const data = {
messages: req.messages,
captchaCode: 'hadsa',
chatId: 'chatbase--1--pdf-p680fxvnm',
conversationId: `y4-${randomStr(10)}-chatbase--1--pdf-p680fxvnm`,
};
try {
const res = await this.client.post('/fe/chat', data, {
responseType: 'stream',
} as AxiosRequestConfig);
res.data.pipe(
es.map(async (chunk: any, cb: any) => {
const content = chunk.toString();
if (!content) {
return;
}
stream.write(Event.message, { content });
}),
);
res.data.on('close', () => {
stream.write(Event.done, { content: '' });
stream.end();
});
} catch (e: any) {
console.error(e.message);
stream.write(Event.error, { error: e.message });
stream.end();
}
}
}
================================================
FILE: model/chatdemo/index.ts
================================================
import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';
import { Browser, Page, Protocol } from 'puppeteer';
import { BrowserPool, BrowserUser } from '../../utils/puppeteer';
import * as fs from 'fs';
import {
Event,
EventStream,
parseJSON,
randomUserAgent,
sleep,
} from '../../utils';
import { v4 } from 'uuid';
import moment from 'moment';
import { AxiosInstance, AxiosRequestConfig } from 'axios';
import es from 'event-stream';
import { CreateAxiosProxy } from '../../utils/proxyAgent';
import { CreateAxiosDefaults } from 'axios/index';
const TimeFormat = 'YYYY-MM-DD HH:mm:ss';
type Account = {
id: string;
email?: string;
login_time?: string;
last_use_time?: string;
password?: string;
cookie: Protocol.Network.Cookie[];
token: string;
useTimes: number;
};
interface RealReq {
question: string;
chat_id: string;
timestamp: number;
token: string;
}
class AccountPool {
private pool: Account[] = [];
private readonly account_file_path = './run/account_demochat.json';
private using = new Set<string>();
constructor() {
if (fs.existsSync(this.account_file_path)) {
const accountStr = fs.readFileSync(this.account_file_path, 'utf-8');
this.pool = parseJSON(accountStr, [] as Account[]);
} else {
fs.mkdirSync('./run', { recursive: true });
this.syncfile();
}
}
public syncfile() {
fs.writeFileSync(this.account_file_path, JSON.stringify(this.pool));
}
public getByID(id: string) {
for (const item of this.pool) {
if (item.id === id) {
return item;
}
}
}
public delete(id: string) {
this.pool = this.pool.filter((item) => item.id !== id);
this.syncfile();
}
public get(): Account {
const now = moment();
for (const item of this.pool) {
if (
(item.useTimes < 10 ||
moment(item.last_use_time).isBefore(
moment().subtract(1, 'd').subtract(2, 'h'),
)) &&
!this.using.has(item.id)
) {
console.log(`find old login account:`, JSON.stringify(item));
item.last_use_time = now.format(TimeFormat);
this.syncfile();
this.using.add(item.id);
return item;
}
}
const newAccount: Account = {
id: v4(),
last_use_time: now.format(TimeFormat),
cookie: [],
useTimes: 0,
token: '',
};
this.pool.push(newAccount);
this.syncfile();
this.using.add(newAccount.id);
return newAccount;
}
public multiGet(size: number): Account[] {
const result: Account[] = [];
for (let i = 0; i < size; i++) {
result.push(this.get());
}
return result;
}
}
export class ChatDemo extends Chat implements BrowserUser<Account> {
private pagePool: BrowserPool<Account>;
private accountPool: AccountPool;
private client: AxiosInstance;
private useragent: string = randomUserAgent();
constructor(options?: ChatOptions) {
super(options);
this.accountPool = new AccountPool();
let maxSize = +(process.env.DEMOCHAT_POOL_SIZE || 0);
this.pagePool = new BrowserPool<Account>(maxSize, this, false);
this.client = CreateAxiosProxy(
{
baseURL: 'https://chat.chatgptdemo.net',
headers: {
'Content-Type': 'application/json',
accept: 'text/event-stream',
'Cache-Control': 'no-cache',
'Proxy-Connection': 'keep-alive',
Referer: 'https://chat.chatgptdemo.net/',
Origin: 'https://chat.chatgptdemo.net',
},
} as CreateAxiosDefaults,
true,
);
}
support(model: ModelType): number {
switch (model) {
case ModelType.GPT3p5Turbo:
return 3000;
case ModelType.GPT3p5_16k:
return 3000;
default:
return 0;
}
}
deleteID(id: string): void {
this.accountPool.delete(id);
}
newID(): string {
const account = this.accountPool.get();
return account.id;
}
async init(
id: string,
browser: Browser,
): Promise<[Page | undefined, Account]> {
const account = this.accountPool.getByID(id);
try {
if (!account) {
throw new Error('account undefined, something error');
}
const [page] = await browser.pages();
await page.setUserAgent(this.useragent);
await page.goto('https://chat.chatgptdemo.net/');
await sleep(2000);
account.cookie = await page.cookies('https://chat.chatgptdemo.net');
if (account.cookie.length === 0) {
throw new Error('demochat got cookie failed');
}
await this.closePOP(page);
account.token = await this.getToken(page);
this.accountPool.syncfile();
this.logger.info('register demochat successfully');
return [page, account];
} catch (e: any) {
this.logger.warn('something error happened,err:', e.message);
return [] as any;
}
}
public async closePOP(page: Page) {
await page.evaluate(
() =>
// @ts-ignore
(document.querySelector(
'#ADS-block-detect > div.ads-block-popup',
// @ts-ignore
).style.display = 'none'),
);
// @ts-ignore
await page.evaluate(
() =>
// @ts-ignore
(document.querySelector(
'#ADS-block-detect > div.overlay',
// @ts-ignore
).style.display = 'none'),
);
}
public async getToken(page: Page) {
// @ts-ignore
const token: string = await page.evaluate(() => $('#TTT').text());
return token;
}
public async getChatID(page: Page) {
const chatid: string = await page.evaluate(() =>
// @ts-ignore
$('.chatbox-item.focused').attr('id'),
);
return chatid;
}
public async newChat(page: Page) {
await page.waitForSelector(
'.app > #main-menu > .main > .button-container > .button',
);
await page.click('.app > #main-menu > .main > .button-container > .button');
}
public async askStream(req: ChatRequest, stream: EventStream) {
const [page, account, done, destroy] = this.pagePool.get();
if (!account || !page || !account.cookie || account.cookie.length === 0) {
stream.write(Event.error, { error: 'please wait init.....about 1 min' });
stream.end();
return;
}
const data: RealReq = {
question: req.prompt,
chat_id: await this.getChatID(page),
timestamp: moment().valueOf(),
token: account.token,
};
try {
account.useTimes += 1;
this.accountPool.syncfile();
const res = await this.client.post('/chat_api_stream', data, {
responseType: 'stream',
headers: {
Cookie: account.cookie
.map((item) => `${item.name}=${item.value}`)
.join('; '),
},
} as AxiosRequestConfig);
res.data.pipe(es.split(/\r?\n\r?\n/)).pipe(
es.map(async (chunk: any, cb: any) => {
const dataStr = chunk.replace('data: ', '');
if (!dataStr) {
return;
}
const data = parseJSON(dataStr, {} as any);
if (!data?.choices) {
stream.write(Event.error, { error: 'not found data.choices' });
stream.end();
return;
}
const [
{
delta: { content = '' },
finish_reason,
},
] = data.choices;
if (finish_reason === 'stop') {
return;
}
stream.write(Event.message, { content });
}),
);
res.data.on('close', () => {
stream.write(Event.done, { content: '' });
stream.end();
this.newChat(page);
done(account);
});
} catch (e: any) {
this.logger.error('demochat ask stream failed, err', e.message);
stream.write(Event.error, { error: e.message });
stream.end();
await this.newChat(page);
destroy(true);
}
}
}
================================================
FILE: model/chatgateai/index.ts
================================================
import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';
import {
Event,
EventStream,
parseJSON,
randomNonce,
randomStr,
randomUserAgent,
sleep,
} from '../../utils';
import {
ChildOptions,
ComChild,
ComInfo,
DestroyOptions,
Pool,
} from '../../utils/pool';
import { Config } from '../../utils/config';
import { CreateAxiosProxy, CreateNewPage } from '../../utils/proxyAgent';
import { CreateEmail, TempEmailType } from '../../utils/emailFactory';
import moment from 'moment/moment';
import { v4 } from 'uuid';
import { Page } from 'puppeteer';
import { AxiosInstance } from 'axios';
import es from 'event-stream';
// @ts-ignore
import { Session } from 'tls-client/dist/esm/sessions';
import { randomInt } from 'crypto';
const ModelMap: Partial<Record<ModelType, string>> = {
[ModelType.GPT4]: 'chatbot-tydbjd',
[ModelType.Claude3Opus]: 'chatbot-zdmvyq',
};
interface Account extends ComInfo {
use_out_time: number;
email: string;
cookies: string;
XWPNonce: string;
}
class Child extends ComChild<Account> {
public client: AxiosInstance;
public page?: Page;
constructor(label: string, info: any, options?: ChildOptions) {
super(label, info, options);
this.client = CreateAxiosProxy(
{
baseURL: '',
},
false,
);
}
async init(): Promise<void> {
try {
if (this.info.cookies) {
this.logger.info('cookies found');
} else {
let page;
page = await CreateNewPage(
'https://chatgate.ai/login?redirect_to=https%3A%2F%2Fchatgate.ai%2F',
{ simplify: false },
);
this.page = page;
await page.waitForSelector(
'#firebaseui-auth-container > div > div.firebaseui-card-content > form > ul > li:nth-child(3) > button',
);
await page.click(
'#firebaseui-auth-container > div > div.firebaseui-card-content > form > ul > li:nth-child(3) > button',
);
const mailbox = CreateEmail(
Config.config.chatgateai?.mail_type || TempEmailType.TempMailLOL,
);
const email = await mailbox.getMailAddress();
this.update({
email: email,
});
await page.waitForSelector('input[type="email"]');
await page.click('input[type="email"]');
await page.keyboard.type(email);
await page.keyboard.press('Enter');
for (const v of await mailbox.waitMails()) {
let verifyUrl = v.content.match(/href=["'](.*?)["']/i)?.[1] || '';
if (!verifyUrl) {
throw new Error('verifyUrl not found');
}
verifyUrl = verifyUrl.replace(/&/g, '&');
await page.goto(verifyUrl, {
waitUntil: 'networkidle2',
timeout: 60 * 10000,
});
}
await sleep(10 * 6 * 1000);
await page.goto('https://chatgate.ai/gpt4/');
await sleep(5 * 1000);
const req = await page.waitForRequest(
(req) =>
req
.url()
.indexOf(
'https://chatgate.ai/wp-json/mwai-ui/v1/discussions/list',
) > -1,
);
this.logger.info(`req: ${req.url()}`);
const headers = req.headers();
this.logger.info(`headers: ${JSON.stringify(headers)}`);
const XWPNonce = headers['x-wp-nonce'];
const cookies = (await page.cookies('https://chatgate.ai'))
.map((v) => `${v.name}=${v.value}`)
.join('; ');
this.logger.info(`XWPNonce: ${XWPNonce}`);
this.update({
XWPNonce: XWPNonce,
cookies,
});
}
} catch (e) {
this.logger.error('init failed, ', e);
this.destroy({ delFile: false, delMem: true });
this.page?.browser().close();
}
}
destroy(options?: DestroyOptions) {
super.destroy(options);
}
use(): void {
this.update({
lastUseTime: moment().unix(),
useCount: (this.info.useCount || 0) + 1,
});
}
}
export class Chatgateai extends Chat {
private pool: Pool<Account, Child> = new Pool(
this.options?.name || '',
() => Config.config.chatgateai?.size || 0,
(info, options) => {
return new Child(this.options?.name || '', info, options);
},
(v) => {
if (!v.cookies) {
return false;
}
const resetTime = moment().utc().startOf('day').unix();
if (v.use_out_time > resetTime) {
return false;
}
return true;
},
{
delay: 1000,
serial: () => Config.config.chatgateai?.serial || 1,
needDel: (v) => !v.cookies,
},
);
constructor(options?: ChatOptions) {
super(options);
}
support(model: ModelType): number {
switch (model) {
case ModelType.GPT4:
return 1000;
case ModelType.Claude3Opus:
return 10000000;
default:
return 0;
}
}
async preHandle(req: ChatRequest): Promise<ChatRequest> {
const reqH = await super.preHandle(req, {
token: true,
countPrompt: true,
forceRemove: true,
});
return reqH;
}
async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
const child = await this.pool.pop();
if (!child) {
stream.write(Event.error, { error: 'No valid connections', status: 429 });
stream.write(Event.done, { content: '' });
stream.end();
return;
}
try {
const url = 'https://chatgate.ai/wp-json/mwai-ui/v1/chats/submit';
const headers = {
'Content-Type': 'application/json',
authority: 'chatgate.ai',
origin: 'https://chatgate.ai',
referer: 'https://chatgate.ai/gpt4/',
pragma: 'no-cache',
'X-WP-Nonce': child.info.XWPNonce,
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0',
Cookie: child.info.cookies,
};
const data = {
botId: ModelMap[req.model],
customId: null,
session: randomStr(12),
chatId: randomStr(12),
contextId: randomInt(10000, 99999),
messages: [
{
id: 'z4neetx1pl9',
role: 'assistant',
content: "Hi! I'm Claude-3 Opus. How can I assist you today?",
who: 'AI: ',
timestamp: Date.now() - 1000,
},
],
newMessage: req.prompt,
newFileId: null,
stream: true,
};
const res = await child.client.post(url, data, {
headers: headers,
responseType: 'stream',
});
res.data.pipe(es.split(/\r?\n\r?\n/)).pipe(
es.map((chunk: any) => {
try {
const data = chunk.toString().replace('data: ', '');
console.log(data);
if (data.includes('Reached your daily limit')) {
throw new Error('Reached your daily limit');
}
if (data.includes('rejected')) {
throw new Error('rejected');
}
if (!data) {
return;
}
const v = JSON.parse(data);
if (v.data) {
if (v.type === 'live') {
stream.write(Event.message, { content: v.data });
}
if (v.type === 'error') {
stream.write(Event.error, { error: v.data, status: 500 });
}
}
} catch (e: any) {
this.logger.error('parse data failed, ', e);
stream.write(Event.error, {
error: 'Something error, please retry later',
status: 500,
});
}
}),
);
res.data.on('close', () => {
this.logger.info('Msg recv ok');
stream.write(Event.done, { content: '' });
stream.end();
});
} catch (e: any) {
stream.write(Event.error, {
error: 'Something error, please retry later',
status: 500,
});
if (e.message === 'Reached your daily limit') {
child.update({
use_out_time: moment().utc().endOf('day').unix(),
});
} else if (e.message === 'rejected') {
// Add your statement or declaration here
} else {
child.update({
cookies: '',
});
}
stream.write(Event.done, { content: '' });
stream.end();
child.destroy({ delFile: false, delMem: true });
}
}
}
================================================
FILE: model/chatgateai/test.js
================================================
/*! For license information please see chatbot.js.LICENSE.txt */
(() => {
'use strict';
var n = {
856: (n, t, e) => {
e.d(t, {
A: () => c,
});
var r = e(601),
o = e.n(r),
i = e(314),
a = e.n(i)()(o());
a.push([
n.id,
".iOqlDdBnATVpadGvx1YX, .lndjoRWjp3ye2x5XZ29y {\n --mwai-spacing: 15px;\n --mwai-fontSize: 15px;\n --mwai-lineHeight: 1.5;\n --mwai-borderRadius: 10px;\n --mwai-width: 460px;\n --mwai-maxHeight: 40vh;\n --mwai-iconTextColor: white;\n --mwai-iconTextBackgroundColor: #343541;\n --mwai-fontColor: #FFFFFF;\n --mwai-backgroundPrimaryColor: #454654;\n --mwai-backgroundHeaderColor: #343541;\n --mwai-headerButtonsColor: #FFFFFF;\n --mwai-conversationsBackgroundColor: #202123;\n --mwai-conversationsTextColor: #FFFFFF;\n --mwai-backgroundSecondaryColor: #343541;\n --mwai-errorBackgroundColor: #6d2f2a;\n --mwai-errorTextColor: #FFFFFF;\n}\n\n.iOqlDdBnATVpadGvx1YX button, .lndjoRWjp3ye2x5XZ29y button {\n color: var(--mwai-fontColor);\n background: var(--mwai-backgroundSecondaryColor);\n border: 1px solid var(--mwai-backgroundPrimaryColor);\n padding: calc(var(--mwai-spacing) / 2) var(--mwai-spacing);\n min-width: 90px;\n border-radius: 5px;\n cursor: pointer;\n transition: all 0.2s ease-out;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 90%;\n position: relative;\n}\n\n.iOqlDdBnATVpadGvx1YX button .M1bTKgon3yJn1pg388Aw, .lndjoRWjp3ye2x5XZ29y button .M1bTKgon3yJn1pg388Aw {\n margin-left: 5px;\n margin-right: 5px;\n font-size: 11px;\n}\n\n.iOqlDdBnATVpadGvx1YX button:hover, .lndjoRWjp3ye2x5XZ29y button:hover {\n background: var(--mwai-backgroundPrimaryColor);\n}\n\n.iOqlDdBnATVpadGvx1YX button[disabled], .lndjoRWjp3ye2x5XZ29y button[disabled] {\n cursor: not-allowed;\n}\n\n.iOqlDdBnATVpadGvx1YX button[disabled] span, .lndjoRWjp3ye2x5XZ29y button[disabled] span {\n opacity: 0.5;\n}\n\n.iOqlDdBnATVpadGvx1YX button[disabled].v3cfCHqnK8iZsl1KBxr5 span, .lndjoRWjp3ye2x5XZ29y button[disabled].v3cfCHqnK8iZsl1KBxr5 span {\n display: none;\n}\n\n.iOqlDdBnATVpadGvx1YX button[disabled].v3cfCHqnK8iZsl1KBxr5:before, .lndjoRWjp3ye2x5XZ29y button[disabled].v3cfCHqnK8iZsl1KBxr5:before {\n content: '';\n width: 18px;\n height: 18px;\n margin: auto;\n border: 3px solid transparent;\n border-top-color: var(--mwai-fontColor);\n border-radius: 50%;\n animation: Q8R59WRCXYK3JY7gl3Nw 1s ease infinite;\n}\n\n.iOqlDdBnATVpadGvx1YX {\n border-radius: var(--mwai-borderRadius) var(--mwai-borderRadius);\n background: var(--mwai-backgroundHeaderColor);\n overflow: hidden;\n}\n\n.iOqlDdBnATVpadGvx1YX * {\n box-sizing: border-box;\n}\n\n.iOqlDdBnATVpadGvx1YX .a48TtMrGohiplJihDv4a {\n color: var(--mwai-headerButtonsColor);\n padding: var(--mwai-spacing);\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.iOqlDdBnATVpadGvx1YX .Aml8NHGXmSBh_55anACw {\n background: var(--mwai-conversationsBackgroundColor);\n list-style: none;\n padding: calc(var(--mwai-spacing) / 2);\n margin: 0;\n}\n\n.iOqlDdBnATVpadGvx1YX .Aml8NHGXmSBh_55anACw .OmmzQgRvsKUxTPnN1NGA {\n margin: 0;\n}\n\n.iOqlDdBnATVpadGvx1YX .Aml8NHGXmSBh_55anACw li {\n color: var(--mwai-conversationsTextColor);\n font-size: 75%;\n padding: calc(var(--mwai-spacing) / 2);\n opacity: 0.65;\n}\n\n.iOqlDdBnATVpadGvx1YX .Aml8NHGXmSBh_55anACw li.Ru4QsUQBo4Gov_bTpbJC {\n background: var(--mwai-backgroundPrimaryColor);\n border-radius: var(--mwai-borderRadius);\n opacity: 1;\n}\n\n.iOqlDdBnATVpadGvx1YX .Aml8NHGXmSBh_55anACw li:hover {\n background: var(--mwai-backgroundPrimaryColor);\n border-radius: var(--mwai-borderRadius);\n cursor: pointer;\n}\n\n.lndjoRWjp3ye2x5XZ29y * {\n box-sizing: border-box;\n}\n\n.lndjoRWjp3ye2x5XZ29y .Aml8NHGXmSBh_55anACw {\n background: var(--mwai-backgroundSecondaryColor);\n color: var(--mwai-fontColor);\n font-size: var(--mwai-fontSize);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n border-radius: var(--mwai-borderRadius);\n}\n\n.lndjoRWjp3ye2x5XZ29y .smw5eGNuW8ar3Rq6KsU5 {\n overflow: auto;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ {\n display: flex;\n padding: var(--mwai-spacing);\n position: relative;\n line-height: var(--mwai-lineHeight);\n transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .s6pfLhxkG5kdsInHIBwB {\n opacity: 0;\n transition: all 0.3s ease-out;\n width: 22px;\n height: 22px;\n position: absolute;\n right: var(--mwai-spacing);\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .s6pfLhxkG5kdsInHIBwB .yPOP1Mu_LbAFIAA1DiLC {\n position: absolute;\n width: 16px;\n height: 16px;\n margin-top: 0px;\n margin-left: 0px;\n background: white;\n opacity: 0.4;\n transition: all 0.2s ease-in;\n cursor: pointer;\n border-radius: 2px;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .s6pfLhxkG5kdsInHIBwB .Vo_Ic5uNSqGTmWJTRoUw {\n position: absolute;\n width: 16px;\n height: 16px;\n margin-top: 6px;\n margin-left: 6px;\n background: white;\n opacity: 0.6;\n transition: all 0.2s ease-in;\n cursor: pointer;\n border-radius: 2px;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .s6pfLhxkG5kdsInHIBwB:hover .yPOP1Mu_LbAFIAA1DiLC {\n opacity: 0.6;\n margin-top: 0px;\n margin-left: 6px;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .s6pfLhxkG5kdsInHIBwB:hover .Vo_Ic5uNSqGTmWJTRoUw {\n opacity: 1;\n margin-top: 6px;\n margin-left: 0px;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .s6pfLhxkG5kdsInHIBwB.saS9VjjVMXioL4CweV81 .yPOP1Mu_LbAFIAA1DiLC {\n opacity: 0;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .s6pfLhxkG5kdsInHIBwB.saS9VjjVMXioL4CweV81 .Vo_Ic5uNSqGTmWJTRoUw {\n width: 18px;\n height: 18px;\n margin-top: 2px;\n margin-left: 2px;\n opacity: 1;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ.LkkwYvlzeIMIzf7mtUwW {\n opacity: 0;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ:hover .s6pfLhxkG5kdsInHIBwB {\n display: block;\n opacity: 1;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ.ND9ujQp2hjVwNQTPWDSf {\n background: var(--mwai-backgroundSecondaryColor);\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ.xVfQe9VEYvuzMaqLoXuP {\n background: var(--mwai-backgroundPrimaryColor);\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .mVKuMauVy4SrhOGg0tO7 {\n color: var(--mwai-fontColor);\n margin-right: 5px;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .mVKuMauVy4SrhOGg0tO7 .V_Rv657Z7bGmaqPXFjGG {\n opacity: 0.50;\n white-space: nowrap;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .mVKuMauVy4SrhOGg0tO7 .hsW5GDpr7mGWbevVTphh {\n margin-right: 10px;\n width: 40px;\n height: 40px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 5px;\n overflow: hidden;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .mVKuMauVy4SrhOGg0tO7 .hsW5GDpr7mGWbevVTphh img {\n max-width: 100%;\n max-height: 100%;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .mVKuMauVy4SrhOGg0tO7 .hsW5GDpr7mGWbevVTphh.weQ0XGKhJgBusnPzOtWH img {\n width: 28px;\n height: 28px;\n filter: brightness(0) invert(1);\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox {\n flex: auto;\n font-size: var(--mwai-fontSize);\n line-height: var(--mwai-lineHeight);\n color: var(--mwai-fontColor);\n font-size: var(--mwai-fontSize);\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox .Sg9568fUZFHY_tr6YZ1r {\n display: block;\n max-width: 250px;\n height: auto;\n margin: 0 0 10px 0;\n border-radius: var(--mwai-borderRadius);\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox * {\n font-size: var(--mwai-fontSize);\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox > span > *:first-child {\n margin-top: 0;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox > span > *:last-child {\n margin-bottom: 0;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox a {\n color: #2196f3;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox h1 {\n font-size: 200%;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox h2 {\n font-size: 160%;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox h3 {\n font-size: 140%;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox h4 {\n font-size: 120%;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox p code {\n background: var(--mwai-backgroundSecondaryColor);\n padding: 2px 6px;\n border-radius: 8px;\n font-size: 90%;\n font-family: system-ui;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox pre {\n color: var(--mwai-fontColor);\n border-radius: var(--mwai-borderRadius);\n padding: calc(var(--mwai-spacing) * 2 / 3) var(--mwai-spacing);\n break-after: auto;\n white-space: pre-wrap;\n font-size: 95%;\n max-width: 100%;\n width: 100%;\n font-family: system-ui;\n background: #343541;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox pre code {\n padding: 0 !important;\n font-family: system-ui;\n background: #343541;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox ul {\n padding: 0;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox ol {\n padding: 0;\n margin: 0 0 0 20px;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox table {\n width: 100%;\n border: 2px solid var(--mwai-backgroundSecondaryColor);\n border-collapse: collapse;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox thead {\n background: var(--mwai-backgroundSecondaryColor);\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox tr, .lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox td {\n padding: 2px 5px;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox td {\n border: 2px solid var(--mwai-backgroundSecondaryColor);\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox .fJyiPz2f5_C8IfUzgD1m {\n display: inline-block;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox .fJyiPz2f5_C8IfUzgD1m > :first-child {\n margin-top: 0;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox > *:first-child {\n margin-top: 0;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ .CWHqlUDu9z_VhM1iNYox > *:last-child {\n margin-bottom: 0;\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ.CbsFIeB3668vSID0A4iZ {\n background: var(--mwai-errorBackgroundColor);\n color: var(--mwai-errorFontColor);\n}\n\n.lndjoRWjp3ye2x5XZ29y .F0C5IedgFBoZ1NVujRQZ.CbsFIeB3668vSID0A4iZ .mVKuMauVy4SrhOGg0tO7 {\n display: none;\n}\n\n.lndjoRWjp3ye2x5XZ29y .kgqpqavmCnlczZVXZMNw {\n display: flex;\n padding: var(--mwai-spacing);\n border-top: 1px solid var(--mwai-backgroundPrimaryColor);\n}\n\n.lndjoRWjp3ye2x5XZ29y .kgqpqavmCnlczZVXZMNw .ikW2DMZ6yprkNfgHcqIi {\n flex: auto;\n position: relative;\n display: flex;\n background: var(--mwai-backgroundPrimaryColor);\n border-radius: var(--mwai-borderRadius);\n overflow: hidden;\n}\n\n.lndjoRWjp3ye2x5XZ29y .kgqpqavmCnlczZVXZMNw .ikW2DMZ6yprkNfgHcqIi textarea {\n background: var(--mwai-backgroundPrimaryColor);\n color: var(--mwai-fontColor);\n flex: auto;\n padding: var(--mwai-spacing);\n border: none;\n font-size: var(--mwai-fontSize);\n resize: none;\n font-family: inherit;\n margin: 0;\n overflow: hidden;\n}\n\n.lndjoRWjp3ye2x5XZ29y .kgqpqavmCnlczZVXZMNw .ikW2DMZ6yprkNfgHcqIi textarea:focus {\n outline: none;\n box-shadow: none;\n}\n\n.lndjoRWjp3ye2x5XZ29y .kgqpqavmCnlczZVXZMNw .ikW2DMZ6yprkNfgHcqIi textarea::placeholder {\n color: var(--mwai-fontColor);\n opacity: 0.5;\n}\n\n.lndjoRWjp3ye2x5XZ29y .kgqpqavmCnlczZVXZMNw .ikW2DMZ6yprkNfgHcqIi .mNSHwda3gI7RQiK8_gv7, .lndjoRWjp3ye2x5XZ29y .kgqpqavmCnlczZVXZMNw .ikW2DMZ6yprkNfgHcqIi .hjMPRhlRyJZ70Vnwp52f {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n cursor: pointer;\n}\n\n.lndjoRWjp3ye2x5XZ29y .kgqpqavmCnlczZVXZMNw .ikW2DMZ6yprkNfgHcqIi .mNSHwda3gI7RQiK8_gv7 svg, .lndjoRWjp3ye2x5XZ29y .kgqpqavmCnlczZVXZMNw .ikW2DMZ6yprkNfgHcqIi .hjMPRhlRyJZ70Vnwp52f svg {\n fill: var(--mwai-fontColor);\n width: 34px;\n height: 34px;\n fill: var(--mwai-fontColor);\n opacity: 0.5;\n filter: grayscale(100%);\n transition: opacity 0.3s ease-out;\n}\n\n.lndjoRWjp3ye2x5XZ29y .kgqpqavmCnlczZVXZMNw .ikW2DMZ6yprkNfgHcqIi .mNSHwda3gI7RQiK8_gv7[active=true] svg, .lndjoRWjp3ye2x5XZ29y .kgqpqavmCnlczZVXZMNw .ikW2DMZ6yprkNfgHcqIi .hjMPRhlRyJZ70Vnwp52f[active=true] svg {\n opacity: 1;\n}\n\n.lndjoRWjp3ye2x5XZ29y .kgqpqavmCnlczZVXZMNw .ikW2DMZ6yprkNfgHcqIi .mNSHwda3gI7RQiK8_gv7[disabled] svg, .lndjoRWjp3ye2x5XZ29y .kgqpqavmCnlczZVXZMNw .ikW2DMZ6yprkNfgHcqIi .hjMPRhlRyJZ70Vnwp52f[disabled] svg {\n opacity: 0;\n}\n\n.lndjoRWjp3ye2x5XZ29y .kgqpqavmCnlczZVXZMNw .ikW2DMZ6ypr
gitextract_6_d41i1o/
├── .dockerignore
├── .github/
│ └── workflows/
│ └── docker-image.yml
├── .gitignore
├── .prettierrc
├── Dockerfile
├── HowToUse.md
├── LICENSE.txt
├── README.md
├── README_ja.md
├── README_zh.md
├── asyncstore.ts
├── docker-compose.yaml
├── index.ts
├── koa.d.ts
├── model/
│ ├── acytoo/
│ │ └── index.ts
│ ├── ails/
│ │ └── index.ts
│ ├── airoom/
│ │ └── index.ts
│ ├── airops/
│ │ └── index.ts
│ ├── askx/
│ │ └── index.ts
│ ├── auto.ts
│ ├── bai/
│ │ └── index.ts
│ ├── base.ts
│ ├── better/
│ │ └── index.ts
│ ├── bibi/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── bing/
│ │ └── index.ts
│ ├── bingcopilot/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── chatbase/
│ │ └── index.ts
│ ├── chatdemo/
│ │ └── index.ts
│ ├── chatgateai/
│ │ ├── index.ts
│ │ └── test.js
│ ├── chim/
│ │ └── index.ts
│ ├── chur/
│ │ └── index.ts
│ ├── claude/
│ │ └── index.ts
│ ├── claudeapi/
│ │ └── index.ts
│ ├── claudeauto/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── copilot/
│ │ └── index.ts
│ ├── cursor/
│ │ └── index.ts
│ ├── ddg/
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── test.js
│ ├── define.ts
│ ├── discord/
│ │ ├── child.ts
│ │ └── define.ts
│ ├── doc2x/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── domo/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ ├── prompt.ts
│ │ └── test.js
│ ├── easychat/
│ │ └── index.ts
│ ├── fakeopen/
│ │ └── index.ts
│ ├── fireworks/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── flux/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── forefront/
│ │ └── index.ts
│ ├── freegpt35/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── freegpt4/
│ │ ├── define.ts
│ │ └── index.ts
│ ├── gemini/
│ │ ├── define.ts
│ │ └── index.ts
│ ├── glm/
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── google/
│ │ └── index.ts
│ ├── gptgod/
│ │ └── index.ts
│ ├── gra/
│ │ └── index.ts
│ ├── groq/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── hypotenuse/
│ │ └── index.ts
│ ├── ideogram/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── index.ts
│ ├── izea/
│ │ └── index.ts
│ ├── jasper/
│ │ └── index.ts
│ ├── langdock/
│ │ └── index.ts
│ ├── magic/
│ │ └── index.ts
│ ├── mcbbs/
│ │ └── index.ts
│ ├── merlin/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── merlingmail/
│ │ ├── child.ts
│ │ └── index.ts
│ ├── midjourney/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── mixer/
│ │ └── index.ts
│ ├── mjplus/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── mjweb/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── myshell/
│ │ └── index.ts
│ ├── navit/
│ │ └── index.ts
│ ├── oneapi/
│ │ └── index.ts
│ ├── openai/
│ │ └── index.ts
│ ├── openaiauto/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── openprompt/
│ │ └── index.ts
│ ├── opensess/
│ │ └── index.ts
│ ├── pap/
│ │ └── index.ts
│ ├── perauto/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── perlabs/
│ │ ├── cfpool.ts
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── perplexity/
│ │ └── index.ts
│ ├── phind/
│ │ └── index.ts
│ ├── pika/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ └── index.ts
│ ├── poe/
│ │ └── define.ts
│ ├── pweb/
│ │ └── index.ts
│ ├── ram/
│ │ └── index.ts
│ ├── runway/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── sincode/
│ │ └── index.ts
│ ├── skailar/
│ │ └── index.ts
│ ├── stack/
│ │ └── index.ts
│ ├── suno/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── takeoff/
│ │ └── index.ts
│ ├── td/
│ │ └── index.ts
│ ├── toyy/
│ │ └── index.ts
│ ├── vanus/
│ │ └── index.ts
│ ├── vidu/
│ │ ├── child.ts
│ │ ├── define.ts
│ │ ├── index.ts
│ │ └── prompt.ts
│ ├── vita/
│ │ └── index.ts
│ ├── vvm/
│ │ └── index.ts
│ ├── www/
│ │ └── index.ts
│ └── xun/
│ └── index.ts
├── package.json
├── router.ts
├── tsconfig.json
└── utils/
├── cache.ts
├── captcha.ts
├── config.ts
├── emailFactory.ts
├── file.ts
├── index.ts
├── log.ts
├── middleware.ts
├── pool.ts
├── proxyAgent.ts
├── puppeteer.ts
└── web.ts
SYMBOL INDEX (1979 symbols across 148 files)
FILE: asyncstore.ts
type StoreSN (line 3) | type StoreSN = {
FILE: koa.d.ts
type Context (line 5) | interface Context {
FILE: model/acytoo/index.ts
type Message (line 14) | interface Message {
type RealReq (line 20) | interface RealReq {
class AcyToo (line 28) | class AcyToo extends Chat {
method constructor (line 31) | constructor(options?: ChatOptions) {
method support (line 44) | support(model: ModelType): number {
method preHandle (line 53) | async preHandle(
method askStream (line 60) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/ails/index.ts
type RealReq (line 24) | interface RealReq {
class Utils (line 34) | class Utils {
method hash (line 35) | static hash(json_data: { t: number; m: string }): string {
method format_timestamp (line 46) | static format_timestamp(timestamp: number): string {
class AILS (line 54) | class AILS extends Chat {
method constructor (line 57) | constructor(options?: ChatOptions) {
method support (line 88) | support(model: ModelType): number {
method askStream (line 97) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/airoom/index.ts
type Room (line 16) | type Room = {
type Account (line 21) | interface Account extends ComInfo {
class Child (line 33) | class Child extends ComChild<Account> {
method constructor (line 37) | constructor(label: string, info: any, options?: ChildOptions) {
method init (line 50) | async init(): Promise<void> {
method signup (line 80) | async signup() {
method login (line 90) | async login() {
method popRoom (line 111) | async popRoom(model: ModelType) {
method newRoom (line 124) | async newRoom(model: ModelType, save: boolean) {
method initFailed (line 155) | initFailed() {
method destroy (line 160) | destroy(options?: DestroyOptions) {
method use (line 164) | use(): void {
class AIRoom (line 172) | class AIRoom extends Chat {
method constructor (line 188) | constructor(options?: ChatOptions) {
method support (line 192) | support(model: ModelType): number {
method preHandle (line 203) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 211) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/airops/index.ts
constant APP_KEY (line 26) | const APP_KEY = 'af9e46318302fccfc6db';
constant APP_CLUSTER (line 27) | const APP_CLUSTER = 'mt1';
type Account (line 29) | interface Account extends ComInfo {
class Child (line 40) | class Child extends ComChild<Account> {
method constructor (line 47) | constructor(label: string, info: any, options?: ChildOptions) {
method setMsgListener (line 51) | public setMsgListener(cb: (event: string, data: string) => void) {
method removeMsgListener (line 72) | public removeMsgListener(channel: string) {
method init (line 76) | async init(): Promise<void> {
method getApiKey (line 203) | async getApiKey(page: Page) {
method getApp (line 218) | async getApp(page: Page) {
method createNewApp (line 235) | async createNewApp(page: Page) {
method use (line 337) | use(): void {
method destroy (line 344) | destroy(options?: DestroyOptions) {
class Airops (line 350) | class Airops extends Chat {
method constructor (line 365) | constructor(options?: ChatOptions) {
method support (line 369) | support(model: ModelType): number {
method preHandle (line 378) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 387) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/askx/index.ts
type Account (line 30) | interface Account extends ComInfo {
class Child (line 37) | class Child extends ComChild<Account> {
method constructor (line 41) | constructor(label: string, info: any, options?: ChildOptions) {
method init (line 51) | async init(): Promise<void> {
method updateToken (line 102) | async updateToken(page: Page) {
method initFailed (line 117) | initFailed() {
method destroy (line 125) | destroy(options?: DestroyOptions) {
method use (line 129) | use(): void {
class Askx (line 137) | class Askx extends Chat {
method constructor (line 153) | constructor(options?: ChatOptions) {
method support (line 157) | support(model: ModelType): number {
method preHandle (line 166) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 174) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/auto.ts
type AutoOptions (line 36) | interface AutoOptions extends ChatOptions {
class Auto (line 40) | class Auto extends Chat {
method constructor (line 46) | constructor(options: AutoOptions) {
method getRandomModel (line 104) | getRandomModel(req: {
method tryAskStream (line 172) | async tryAskStream(
method askStream (line 233) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
method support (line 237) | support(model: ModelType): number {
method preHandle (line 242) | async preHandle(req: ChatRequest, options: any): Promise<ChatRequest> {
method speech (line 300) | async speech(ctx: Application.Context, req: SpeechRequest): Promise<vo...
method generations (line 305) | async generations(
method embeddings (line 313) | async embeddings(
method transcriptions (line 321) | public async transcriptions(ctx: Context, req: TranscriptionRequest) {
method createVideoTask (line 326) | public async createVideoTask(ctx: Context, req: CreateVideoTaskRequest) {
method queryVideoTask (line 331) | public async queryVideoTask(
method createSong (line 339) | async createSong(ctx: Application.Context, req: SongOptions) {
method feedSong (line 344) | async feedSong(
method ImagesEdits (line 352) | async ImagesEdits(
FILE: model/bai/index.ts
type RealReq (line 20) | interface RealReq {
class Bai (line 24) | class Bai extends Chat {
method constructor (line 27) | constructor(options?: ChatOptions) {
method support (line 38) | support(model: ModelType): number {
method askStream (line 47) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/base.ts
type ChatOptions (line 27) | interface ChatOptions {
type ChatResponse (line 31) | interface ChatResponse {
type MessageContent (line 38) | type MessageContent =
type Message (line 54) | type Message = {
function getImagesFromContent (line 59) | function getImagesFromContent(content: MessageContent): string[] {
function getFilesFromContent (line 77) | function getFilesFromContent(content: MessageContent): string[] {
type ModelType (line 95) | enum ModelType {
type Site (line 241) | enum Site {
type ChatRequest (line 338) | interface ChatRequest {
type SpeechRequest (line 354) | interface SpeechRequest {
type TextEmbeddingRequest (line 363) | interface TextEmbeddingRequest {
type ImageGenerationRequest (line 398) | interface ImageGenerationRequest {
function contentToString (line 417) | function contentToString(content: MessageContent): string {
function messagesToPrompt (line 436) | function messagesToPrompt(messages: Message[]): string {
function randomRemoveContentChars (line 449) | function randomRemoveContentChars(
function countMessagesToken (line 470) | function countMessagesToken(messages: Message[]): number {
function sliceMessagesByToken (line 495) | function sliceMessagesByToken(
function sliceMessagesByLength (line 531) | function sliceMessagesByLength(
class Chat (line 567) | class Chat {
method constructor (line 571) | constructor(options?: ChatOptions) {
method support (line 576) | public support(model: ModelType): number {
method preHandle (line 580) | public async preHandle(
method ask (line 610) | public async ask(req: ChatRequest): Promise<ChatResponse> {
method askStream (line 653) | public async askStream(req: ChatRequest, stream: EventStream): Promise...
method webshow (line 657) | public async webshow(ctx: Context) {
method speech (line 661) | public async speech(ctx: Context, req: SpeechRequest) {
method ImagesEdits (line 665) | public async ImagesEdits(ctx: Context, req: ImageEditRequest) {
method generations (line 669) | public async generations(ctx: Context, req: ImageGenerationRequest) {
method embeddings (line 673) | public async embeddings(ctx: Context, req: TextEmbeddingRequest) {
method transcriptions (line 677) | public async transcriptions(ctx: Context, req: TranscriptionRequest) {
method createVideoTask (line 681) | public async createVideoTask(ctx: Context, req: CreateVideoTaskRequest) {
method queryVideoTask (line 685) | public async queryVideoTask(ctx: Context, req: QueryVideoTaskRequest) {
method createSong (line 689) | public async createSong(ctx: Context, req: SongOptions) {
method feedSong (line 693) | public async feedSong(
method dynamicRouter (line 700) | public dynamicRouter(router: Router): boolean {
FILE: model/better/index.ts
type Message (line 19) | interface Message {
type RealReq (line 30) | interface RealReq {
class Better (line 37) | class Better extends Chat {
method constructor (line 40) | constructor(options?: ChatOptions) {
method support (line 54) | support(model: ModelType): number {
method askStream (line 67) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/bibi/child.ts
class Child (line 23) | class Child extends ComChild<Account> {
method init (line 26) | async init(): Promise<void> {
method summary (line 40) | async summary(req: SummaryReq) {
method chapterSummary (line 52) | async chapterSummary(req: ChapterSummaryReq) {
method subtitle (line 58) | async subtitle(req: SubtitleReq) {
method chat (line 63) | async chat(req: ChatReq) {
method express (line 68) | async express(req: ExpressReq) {
method vision (line 73) | async vision(req: VisionReq) {
method use (line 78) | use() {
FILE: model/bibi/define.ts
type Account (line 5) | interface Account extends ComInfo {
type PageData (line 9) | interface PageData {
type ProcessingData (line 17) | interface ProcessingData {
type StatusData (line 24) | interface StatusData {
type SummaryReq (line 30) | type SummaryReq = {
type Subtitle (line 68) | interface Subtitle {
type VideoDetail (line 75) | interface VideoDetail {
type SummaryRes (line 94) | type SummaryRes = {
type ChapterSummaryReq (line 106) | type ChapterSummaryReq = {};
type ChapterSummaryReqJoi (line 107) | type ChapterSummaryReqJoi = {};
type ChapterSummaryRes (line 108) | type ChapterSummaryRes = {};
type SubtitleReq (line 110) | type SubtitleReq = {
type SubtitleRes (line 118) | type SubtitleRes = {
type ChatReq (line 133) | type ChatReq = {
type ChatRes (line 147) | type ChatRes = {
type ExpressReq (line 162) | type ExpressReq = {
type ExpressRes (line 180) | type ExpressRes = {
type VisionReq (line 191) | type VisionReq = {};
type VisionRes (line 193) | type VisionRes = {};
type PromptRes (line 195) | interface PromptRes {
FILE: model/bibi/index.ts
class Bibi (line 33) | class Bibi extends Chat {
method support (line 65) | support(model: ModelType): number {
method summaryStream (line 74) | async summaryStream(req: PromptRes, stream: EventStream) {
method subtitleStream (line 97) | async subtitleStream(req: SubtitleReq, stream: EventStream) {
method askStream (line 107) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
method dynamicRouter (line 165) | dynamicRouter(router: Router): boolean {
FILE: model/bing/index.ts
class Bing (line 11) | class Bing extends Chat {
method constructor (line 13) | constructor(options?: ChatOptions) {
method init (line 17) | async init() {
method newPage (line 22) | async newPage() {
method support (line 29) | support(model: ModelType): number {
method askStream (line 38) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/bingcopilot/child.ts
class Child (line 9) | class Child extends ComChild<Account> {
method init (line 13) | async init(): Promise<void> {
method getIP (line 19) | async getIP(): Promise<string> {
method createConversation (line 31) | async createConversation() {
method createMessage (line 43) | async createMessage(
method fetch (line 54) | async fetch<T>(url: string): Promise<T> {
method use (line 96) | use() {
FILE: model/bingcopilot/define.ts
type Account (line 3) | interface Account extends ComInfo {}
type MessageUpdate (line 5) | interface MessageUpdate {
type AdaptiveCard (line 24) | interface AdaptiveCard {
type TextBlock (line 30) | interface TextBlock {
type SuggestedResponse (line 36) | interface SuggestedResponse {
type Message (line 52) | interface Message {
FILE: model/bingcopilot/index.ts
class BingCopilot (line 9) | class BingCopilot extends Chat {
method constructor (line 22) | constructor(options?: ChatOptions) {
method support (line 26) | support(model: ModelType): number {
method askStream (line 35) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/chatbase/index.ts
class ChatBase (line 19) | class ChatBase extends Chat {
method constructor (line 22) | constructor(options?: ChatOptions) {
method support (line 35) | support(model: ModelType): number {
method askStream (line 44) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/chatdemo/index.ts
type Account (line 21) | type Account = {
type RealReq (line 32) | interface RealReq {
class AccountPool (line 39) | class AccountPool {
method constructor (line 44) | constructor() {
method syncfile (line 54) | public syncfile() {
method getByID (line 58) | public getByID(id: string) {
method delete (line 66) | public delete(id: string) {
method get (line 71) | public get(): Account {
method multiGet (line 101) | public multiGet(size: number): Account[] {
class ChatDemo (line 110) | class ChatDemo extends Chat implements BrowserUser<Account> {
method constructor (line 116) | constructor(options?: ChatOptions) {
method support (line 137) | support(model: ModelType): number {
method deleteID (line 148) | deleteID(id: string): void {
method newID (line 152) | newID(): string {
method init (line 157) | async init(
method closePOP (line 186) | public async closePOP(page: Page) {
method getToken (line 206) | public async getToken(page: Page) {
method getChatID (line 212) | public async getChatID(page: Page) {
method newChat (line 220) | public async newChat(page: Page) {
method askStream (line 227) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/chatgateai/index.ts
type Account (line 35) | interface Account extends ComInfo {
class Child (line 42) | class Child extends ComChild<Account> {
method constructor (line 46) | constructor(label: string, info: any, options?: ChildOptions) {
method init (line 56) | async init(): Promise<void> {
method destroy (line 126) | destroy(options?: DestroyOptions) {
method use (line 130) | use(): void {
class Chatgateai (line 138) | class Chatgateai extends Chat {
method constructor (line 162) | constructor(options?: ChatOptions) {
method support (line 166) | support(model: ModelType): number {
method preHandle (line 177) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 186) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/chatgateai/test.js
function e (line 262) | function e(n) {
function r (line 270) | function r(n, r) {
function o (line 299) | function o(n, t) {
function e (line 427) | function e(r) {
function b (line 487) | function b(n) {
function j (line 507) | function j(n, t) {
function R (line 576) | function R(n, t) {
function C (line 581) | function C(n, t) {
function k (line 593) | function k(n) {
function S (line 612) | function S() {
function I (line 627) | function I(n, t, e) {
function O (line 655) | function O(n, t) {
function X (line 859) | function X(n) {
function M (line 862) | function M(n) {
function P (line 880) | function P(n, t) {
function q (line 889) | function q(n) {
function n (line 903) | function n() {
function D (line 1017) | function D() {
function F (line 1456) | function F(n, t) {
function _ (line 1525) | function _(n, t) {
function Y (line 1530) | function Y(n, t, e, r, o, i, a) {
function G (line 1539) | function G(n) {
function U (line 1555) | function U(n) {
function tn (line 1590) | function tn(n, t) {
function en (line 1593) | function en() {
function rn (line 1795) | function rn(n, t, e, r) {
function on (line 1798) | function on() {
function an (line 1829) | function an(n, t, e, r) {
function cn (line 1832) | function cn() {
function ln (line 1915) | function ln() {
function un (line 1948) | function un(n) {
function dn (line 1967) | function dn(n, t) {
function fn (line 1979) | function fn(n) {
function hn (line 2024) | function hn() {
function mn (line 2463) | function mn(n, t, e, r, o, i, a) {
function yn (line 2472) | function yn(n) {
function gn (line 2488) | function gn(n) {
function vn (line 2508) | function vn(n, t) {
function bn (line 2563) | function bn(n, t) {
function wn (line 2578) | function wn(n, t) {
function Tn (line 3370) | function Tn() {
function Wt (line 3546) | function Wt(n) {
function Dt (line 3551) | function Dt(n) {
function Yt (line 3556) | function Yt(n) {
function Jt (line 3568) | function Jt(n) {
function ne (line 3582) | function ne(n, t) {
function ie (line 3644) | function ie(n) {
function ae (line 3659) | function ae(n) {
function ce (line 3668) | function ce(n, t, e) {
function le (line 3686) | function le(n, t, e) {
function se (line 3708) | function se(n, t) {
function ue (line 3715) | function ue(n) {
function pe (line 3720) | function pe(n) {
function de (line 3725) | function de(n) {
function fe (line 3730) | function fe(n) {
function he (line 3735) | function he(n, t, e) {
function me (line 3745) | function me(n) {
function ye (line 3758) | function ye(n) {
function ge (line 3761) | function ge(n, t, e) {
function ve (line 3768) | function ve(n, t, e) {
function be (line 3775) | function be(n, t, e) {
function xe (line 3781) | function xe() {
function je (line 3784) | function je() {
function Re (line 3787) | function Re(...n) {
function Ce (line 3790) | function Ce(n, t, e) {
function ke (line 3796) | function ke(n, t = {}) {
function Ie (line 4543) | function Ie() {
function n (line 4596) | function n() {}
function n (line 4700) | function n() {}
function n (line 4735) | function n(n, t) {
function Le (line 4961) | function Le(n) {
function Te (line 4979) | function Te(n, t) {
function Ne (line 4991) | function Ne(n) {
function Be (line 5080) | function Be(n, t) {
function Me (line 5191) | function Me(n, t) {
function Pe (line 5260) | function Pe(n, t) {
function Ue (line 5696) | function Ue() {
function ar (line 5763) | function ar(n, t, e) {
function mr (line 6023) | function mr(n) {
function yr (line 6041) | function yr(n, t) {
function gr (line 6053) | function gr(n) {
function vr (line 6098) | function vr(n) {
function br (line 6118) | function br() {
function wr (line 6557) | function wr(n, t, e, r, o, i, a) {
function xr (line 6566) | function xr(n) {
function jr (line 6582) | function jr(n, t) {
function Rr (line 6637) | function Rr(n, t) {
function Cr (line 6652) | function Cr(n, t) {
function Nr (line 7199) | function Nr(n) {
function Br (line 7218) | function Br() {
function Hr (line 7657) | function Hr(n, t) {
function Xr (line 7669) | function Xr(n) {
function Mr (line 7714) | function Mr(n, t, e, r, o, i, a) {
function Pr (line 7723) | function Pr(n) {
function qr (line 7739) | function qr(n, t) {
function Wr (line 7808) | function Wr(n, t) {
function Kr (line 8061) | function Kr(n) {
function $r (line 8079) | function $r(n, t) {
function no (line 8091) | function no(n) {
function lo (line 8254) | function lo(n) {
function n (line 8259) | function n(n, t) {
FILE: model/chim/index.ts
type RealReq (line 21) | interface RealReq {
class Chim (line 28) | class Chim extends Chat {
method constructor (line 31) | constructor(options?: ChatOptions) {
method support (line 45) | support(model: ModelType): number {
method askStream (line 58) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/chur/index.ts
type RealReq (line 20) | interface RealReq {
class Chur (line 30) | class Chur extends Chat {
method constructor (line 33) | constructor(options?: ChatOptions) {
method support (line 48) | support(model: ModelType): number {
method askStream (line 59) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/claude/index.ts
type MessageContent (line 18) | interface MessageContent {
type Author (line 23) | interface Author {
type Metadata (line 29) | interface Metadata {
type Message (line 35) | interface Message {
type Conversation (line 48) | interface Conversation {
type Account (line 54) | interface Account extends ComInfo {
class Child (line 62) | class Child extends ComChild<Account> {
method constructor (line 67) | constructor(label: string, info: any, options?: ChildOptions) {
method extractOrgId (line 71) | extractOrgId(url: string): string | null {
method updateOrg (line 77) | async updateOrg() {
method init (line 96) | async init(): Promise<void> {
method newChat (line 127) | async newChat(): Promise<string> {
method destroy (line 166) | async destroy(options?: DestroyOptions) {
method initFailed (line 178) | initFailed() {
method use (line 183) | use(): void {
class ClaudeChat (line 191) | class ClaudeChat extends Chat {
method constructor (line 229) | constructor(options?: ChatOptions) {
method support (line 233) | support(model: ModelType): number {
method preHandle (line 242) | async preHandle(
method askStream (line 268) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/claudeapi/index.ts
type RealReq (line 20) | interface RealReq {
type MessagesReq (line 32) | interface MessagesReq extends ChatRequest {
type ClaudeChatOptions (line 52) | interface ClaudeChatOptions extends ChatOptions {
class ClaudeAPI (line 73) | class ClaudeAPI extends Chat {
method constructor (line 77) | constructor(options?: ClaudeChatOptions) {
method support (line 96) | support(model: ModelType): number {
method preHandle (line 100) | async preHandle(
method askMessagesStream (line 129) | async askMessagesStream(req: MessagesReq, stream: EventStream) {
method askStream (line 257) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/claudeauto/child.ts
class Child (line 23) | class Child extends ComChild<Account> {
method init (line 41) | async init(): Promise<void> {
method use (line 72) | use(): void {
method checkChat (line 79) | async checkChat() {
method askMessagesStream (line 92) | async askMessagesStream(req: MessagesReq) {
FILE: model/claudeauto/define.ts
type Account (line 4) | interface Account extends ComInfo {
type MessagesReq (line 11) | interface MessagesReq extends ChatRequest {
FILE: model/claudeauto/index.ts
type RealReq (line 17) | interface RealReq {
class ClaudeAuto (line 29) | class ClaudeAuto extends Chat {
method constructor (line 71) | constructor(options?: ChatOptions) {
method support (line 75) | support(model: ModelType): number {
method preHandle (line 88) | async preHandle(
method askStream (line 104) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/copilot/index.ts
type Account (line 36) | type Account = {
type RealReq (line 46) | type RealReq = {
class CopilotAccountPool (line 51) | class CopilotAccountPool {
method constructor (line 56) | constructor() {
method syncfile (line 66) | public syncfile() {
method getByID (line 70) | public getByID(id: string) {
method delete (line 78) | public delete(id: string) {
method get (line 83) | public get(): Account {
method multiGet (line 105) | public multiGet(size: number): Account[] {
class Copilot (line 114) | class Copilot extends Chat implements BrowserUser<Account> {
method constructor (line 119) | constructor(options?: ChatOptions) {
method support (line 136) | support(model: ModelType): number {
method closeWelcomePop (line 145) | private static async closeWelcomePop(page: Page) {
method deleteID (line 157) | deleteID(id: string): void {
method newID (line 161) | newID(): string {
method newChat (line 166) | public static async newChat(page: Page) {
method getAuthKey (line 170) | private static async getAuthKey(page: Page): Promise<string> {
method init (line 177) | async init(
method ifLogin (line 270) | public static async ifLogin(page: Page): Promise<boolean> {
method clear (line 284) | public static async clear(page: Page) {
method askStream (line 294) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/cursor/index.ts
type Account (line 38) | type Account = {
type ConversationMessage (line 48) | interface ConversationMessage {
type Context (line 53) | interface Context {
type ModelDetails (line 57) | interface ModelDetails {
type RealReq (line 62) | interface RealReq {
type AuthRes (line 70) | type AuthRes = {
type UsageInfo (line 78) | interface UsageInfo {
type UsageDetails (line 85) | type UsageDetails = Partial<Record<ModelType, UsageInfo>>;
class CursorAccountPool (line 86) | class CursorAccountPool {
method constructor (line 91) | constructor() {
method syncfile (line 101) | public syncfile() {
method getByID (line 108) | public getByID(id: string) {
method release (line 116) | public release(id: string) {
method delete (line 120) | public delete(id: string) {
method get (line 125) | public get(): Account {
method multiGet (line 183) | public multiGet(size: number): Account[] {
function allowCursor (line 192) | function allowCursor() {
class Cursor (line 196) | class Cursor extends Chat implements BrowserUser<Account> {
method constructor (line 201) | constructor(options?: ChatOptions) {
method support (line 224) | support(model: ModelType): number {
method deleteID (line 235) | deleteID(id: string): void {
method release (line 239) | release(id: string): void {
method newID (line 243) | newID(): string {
method digest (line 248) | async digest(s: string) {
method getUsage (line 254) | async getUsage(page: Page) {
method init (line 263) | async init(
method accept (line 384) | private async accept(page: Page) {
method getToken (line 398) | private async getToken(
method askStream (line 413) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/ddg/index.ts
type Account (line 26) | interface Account extends ComInfo {}
class Child (line 28) | class Child extends ComChild<Account> {
method constructor (line 31) | constructor(label: string, info: any, options?: ChildOptions) {
method init (line 35) | async init(): Promise<void> {
method search (line 50) | async search(query: string) {
method initFailed (line 106) | initFailed() {
method destroy (line 111) | destroy(options?: DestroyOptions) {
class DDG (line 117) | class DDG extends Chat {
method constructor (line 130) | constructor(options?: ChatOptions) {
method support (line 134) | support(model: ModelType): number {
method preHandle (line 151) | async preHandle(
method searchStream (line 167) | async searchStream(req: ChatRequest, stream: EventStream) {
method chatStream (line 180) | async chatStream(req: ChatRequest, stream: EventStream): Promise<void> {
method askStream (line 240) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/ddg/test.js
function l (line 12) | function l() {
function d (line 69) | function d(e, t) {
function p (line 257) | function p({ children: e }) {
function R (line 301) | function R() {
function b (line 325) | function b(e) {
function T (line 340) | function T(e, t) {
function S (line 353) | function S(e) {
function x (line 660) | function x(e, t) {
function V (line 726) | function V(e, t) {
function Z (line 739) | function Z(e) {
function j (line 759) | function j({ api: e, modelConfig: t, initialMessages: a }) {
function W (line 1140) | function W() {
function ae (line 1208) | function ae(e, t) {
function ne (line 1257) | function ne(e) {
function le (line 1309) | function le({ enabled: e, onClick: t }) {
function oe (line 1343) | function oe() {
function ue (line 1379) | function ue() {
function pe (line 1425) | function pe(e, t) {
function Re (line 1438) | function Re(e) {
function fe (line 1458) | function fe(e) {
function Ce (line 1578) | function Ce({ amount: e = 3, overrideSuggestions: t }) {
function Oe (line 1600) | function Oe({ children: e }) {
function Se (line 1697) | function Se({ children: e }) {
function Le (line 1721) | function Le({ status: e = 'default', modelStyleId: t = 'default' }) {
function De (line 1742) | function De(e) {
function Pe (line 1771) | function Pe({ children: e }) {
function xe (line 1781) | function xe({ contentExpanded: e, children: t }) {
function Ue (line 1793) | function Ue({ children: e }) {
function He (line 1814) | function He({ onSuggestionClick: e, overrideSuggestions: t }) {
function Ve (line 1867) | function Ve({ suggestionBrief: e, modelStyleId: t, onClick: a }) {
function Ke (line 1895) | function Ke(e, t) {
function Fe (line 1966) | function Fe({ charCount: e, charLimit: t, errorMaxChars: a }) {
function We (line 2007) | function We() {
function qe (line 2042) | function qe({ children: e, tooltipLabel: t, onClick: a }) {
function Je (line 2062) | function Je({ content: e, onClick: t = () => null }) {
function Xe (line 2076) | function Xe({ onClick: e }) {
function $e (line 2088) | function $e({
function tt (line 2173) | function tt({ state: e, children: t }) {
function at (line 2189) | function at({ error: e, status: t = 'ready' }) {
function rt (line 2282) | function rt() {
function ot (line 2343) | function ot({ content: e }) {
function Rt (line 2355) | function Rt() {
function vt (line 2477) | function vt({ open: e, closeModal: t, clearConversation: a }) {
function gt (line 2520) | function gt({ clearConversation: e, enabled: t }) {
function At (line 2548) | function At() {
function Dt (line 2610) | function Dt() {
function Ht (line 2700) | function Ht({ as: e = 'div', className: t, badgeText: a = 'NEW!' }) {
function Zt (line 2716) | function Zt({ className: e }) {
function jt (line 2725) | function jt({ className: e }) {
function Ft (line 2740) | function Ft({ open: e, closeModal: t, onShareFeedbackClick: a }) {
function Gt (line 2834) | function Gt() {
function zt (line 2882) | function zt() {
function qt (line 2912) | function qt() {
function ra (line 2979) | function ra() {
function oa (line 3041) | function oa({ open: e, closeModal: t }) {
function sa (line 3078) | function sa() {
function ua (line 3105) | function ua() {
function _a (line 3152) | function _a() {
function Ia (line 3269) | function Ia({ model: e, checked: t, onClick: a }) {
function Oa (line 3353) | function Oa({ children: e, variant: t }) {
function Ta (line 3373) | function Ta({ open: e, onClose: t }) {
function Sa (line 3461) | function Sa() {
function La (line 3494) | function La({
function Ma (line 3520) | function Ma({
function Pa (line 3762) | function Pa({ variant: e = 'singleColumn', style: t = {}, children: a }) {
function Ua (line 3784) | function Ua() {
function Va (line 3849) | function Va({ modelStyleId: e }) {
function Za (line 3855) | function Za() {
function ja (line 3887) | function ja() {
function Ga (line 3930) | function Ga() {
function Ya (line 3995) | function Ya(e) {
function za (line 4084) | function za() {
function rn (line 4206) | function rn({ showSection: e, isFocuseable: t }) {
function ln (line 4592) | function ln({ initialScreen: e = 0 }) {
function cn (line 4655) | function cn({ className: e, onAction: t, isFocuseable: a }) {
function on (line 4731) | function on({
function sn (line 4828) | function sn({ className: e, onAction: t, isFocuseable: a }) {
function un (line 4909) | function un({ illustration: e, text: t }) {
function mn (line 4928) | function mn({ children: e }) {
function dn (line 4939) | function dn({ children: e }) {
function En (line 4950) | function En() {
function Rn (line 4970) | function Rn(e) {
function fn (line 4974) | function fn({
function hn (line 5033) | function hn({
FILE: model/define.ts
type AudioFileFormat (line 7) | type AudioFileFormat =
type LanguageISO639_1 (line 18) | type LanguageISO639_1 = string;
type ResponseFormat (line 21) | type ResponseFormat = 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';
type TimestampGranularity (line 24) | type TimestampGranularity = 'word' | 'segment';
type TranscriptionRequest (line 27) | interface TranscriptionRequest {
type CreateVideoTaskRequest (line 71) | interface CreateVideoTaskRequest {
type QueryVideoTaskRequest (line 77) | interface QueryVideoTaskRequest {
type ImageEditRequest (line 82) | interface ImageEditRequest {
FILE: model/discord/child.ts
class DiscordChild (line 21) | class DiscordChild<
method sendEvent (line 46) | sendEvent(e: GatewayEventPayload) {
method interact (line 50) | async interact(d: InteractionPayload<InteractionType>) {
method upload (line 61) | async upload(url: string) {
method getMessages (line 93) | async getMessages() {
method waitGatewayEventName (line 104) | async waitGatewayEventName<T>(
method waitGatewayEventNameAsync (line 131) | async waitGatewayEventNameAsync<T>(
method identify (line 153) | identify() {
method sendHeartBeat (line 196) | sendHeartBeat() {
method initHello (line 203) | initHello(heatBeatInterval: number) {
method handleHello (line 212) | async handleHello(e: GatewayEventPayload<GatewayDHello>) {
method listenEvent (line 216) | listenEvent(e: GatewayEventPayload<any>) {
method initWS (line 231) | initWS() {
method destroy (line 259) | destroy(options?: DestroyOptions) {
method init (line 267) | async init(): Promise<void> {
method initFailed (line 294) | initFailed(e?: Error) {
method use (line 302) | use(): void {
FILE: model/discord/define.ts
type DiscordAccount (line 4) | interface DiscordAccount extends ComInfo {
type MessageFlags (line 11) | enum MessageFlags {
type GatewayEvents (line 25) | enum GatewayEvents {
type GatewayMessageType (line 39) | enum GatewayMessageType {
type GatewayEventName (line 73) | enum GatewayEventName {
type Embed (line 80) | interface Embed {
type MessageSubComponent (line 91) | interface MessageSubComponent {
type MessageComponent (line 103) | interface MessageComponent {
type UserMember (line 108) | interface UserMember {
type User (line 121) | interface User {
type GatewayEventPayload (line 134) | interface GatewayEventPayload<T = any> {
type GatewayHandler (line 141) | type GatewayHandler<T = any> = (payload: GatewayEventPayload<T>) => void;
type GatewayDHello (line 143) | interface GatewayDHello {
type GatewayDInteractionCreate (line 148) | interface GatewayDInteractionCreate {
type GatewayDInteractionSuccess (line 153) | interface GatewayDInteractionSuccess {
type GatewayMessageAttachment (line 158) | interface GatewayMessageAttachment {
type GatewayMessage (line 171) | interface GatewayMessage {
type GatewayDMessageCreate (line 201) | interface GatewayDMessageCreate extends GatewayMessage {}
type GatewayDMessageUpdate (line 203) | interface GatewayDMessageUpdate extends GatewayMessage {}
type InteractionType (line 205) | enum InteractionType {
type InteractionPayload (line 213) | interface InteractionPayload<T extends InteractionType> {
type InteractionDataOption (line 230) | interface InteractionDataOption {
type ApplicationCommandType (line 236) | enum ApplicationCommandType {
type ApplicationCommandOptionType (line 242) | enum ApplicationCommandOptionType {
type ApplicationCommand (line 256) | interface ApplicationCommand {
type ApplicationCommandAttachment (line 274) | interface ApplicationCommandAttachment {
type ChoiceItem (line 280) | interface ChoiceItem {
type ApplicationCommandOption (line 286) | interface ApplicationCommandOption {
function getProgress (line 415) | function getProgress(text: string) {
function getPrompt (line 424) | function getPrompt(text: string) {
type AIActionType (line 431) | enum AIActionType {
type AIAction (line 437) | type AIAction = {
type UploadFileInfo (line 470) | type UploadFileInfo = {
type UploadedFileData (line 477) | type UploadedFileData = {
type DimensionsType (line 483) | enum DimensionsType {
FILE: model/doc2x/child.ts
class Child (line 10) | class Child extends ComChild<Account> {
method init (line 12) | async init(): Promise<void> {
method pdfToStream (line 32) | async pdfToStream(form: FormData, stream: EventStream) {
method pdfToMDStream (line 52) | async pdfToMDStream(form: FormData, stream: EventStream) {
method pdfToMDWithProgressStream (line 81) | async pdfToMDWithProgressStream(form: FormData, stream: EventStream) {
method pdfToJSONStream (line 112) | async pdfToJSONStream(form: FormData, stream: EventStream) {
method use (line 129) | use() {
FILE: model/doc2x/define.ts
type Account (line 3) | interface Account extends ComInfo {
type PageData (line 7) | interface PageData {
type ProcessingData (line 15) | interface ProcessingData {
type StatusData (line 22) | interface StatusData {
FILE: model/doc2x/index.ts
class Doc2x (line 11) | class Doc2x extends Chat {
method support (line 43) | support(model: ModelType): number {
method handlePDF (line 62) | async handlePDF(req: ChatRequest, stream: EventStream) {
method askStream (line 91) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/domo/child.ts
class Child (line 26) | class Child extends DiscordChild<Account> {
method doComponent (line 29) | async doComponent(message_id: string, info: MessageSubComponent) {
method gen (line 54) | async gen(
method animate (line 128) | async animate(image_url: string) {
method video (line 173) | async video(video_url: string, prompt: string) {
method getInfo (line 225) | async getInfo(): Promise<DomoProfileInfo> {
method updateInfo (line 264) | async updateInfo() {
method init (line 278) | async init(): Promise<void> {
method createVideo (line 283) | async createVideo(options: { image_url?: string; video_url?: string }) {
FILE: model/domo/define.ts
type Account (line 9) | interface Account extends DiscordAccount {
function getProgress (line 225) | function getProgress(text: string) {
function getPrompt (line 234) | function getPrompt(text: string) {
type AIActionType (line 241) | enum AIActionType {
type AIAction (line 247) | type AIAction = {
type DimensionsType (line 283) | enum DimensionsType {
type DomoProfileInfo (line 295) | interface DomoProfileInfo {
type DomoSpeedMode (line 340) | enum DomoSpeedMode {
type ArtStyle (line 345) | enum ArtStyle {
FILE: model/domo/index.ts
class Domo (line 41) | class Domo extends Chat {
method constructor (line 96) | constructor(options?: ChatOptions) {
method support (line 100) | support(model: ModelType): number {
method handleComponents (line 115) | async handleComponents(
method gen (line 153) | async gen(
method askStream (line 204) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
method imgToVideo (line 289) | async imgToVideo(req: ChatRequest, stream: EventStream): Promise<void> {
method videoToVideo (line 351) | async videoToVideo(req: ChatRequest, stream: EventStream): Promise<voi...
FILE: model/easychat/index.ts
type PageData (line 34) | type PageData = {
type Message (line 42) | interface Message {
type RealReq (line 47) | interface RealReq {
type Account (line 56) | type Account = {
type HistoryData (line 66) | type HistoryData = {
class EasyChatAccountPool (line 74) | class EasyChatAccountPool {
method constructor (line 79) | constructor() {
method syncfile (line 89) | public syncfile() {
method getByID (line 93) | public getByID(id: string) {
method delete (line 101) | public delete(id: string) {
method get (line 106) | public get(): Account {
method multiGet (line 127) | public multiGet(size: number): Account[] {
type EasyChatOptions (line 136) | interface EasyChatOptions extends ChatOptions {
class EasyChat (line 140) | class EasyChat extends Chat implements BrowserUser<Account> {
method constructor (line 146) | constructor(options?: EasyChatOptions) {
method support (line 163) | support(model: ModelType): number {
method closeWelcomePop (line 172) | private static async closeWelcomePop(page: Page) {
method deleteID (line 185) | deleteID(id: string): void {
method newID (line 189) | newID(): string {
method init (line 194) | async init(
method askStream (line 271) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/fakeopen/index.ts
type Message (line 24) | interface Message {
type RealReq (line 29) | interface RealReq {
type ValidModelsResp (line 40) | type ValidModelsResp = {
type LoginRes (line 61) | type LoginRes = {
type Account (line 70) | type Account = {
class AccountPool (line 84) | class AccountPool {
method constructor (line 90) | constructor() {
method initialize (line 116) | async initialize() {
method syncfile (line 214) | public syncfile() {
method getByID (line 218) | public getByID(id: string) {
method delete (line 226) | public delete(id: string) {
method release (line 234) | public release(id: string) {
method get (line 238) | public get(isPlus: boolean): Account {
class FakeOpen (line 261) | class FakeOpen extends Chat {
method constructor (line 265) | constructor(options?: ChatOptions) {
method support (line 286) | support(model: ModelType): number {
method askStream (line 299) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/fireworks/child.ts
class Child (line 18) | class Child extends ComChild<Account> {
method saveCookies (line 25) | async saveCookies() {
method saveUA (line 31) | async saveUA() {
method saveAPIKey (line 36) | async saveAPIKey() {
method checkChat (line 54) | async checkChat() {
method askForStream (line 77) | async askForStream(req: any, stream: EventStream) {
method init (line 112) | async init() {
method initFailed (line 188) | initFailed() {
method use (line 193) | use() {
method destroy (line 200) | destroy(options?: DestroyOptions) {
FILE: model/fireworks/define.ts
type Account (line 5) | interface Account extends ComInfo {
type UserAuth (line 19) | interface UserAuth {
type Organization (line 24) | interface Organization {
type UserOrgs (line 39) | interface UserOrgs {
type User (line 44) | interface User {
type ProfileRes (line 56) | interface ProfileRes {
type FireworksModel (line 60) | interface FireworksModel {
function extractSecretKey (line 99) | function extractSecretKey(inputString: string) {
function getFireworksModel (line 109) | function getFireworksModel(model: ModelType) {
FILE: model/fireworks/index.ts
class Fireworks (line 10) | class Fireworks extends Chat {
method constructor (line 11) | constructor(options?: ChatOptions) {
method support (line 70) | support(model: ModelType): number {
method askStream (line 78) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/flux/child.ts
class Child (line 28) | class Child extends ComChild<Account> {
method constructor (line 36) | constructor(
method client (line 45) | get client() {
method saveCookies (line 80) | async saveCookies() {
method getHeader (line 98) | async getHeader() {
method saveUA (line 124) | async saveUA() {
method chat (line 129) | async chat(messages: string) {
method predictions (line 141) | async predictions(req: PredictionsReq) {
method result (line 149) | async result(id: string) {
method init (line 159) | async init() {
method initFailed (line 189) | initFailed() {
method use (line 194) | use() {
method destroy (line 201) | destroy(options?: DestroyOptions) {
FILE: model/flux/define.ts
type Account (line 8) | interface Account extends ComInfo {
type PredictionsReq (line 23) | interface PredictionsReq {
type PredictionsRes (line 29) | interface PredictionsRes {
type ResultRes (line 34) | interface ResultRes {
class ClertAuth (line 61) | class ClertAuth {
method constructor (line 65) | constructor(
method updateSID (line 90) | async updateSID() {
method getToken (line 107) | async getToken() {
FILE: model/flux/index.ts
class Flux (line 32) | class Flux extends Chat {
method support (line 88) | support(model: ModelType): number {
method askStream (line 97) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
method dynamicRouter (line 171) | dynamicRouter(router: Router): boolean {
FILE: model/forefront/index.ts
type PageData (line 35) | type PageData = {
type Account (line 43) | type Account = {
type RealReq (line 54) | interface RealReq {
class AccountPool (line 67) | class AccountPool {
method constructor (line 71) | constructor() {
method syncfile (line 81) | public syncfile() {
method getByID (line 85) | public getByID(id: string) {
method delete (line 93) | public delete(id: string) {
method get (line 98) | public get(): Account {
method multiGet (line 123) | public multiGet(size: number): Account[] {
type ForefrontOptions (line 132) | interface ForefrontOptions extends ChatOptions {
class Forefrontnew (line 136) | class Forefrontnew extends Chat implements BrowserUser<Account> {
method constructor (line 142) | constructor(options?: ForefrontOptions) {
method support (line 165) | support(model: ModelType): number {
method tryValidate (line 176) | private async tryValidate(validateURL: string, triedTimes: number) {
method closeWelcomePop (line 191) | private static async closeWelcomePop(page: Page) {
method deleteID (line 239) | deleteID(id: string): void {
method newID (line 243) | newID(): string {
method getChatID (line 248) | private static async getChatID(page: Page): Promise<string> {
method init (line 258) | async init(
method ifLogin (line 347) | public static async ifLogin(page: Page): Promise<boolean> {
method getAuth (line 360) | private async getAuth(page: Page): Promise<Record<string, string>> {
method askStream (line 394) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/freegpt35/child.ts
class Child (line 11) | class Child extends ComChild<Account> {
method constructor (line 34) | constructor(label: string, info: Account, options?: any) {
method updateSessionID (line 38) | async updateSessionID() {
method askForStream (line 50) | async askForStream(req: ChatRequest, stream: EventStream) {
method init (line 117) | async init() {
method use (line 128) | use() {
method destroy (line 134) | destroy(options?: DestroyOptions) {
FILE: model/freegpt35/define.ts
type Account (line 3) | interface Account extends ComInfo {}
type MessageContent (line 5) | interface MessageContent {
type Author (line 13) | interface Author {
type Metadata (line 19) | interface Metadata {
type Message (line 31) | interface Message {
type Conversation (line 44) | interface Conversation {
FILE: model/freegpt35/index.ts
class FreeGPT35 (line 8) | class FreeGPT35 extends Chat {
method constructor (line 25) | constructor(options?: ChatOptions) {
method support (line 29) | support(model: ModelType): number {
method preHandle (line 40) | async preHandle(
method askStream (line 54) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/freegpt4/define.ts
type ApiKeyBase (line 1) | interface ApiKeyBase {
type ApiKey (line 7) | interface ApiKey extends ApiKeyBase {
type ApiKeysData (line 14) | interface ApiKeysData {
FILE: model/freegpt4/index.ts
type Room (line 21) | type Room = {
type Account (line 26) | interface Account extends ComInfo {
class Child (line 33) | class Child extends ComChild<Account> {
method constructor (line 37) | constructor(label: string, info: any, options?: ChildOptions) {
method createAPIKey (line 47) | async createAPIKey(info: ApiKeyBase) {
method getAPIKey (line 71) | async getAPIKey(): Promise<ApiKeysData> {
method initAPIKey (line 94) | async initAPIKey() {
method init (line 152) | async init(): Promise<void> {
method initFailed (line 221) | initFailed() {
method destroy (line 226) | destroy(options?: DestroyOptions) {
method use (line 230) | use(): void {
class FreeGPT4 (line 238) | class FreeGPT4 extends Chat {
method constructor (line 254) | constructor(options?: ChatOptions) {
method support (line 258) | support(model: ModelType): number {
method preHandle (line 269) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 277) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/gemini/define.ts
type GeminiRequest (line 3) | interface GeminiRequest extends ChatRequest {
FILE: model/gemini/index.ts
type Account (line 35) | interface Account extends ComInfo {
class Child (line 40) | class Child extends ComChild<Account> {
method init (line 48) | async init(): Promise<void> {
method use (line 53) | use() {
method getMimeTypeFromBase64 (line 60) | getMimeTypeFromBase64(base64: string) {
method destroy (line 65) | destroy(options?: DestroyOptions) {
method checkChat (line 69) | async checkChat() {
method messageToContent (line 102) | async messageToContent(
method preHandleContent (line 183) | async preHandleContent(data: Content[]) {
method generateContentStream (line 205) | async generateContentStream(req: GeminiRequest) {
class Gemini (line 273) | class Gemini extends Chat {
method constructor (line 313) | constructor(options?: ChatOptions) {
method support (line 317) | support(model: ModelType): number {
method preHandle (line 335) | async preHandle(
method askStream (line 347) | public async askStream(req: GeminiRequest, stream: EventStream) {
FILE: model/glm/define.ts
type VideoGenerationsReq (line 3) | interface VideoGenerationsReq {
type VideoGenerationsRes (line 9) | interface VideoGenerationsRes {
type AsyncResultRes (line 16) | interface AsyncResultRes {
FILE: model/glm/index.ts
type RealReq (line 42) | interface RealReq extends ChatRequest {
type GLMChatOptions (line 61) | interface GLMChatOptions extends ChatOptions {
function generateAuthToken (line 76) | function generateAuthToken(apiKey: string): string {
class GLM (line 107) | class GLM extends Chat {
method constructor (line 111) | constructor(options?: GLMChatOptions) {
method support (line 131) | support(model: ModelType): number {
method preHandle (line 135) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method videoGenerations (line 148) | async videoGenerations(
method asyncResult (line 155) | async asyncResult(id: string): Promise<AsyncResultRes> {
method handleCogViewX (line 160) | public async handleCogViewX(req: ChatRequest, stream: EventStream) {
method askStream (line 241) | public async askStream(req: ChatRequest, stream: EventStream) {
method speech (line 337) | async speech(ctx: Application.Context, req: SpeechRequest): Promise<vo...
method generations (line 346) | async generations(
method dynamicRouter (line 355) | dynamicRouter(router: Router): boolean {
FILE: model/google/index.ts
class Google (line 11) | class Google extends Chat {
method constructor (line 13) | constructor(options?: ChatOptions) {
method init (line 17) | async init() {
method newPage (line 22) | async newPage() {
method support (line 29) | support(model: ModelType): number {
method askStream (line 38) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/gptgod/index.ts
type Account (line 15) | interface Account extends ComInfo {}
class Child (line 17) | class Child extends ComChild<Account> {
method constructor (line 20) | constructor(label: string, info: any, options?: ChildOptions) {
method init (line 24) | async init(): Promise<void> {
method initFailed (line 56) | initFailed() {
method destroy (line 61) | destroy(options?: DestroyOptions) {
method use (line 66) | use(): void {
class GPTGOD (line 74) | class GPTGOD extends Chat {
method constructor (line 87) | constructor(options?: ChatOptions) {
method support (line 91) | support(model: ModelType): number {
method preHandle (line 95) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 103) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/gra/index.ts
type Message (line 7) | interface Message {
type RealReq (line 12) | interface RealReq {
class Gra (line 19) | class Gra extends Chat {
method constructor (line 22) | constructor(options?: ChatOptions) {
method support (line 35) | support(model: ModelType): number {
method ask (line 46) | public async ask(req: ChatRequest): Promise<ChatResponse> {
method askStream (line 71) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/groq/child.ts
class Child (line 22) | class Child extends ComChild<Account> {
method saveCookies (line 29) | async saveCookies() {
method token (line 39) | get token() {
method saveUA (line 44) | async saveUA() {
method fetch (line 49) | async fetch<T>(path: string, requestInit: RequestInit): Promise<T> {
method saveOrgID (line 98) | async saveOrgID() {
method checkChat (line 108) | async checkChat() {
method askForStream (line 148) | async askForStream(req: any, stream: EventStream) {
method init (line 221) | async init() {
method initFailed (line 276) | initFailed() {
method use (line 281) | use() {
method destroy (line 288) | destroy(options?: DestroyOptions) {
FILE: model/groq/define.ts
type Account (line 7) | interface Account extends ComInfo {
type UserAuth (line 20) | interface UserAuth {
type Organization (line 25) | interface Organization {
type UserOrgs (line 40) | interface UserOrgs {
type User (line 45) | interface User {
type ProfileRes (line 57) | interface ProfileRes {
type GroqModel (line 61) | interface GroqModel {
FILE: model/groq/index.ts
class Groq (line 10) | class Groq extends Chat {
method constructor (line 11) | constructor(options?: ChatOptions) {
method support (line 69) | support(model: ModelType): number {
method askStream (line 77) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/hypotenuse/index.ts
type Account (line 26) | interface Account extends ComInfo {
class Child (line 32) | class Child extends ComChild<Account> {
method constructor (line 38) | constructor(label: string, info: any, options?: ChildOptions) {
method init (line 42) | async init(): Promise<void> {
method createThreads (line 88) | async createThreads() {
method sendMessage (line 109) | async sendMessage(threadID: string, prompt: string) {
method genRes (line 145) | async genRes(thrID: string, msgID: string, model: ModelType) {
method saveSess (line 182) | async saveSess() {
method initFailed (line 191) | initFailed() {
method destroy (line 196) | destroy(options?: DestroyOptions) {
class Hypotenuse (line 202) | class Hypotenuse extends Chat {
method constructor (line 218) | constructor(options?: ChatOptions) {
method support (line 222) | support(model: ModelType): number {
method preHandle (line 235) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 243) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/ideogram/child.ts
class Child (line 37) | class Child extends ComChild<Account> {
method constructor (line 47) | constructor(
method client (line 56) | get client() {
method saveUA (line 73) | async saveUA() {
method checkCreateProfile (line 79) | async checkCreateProfile() {
method checkUsage (line 91) | async checkUsage() {
method init (line 103) | async init() {
method initFailed (line 137) | initFailed() {
method use (line 142) | use() {
method close (line 149) | close() {
method close_delay (line 157) | get close_delay() {
method destroy (line 161) | async destroy(options?: DestroyOptions) {
method ImagesSample (line 179) | async ImagesSample(req: ideogram.ImagesSampleReq) {
method ImagesSamplingAvailable (line 191) | async ImagesSamplingAvailable(model_version: string = 'V_0_2') {
method GalleryRetrieveRequests (line 200) | async GalleryRetrieveRequests(request_ids: string[]) {
method saveToken (line 217) | async saveToken() {
method saveUserID (line 262) | async saveUserID() {
method GetRefreshToken (line 268) | async GetRefreshToken(refreshToken: string) {
method Login (line 296) | async Login(external_photo_url: string) {
method downloadAndUploadCDN (line 307) | async downloadAndUploadCDN(response_id: string) {
FILE: model/ideogram/define.ts
type Account (line 8) | interface Account extends ComInfo {
type PredictionsReq (line 27) | interface PredictionsReq {
type PredictionsRes (line 33) | interface PredictionsRes {
type ResultRes (line 38) | interface ResultRes {
class ClertAuth (line 50) | class ClertAuth {
method constructor (line 54) | constructor(
method updateSID (line 79) | async updateSID() {
method getToken (line 96) | async getToken() {
type StyleExpert (line 118) | enum StyleExpert {
type ModelVersion (line 127) | enum ModelVersion {
type AspectRatio (line 131) | enum AspectRatio {
type Action (line 152) | interface Action {
type Resolution (line 158) | interface Resolution {
type ColorPalette (line 163) | interface ColorPalette {
type ImagesSampleReq (line 167) | interface ImagesSampleReq {
type ImagesSampleRes (line 178) | interface ImagesSampleRes {
type ImagesSamplingAvailableRes (line 189) | interface ImagesSamplingAvailableRes {
type ProviderData (line 200) | interface ProviderData {
type StsTokenManager (line 209) | interface StsTokenManager {
type User (line 215) | interface User {
type TokenRefreshResponse (line 230) | interface TokenRefreshResponse {
type SamplingRequest (line 240) | interface SamplingRequest {
type Response (line 264) | interface Response {
type User (line 278) | interface User {
type UserHparams (line 286) | interface UserHparams {
type GalleryRetrieveRes (line 290) | interface GalleryRetrieveRes {
type EnabledFeatures (line 294) | interface EnabledFeatures {
type SubscriptionStatus (line 298) | interface SubscriptionStatus {
type UserModel (line 305) | interface UserModel {
type LoginRes (line 316) | interface LoginRes {
FILE: model/ideogram/index.ts
class Ideogram (line 29) | class Ideogram extends Chat {
method support (line 83) | support(model: ModelType): number {
method askStream (line 92) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
method dynamicRouter (line 187) | dynamicRouter(router: Router): boolean {
FILE: model/index.ts
class ChatModelFactory (line 81) | class ChatModelFactory {
method constructor (line 85) | constructor(options?: ChatOptions) {
method init (line 91) | init() {
method get (line 222) | get(model: Site): Chat | undefined {
method forEach (line 226) | forEach(callbackfn: (value: Chat, key: Site, map: Map<Site, Chat>) => ...
FILE: model/izea/index.ts
type RealAck (line 24) | interface RealAck {
type Account (line 29) | interface Account extends ComInfo {
type Events (line 36) | type Events = {
class Child (line 42) | class Child extends ComChild<Account> {
method isMsg (line 48) | isMsg(msg: string): boolean {
method startListener (line 57) | async startListener() {
method decUseLeft (line 98) | decUseLeft() {
method sendMsg (line 108) | async sendMsg(model: ModelType, prompt: string, events?: Events) {
method updateUseLeft (line 150) | public async updateUseLeft(page: Page) {
method clearContext (line 166) | public async clearContext() {
method updateToken (line 170) | public async updateToken(page: Page) {
method init (line 183) | async init(): Promise<void> {
method initFailed (line 269) | initFailed() {
method destroy (line 274) | destroy(options?: DestroyOptions) {
class Izea (line 280) | class Izea extends Chat {
method constructor (line 303) | constructor(options?: ChatOptions) {
method support (line 307) | support(model: ModelType): number {
method preHandle (line 316) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 336) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/jasper/index.ts
type UseLeft (line 33) | type UseLeft = Partial<Record<ModelType, number>>;
type Account (line 40) | type Account = {
class AccountPool (line 53) | class AccountPool {
method constructor (line 58) | constructor() {
method syncfile (line 98) | public syncfile() {
method getByID (line 102) | public getByID(id: string) {
method delete (line 110) | public delete(id: string) {
method release (line 118) | public release(id: string) {
method get (line 122) | public get(): Account {
type PerplexityChatRequest (line 145) | interface PerplexityChatRequest extends ChatRequest {
class Jasper (line 149) | class Jasper extends Chat implements BrowserUser<Account> {
method constructor (line 153) | constructor(options?: ChatOptions) {
method support (line 165) | support(model: ModelType): number {
method deleteID (line 176) | deleteID(id: string): void {
method release (line 180) | release(id: string): void {
method newID (line 184) | newID(): string {
method init (line 189) | async init(
method newChat (line 217) | async newChat(page: Page) {
method isLogin (line 222) | public async isLogin(page: Page) {
method goHome (line 235) | public static async goHome(page: Page) {
method isVIP (line 239) | public async isVIP(page: Page) {
method changeMode (line 255) | private async changeMode(page: Page, model: ModelType = ModelType.GPT4) {
method askStream (line 275) | public async askStream(req: PerplexityChatRequest, stream: EventStream) {
FILE: model/langdock/index.ts
type Account (line 33) | interface Account extends ComInfo {
class Child (line 45) | class Child extends ComChild<Account> {
method constructor (line 52) | constructor(label: string, info: any, options?: ChildOptions) {
method getChatID (line 68) | async getChatID(): Promise<[string, () => Promise<void>]> {
method acceptCK (line 78) | async acceptCK(page: Page): Promise<void> {
method newChat (line 94) | async newChat() {
method init (line 121) | async init(): Promise<void> {
method destroy (line 213) | destroy(options?: DestroyOptions) {
method readyChat (line 218) | async readyChat(page: Page) {
method sayHello (line 227) | async sayHello(page: Page) {
method selectModel (line 237) | async selectModel() {
method selectAllModel (line 259) | async selectAllModel(page: Page) {
method newWorkspace (line 281) | async newWorkspace(page: Page) {
method getTK (line 294) | async getTK(page: Page) {
method getID (line 324) | async getID() {
method use (line 346) | use(): void {
class Langdock (line 353) | class Langdock extends Chat {
method constructor (line 372) | constructor(options?: ChatOptions) {
method support (line 376) | support(model: ModelType): number {
method preHandle (line 387) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 399) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/magic/index.ts
type PageData (line 11) | type PageData = {
type Account (line 19) | type Account = {
type ModelInfo (line 29) | interface ModelInfo {
type RealReq (line 57) | interface RealReq {
type HistoryData (line 65) | type HistoryData = {
class MagicAccountPool (line 73) | class MagicAccountPool {
method constructor (line 78) | constructor() {
method syncfile (line 88) | public syncfile() {
method getByID (line 92) | public getByID(id: string) {
method delete (line 100) | public delete(id: string) {
method get (line 105) | public get(): Account {
method multiGet (line 118) | public multiGet(size: number): Account[] {
class Magic (line 127) | class Magic extends Chat implements BrowserUser<Account> {
method constructor (line 134) | constructor(options?: ChatOptions) {
method support (line 153) | support(model: ModelType): number {
method deleteID (line 170) | deleteID(id: string): void {
method newID (line 174) | newID(): string {
method init (line 179) | async init(
method askStream (line 211) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/mcbbs/index.ts
type Message (line 19) | interface Message {
type RealReq (line 24) | interface RealReq {
class Mcbbs (line 32) | class Mcbbs extends Chat {
method constructor (line 35) | constructor(options?: ChatOptions) {
method support (line 48) | support(model: ModelType): number {
method askStream (line 59) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/merlin/child.ts
class Child (line 16) | class Child extends ComChild<Account> {
method constructor (line 20) | constructor(label: string, info: any, options?: ChildOptions) {
method init (line 30) | async init(): Promise<void> {
method initFailed (line 118) | initFailed(e?: Error) {
method destroy (line 131) | destroy(options?: DestroyOptions) {
method genSignImage (line 135) | async genSignImage(contentType: string[] = [], numOfImages: number = 1) {
method getLoginStatus (line 168) | async getLoginStatus(page: Page) {
method getUsage (line 214) | async getUsage(page: Page) {
method getSession (line 227) | async getSession(token: string) {
method use (line 234) | use(): void {
FILE: model/merlin/define.ts
type Account (line 4) | interface Account extends ComInfo {
FILE: model/merlin/index.ts
class Merlin (line 11) | class Merlin extends Chat {
method constructor (line 40) | constructor(options?: ChatOptions) {
method support (line 44) | support(model: ModelType): number {
method preHandle (line 65) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 85) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/merlingmail/child.ts
class MerlinGmailChild (line 7) | class MerlinGmailChild extends Child {
method init (line 8) | async init(): Promise<void> {
FILE: model/merlingmail/index.ts
class MerlinGmail (line 28) | class MerlinGmail extends Chat {
method constructor (line 64) | constructor(options?: ChatOptions) {
method support (line 68) | support(model: ModelType): number {
method preHandle (line 89) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 103) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/midjourney/child.ts
class Child (line 28) | class Child extends DiscordChild<Account> {
method imagine (line 30) | async imagine(
method doComponent (line 104) | async doComponent(
method blend (line 163) | async blend(
method getInfo (line 262) | async getInfo(): Promise<MJProfileInfo> {
method updateInfo (line 301) | async updateInfo() {
method init (line 312) | async init(): Promise<void> {
FILE: model/midjourney/define.ts
type Account (line 8) | interface Account extends DiscordAccount {
function getProgress (line 131) | function getProgress(text: string) {
function getPrompt (line 140) | function getPrompt(text: string) {
type AIActionType (line 147) | enum AIActionType {
type AIAction (line 153) | type AIAction = {
type DimensionsType (line 186) | enum DimensionsType {
type MJProfileInfo (line 198) | interface MJProfileInfo {
type MJSpeedMode (line 263) | enum MJSpeedMode {
FILE: model/midjourney/index.ts
class Midjourney (line 27) | class Midjourney extends Chat {
method constructor (line 86) | constructor(options?: ChatOptions) {
method support (line 90) | support(model: ModelType): number {
method doMultiComponents (line 99) | async doMultiComponents(
method doComponents (line 134) | async doComponents(
method handleComponents (line 200) | async handleComponents(
method imagine (line 239) | async imagine(
method blend (line 301) | async blend(
method askStream (line 370) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/mixer/index.ts
type Account (line 31) | interface Account extends ComInfo {
class Child (line 37) | class Child extends ComChild<Account> {
method constructor (line 40) | constructor(label: string, info: any, options?: ChildOptions) {
method init (line 55) | async init(): Promise<void> {
method use (line 117) | use(): void {
method destroy (line 124) | destroy(options?: DestroyOptions) {
class Mixer (line 130) | class Mixer extends Chat {
method constructor (line 148) | constructor(options?: ChatOptions) {
method support (line 152) | support(model: ModelType): number {
method preHandle (line 163) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method getReward (line 184) | async getReward(client: AxiosInstance, rewardId: string) {
method askStream (line 200) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/mjplus/child.ts
class Child (line 16) | class Child extends ComChild<Account> {
method init (line 18) | async init(): Promise<void> {
method use (line 33) | use() {
method fetchTask (line 40) | async fetchTask(id: string): Promise<Task> {
method imagine (line 48) | async imagine(req: ImagineRequest): Promise<ComReturn<DiscordPropertie...
method blend (line 59) | async blend(req: BlendRequest): Promise<ComReturn<DiscordProperties>> {
method action (line 70) | async action(req: ActionRequest): Promise<ComReturn<DiscordProperties>> {
method swapFace (line 81) | async swapFace(req: SwapFaceRequest): Promise<ComReturn<DiscordPropert...
FILE: model/mjplus/define.ts
type Account (line 3) | interface Account extends ComInfo {
type ComReturn (line 8) | interface ComReturn<T = DiscordProperties> {
type DiscordProperties (line 15) | interface DiscordProperties {
type Task (line 20) | interface Task {
type TaskProperties (line 38) | interface TaskProperties {
type TaskButton (line 51) | interface TaskButton {
type AccountFilter (line 59) | interface AccountFilter {
type BotType (line 68) | enum BotType {
type ImagineRequest (line 73) | interface ImagineRequest {
type BlendRequest (line 82) | interface BlendRequest {
type ActionRequest (line 91) | interface ActionRequest {
type SwapFaceRequest (line 99) | interface SwapFaceRequest {
type ToolType (line 107) | enum ToolType {
type ToolInfo (line 114) | interface ToolInfo {
type ImageTool (line 125) | interface ImageTool extends ToolInfo {
type BlendTool (line 129) | interface BlendTool extends ToolInfo {
type ActionTool (line 134) | interface ActionTool extends ToolInfo {
type SwapFaceTool (line 139) | interface SwapFaceTool extends ToolInfo {
FILE: model/mjplus/index.ts
class MJPlus (line 30) | class MJPlus extends Chat {
method support (line 64) | support(model: ModelType): number {
method imageStream (line 73) | async imageStream(child: Child, req: ImageTool, stream: EventStream) {
method blendStream (line 136) | async blendStream(child: Child, req: BlendTool, stream: EventStream) {
method actionStream (line 208) | async actionStream(child: Child, req: ActionTool, stream: EventStream) {
method askStream (line 272) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/mjweb/child.ts
class Child (line 28) | class Child extends ComChild<Account> {
method constructor (line 36) | constructor(
method client (line 45) | get client() {
method saveCookies (line 80) | async saveCookies() {
method getHeader (line 98) | async getHeader() {
method saveUA (line 124) | async saveUA() {
method chat (line 129) | async chat(messages: string) {
method predictions (line 141) | async predictions(req: PredictionsReq) {
method result (line 149) | async result(id: string) {
method init (line 159) | async init() {
method initFailed (line 210) | initFailed() {
method use (line 215) | use() {
method destroy (line 222) | destroy(options?: DestroyOptions) {
FILE: model/mjweb/define.ts
type Account (line 8) | interface Account extends ComInfo {
type PredictionsReq (line 23) | interface PredictionsReq {
type PredictionsRes (line 29) | interface PredictionsRes {
type ResultRes (line 34) | interface ResultRes {
class ClertAuth (line 61) | class ClertAuth {
method constructor (line 65) | constructor(
method updateSID (line 90) | async updateSID() {
method getToken (line 107) | async getToken() {
FILE: model/mjweb/index.ts
class MJWeb (line 24) | class MJWeb extends Chat {
method support (line 80) | support(model: ModelType): number {
method askStream (line 89) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
method dynamicRouter (line 163) | dynamicRouter(router: Router): boolean {
FILE: model/myshell/index.ts
type Account (line 39) | type Account = {
type ReplyMessage (line 50) | interface ReplyMessage {
type TextStreamData (line 68) | interface TextStreamData {
type TextStream (line 75) | interface TextStream {
class PoeAccountPool (line 81) | class PoeAccountPool {
method constructor (line 86) | constructor() {
method syncfile (line 111) | public syncfile() {
method release (line 115) | public release(id: string) {
method getByID (line 119) | public getByID(id: string) {
method delete (line 127) | public delete(id: string) {
method get (line 135) | public get(): Account {
class MyShell (line 164) | class MyShell extends Chat implements BrowserUser<Account> {
method constructor (line 169) | constructor(options?: ChatOptions) {
method support (line 181) | support(model: ModelType): number {
method preHandle (line 192) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method deleteID (line 200) | deleteID(id: string): void {
method release (line 204) | release(id: string): void {
method newID (line 208) | newID(): string {
method init (line 213) | async init(
method enterInviteCode (line 305) | async enterInviteCode(page: Page) {
method getFreeTrail (line 332) | async getFreeTrail(page: Page) {
method getBattery (line 341) | async getBattery(token: string) {
method initWSS (line 353) | async initWSS(
method getChatBooster (line 379) | async getChatBooster(page: Page) {
method getToken (line 417) | async getToken(page: Page) {
method getVisitorId (line 425) | async getVisitorId(page: Page) {
method askStream (line 435) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/navit/index.ts
type Account (line 23) | interface Account extends ComInfo {
class Child (line 34) | class Child extends ComChild<Account> {
method constructor (line 40) | constructor(label: string, info: any, options?: ChildOptions) {
method createWSS (line 50) | createWSS() {
method init (line 78) | async init(): Promise<void> {
method getToken (line 144) | async getToken(page: Page) {
method getUserInfo (line 152) | async getUserInfo(page: Page) {
method updateQuota (line 164) | async updateQuota() {
method updateModelID (line 184) | async updateModelID() {
method initFailed (line 220) | initFailed() {
method destroy (line 225) | destroy(options?: DestroyOptions) {
method sendMsg (line 230) | sendMsg(
method clearContext (line 296) | clearContext(model: ModelType) {
class Navit (line 312) | class Navit extends Chat {
method constructor (line 334) | constructor(options?: ChatOptions) {
method support (line 338) | support(model: ModelType): number {
method preHandle (line 351) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 359) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/oneapi/index.ts
type RealReq (line 23) | interface RealReq {
class OneAPI (line 30) | class OneAPI extends Chat {
method constructor (line 33) | constructor(options?: ChatOptions) {
method support (line 49) | support(model: ModelType): number {
method getRandomKey (line 53) | getRandomKey() {
method askStream (line 58) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/openai/index.ts
type RealReq (line 29) | interface RealReq extends ChatRequest {
type OpenAIChatOptions (line 48) | interface OpenAIChatOptions extends ChatOptions {
class OpenAI (line 74) | class OpenAI extends Chat {
method constructor (line 78) | constructor(options?: OpenAIChatOptions) {
method newClient (line 83) | newClient() {
method support (line 99) | support(model: ModelType): number {
method preHandle (line 105) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 115) | public async askStream(req: ChatRequest, stream: EventStream) {
method speech (line 191) | async speech(ctx: Application.Context, req: SpeechRequest): Promise<vo...
method generations (line 201) | async generations(
method embeddings (line 211) | async embeddings(
method transcriptions (line 221) | async transcriptions(
method createVideoTask (line 231) | async createVideoTask(
method queryVideoTask (line 239) | async queryVideoTask(
method createSong (line 247) | async createSong(ctx: Application.Context, req: SongOptions) {
method feedSong (line 252) | async feedSong(
FILE: model/openaiauto/child.ts
class Child (line 13) | class Child extends ComChild<Account> {
method init (line 30) | async init(): Promise<void> {
method initFailed (line 45) | initFailed(e?: any) {
method use (line 53) | use(): void {
method checkChat (line 60) | async checkChat() {
method handleError (line 103) | async handleError(e: { error: { message: string } }) {
FILE: model/openaiauto/define.ts
type Account (line 4) | interface Account extends ComInfo {
type MessagesReq (line 11) | interface MessagesReq extends ChatRequest {
type OpenaiError (line 43) | type OpenaiError = {
FILE: model/openaiauto/index.ts
type RealReq (line 19) | interface RealReq extends ChatRequest {
class OpenAIAuto (line 38) | class OpenAIAuto extends Chat {
method constructor (line 80) | constructor(options?: ChatOptions) {
method support (line 84) | support(model: ModelType): number {
method preHandle (line 91) | async preHandle(
method askStream (line 107) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/openprompt/index.ts
type Account (line 34) | type Account = {
type RealReq (line 44) | type RealReq = {
class OpenPromptAccountPool (line 49) | class OpenPromptAccountPool {
method constructor (line 54) | constructor() {
method syncfile (line 64) | public syncfile() {
method getByID (line 68) | public getByID(id: string) {
method delete (line 76) | public delete(id: string) {
method get (line 81) | public get(): Account {
method multiGet (line 110) | public multiGet(size: number): Account[] {
class OpenPrompt (line 119) | class OpenPrompt extends Chat implements BrowserUser<Account> {
method constructor (line 124) | constructor(options?: ChatOptions) {
method support (line 141) | support(model: ModelType): number {
method deleteID (line 150) | deleteID(id: string): void {
method newID (line 154) | newID(): string {
method newChat (line 159) | public static async newChat(page: Page) {
method init (line 163) | async init(
method ifLogin (line 250) | public async ifLogin(page: Page): Promise<boolean> {
method askStream (line 262) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/opensess/index.ts
type RealReq (line 27) | interface RealReq extends ChatRequest {
type MessageContent (line 64) | interface MessageContent {
type Author (line 69) | interface Author {
type Metadata (line 75) | interface Metadata {
type Message (line 81) | interface Message {
type Conversation (line 94) | interface Conversation {
type Account (line 100) | interface Account extends ComInfo {
class Child (line 107) | class Child extends ComChild<Account> {
method constructor (line 113) | constructor(label: string, info: any, options?: ChildOptions) {
method init (line 117) | async init(): Promise<void> {
method getToken (line 169) | async getToken() {
method updateToken (line 182) | async updateToken() {
method updateSess (line 190) | async updateSess() {
method destroy (line 209) | async destroy(options?: DestroyOptions) {
method initFailed (line 214) | initFailed() {
method use (line 219) | use(): void {
class OpenSess (line 227) | class OpenSess extends Chat {
method constructor (line 247) | constructor(options?: ChatOptions) {
method support (line 251) | support(model: ModelType): number {
method preHandle (line 262) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 270) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/pap/index.ts
type Message (line 19) | interface Message {
type RealReq (line 24) | interface RealReq {
class Pap (line 31) | class Pap extends Chat {
method constructor (line 34) | constructor(options?: ChatOptions) {
method support (line 47) | support(model: ModelType): number {
method askStream (line 56) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/perauto/child.ts
class Child (line 28) | class Child extends ComChild<Account> {
method isLogin (line 36) | async isLogin(page: Page) {
method set (line 48) | private async set(page: Page) {
method setCopilot (line 60) | async setCopilot(open: boolean) {
method listenTokenChange (line 67) | async listenTokenChange() {
method goHome (line 96) | public async goHome() {
method changeMode (line 117) | public async changeMode(t: FocusType) {
method initIO (line 143) | async initIO() {
method updateVisitorID (line 176) | async updateVisitorID() {
method init (line 185) | async init(): Promise<void> {
method initFailed (line 246) | initFailed() {
method destroy (line 254) | async destroy(options?: DestroyOptions) {
method isPro (line 265) | async isPro(page: Page) {
method askForStream (line 269) | async askForStream(req: ChatRequest, stream: EventStream) {
FILE: model/perauto/define.ts
type UseLeft (line 4) | type UseLeft = Partial<Record<ModelType, number>>;
type Account (line 6) | interface Account extends ComInfo {
type FocusType (line 21) | enum FocusType {
type PerplexityChatRequest (line 47) | interface PerplexityChatRequest extends ChatRequest {
type PerEvents (line 51) | enum PerEvents {
type PerEventReq (line 58) | interface PerEventReq {
type UserSettings (line 68) | interface UserSettings extends PerEventReq {
type PerAskSearchFocus (line 89) | enum PerAskSearchFocus {
type PerAskMode (line 98) | enum PerAskMode {
type PerAsk (line 102) | interface PerAsk extends PerEventReq {
type PerMessageResponse (line 117) | interface PerMessageResponse {
FILE: model/perauto/index.ts
class PerAuto (line 9) | class PerAuto extends Chat {
method constructor (line 45) | constructor(options?: ChatOptions) {
method support (line 49) | support(model: ModelType): number {
method preHandle (line 70) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 97) | public async askStream(req: PerplexityChatRequest, stream: EventStream) {
FILE: model/perlabs/cfpool.ts
class PagePool (line 8) | class PagePool {
method pop (line 12) | async pop(): Promise<PageChild> {
method release (line 27) | async release(child: PageChild) {
method destroy (line 33) | async destroy(child: PageChild) {
class PageChild (line 43) | class PageChild {
method constructor (line 47) | constructor(public id: string, private url: string) {}
method init (line 48) | async init(): Promise<boolean> {
method release (line 65) | async release() {
method destroy (line 72) | async destroy() {
FILE: model/perlabs/child.ts
class Child (line 16) | class Child extends ComChild<Account> {
method init (line 20) | async init(): Promise<void> {
method initFailed (line 59) | async initFailed(e?: Error) {
method destroy (line 64) | async destroy(options?: DestroyOptions) {
method askForStream (line 72) | async askForStream(
FILE: model/perlabs/define.ts
type Account (line 4) | interface Account extends ComInfo {
type MessageReq (line 8) | interface MessageReq {
type MessageRes (line 16) | interface MessageRes {
type PerLabEvents (line 45) | enum PerLabEvents {
FILE: model/perlabs/index.ts
class PerLabs (line 8) | class PerLabs extends Chat {
method constructor (line 30) | constructor(options?: ChatOptions) {
method support (line 34) | support(model: ModelType): number {
method askStream (line 41) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/perplexity/index.ts
type UseLeft (line 10) | type UseLeft = Partial<Record<ModelType, number>>;
type FocusType (line 12) | enum FocusType {
type Account (line 32) | interface Account extends ComInfo {
class Child (line 43) | class Child extends ComChild<Account> {
method isLogin (line 50) | async isLogin(page: Page) {
method closeCopilot (line 62) | private async closeCopilot(page: Page) {
method setModel (line 74) | async setModel(page: Page, model: ModelType) {
method listenTokenChange (line 95) | async listenTokenChange() {
method goHome (line 124) | public async goHome() {
method changeMode (line 145) | public async changeMode(t: FocusType) {
method startListener (line 171) | async startListener() {
method sendMsg (line 219) | async sendMsg(
method init (line 268) | async init(): Promise<void> {
method initFailed (line 317) | initFailed() {
method destroy (line 325) | destroy(options?: DestroyOptions) {
method isPro (line 335) | async isPro(page: Page) {
type PerplexityChatRequest (line 340) | interface PerplexityChatRequest extends ChatRequest {
class Perplexity (line 344) | class Perplexity extends Chat {
method constructor (line 389) | constructor(options?: ChatOptions) {
method support (line 393) | support(model: ModelType): number {
method preHandle (line 412) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 440) | public async askStream(req: PerplexityChatRequest, stream: EventStream) {
FILE: model/phind/index.ts
type Account (line 24) | interface Account extends ComInfo {
class Child (line 38) | class Child extends ComChild<Account> {
method constructor (line 42) | constructor(label: string, info: any, options?: ChildOptions) {
method ifLogin (line 46) | async ifLogin() {
method updateLeft (line 56) | async updateLeft() {
method updateToken (line 78) | async updateToken() {
method init (line 92) | async init(): Promise<void> {
method updateUserID (line 153) | async updateUserID() {
method destroy (line 175) | destroy(options?: DestroyOptions) {
method initFailed (line 180) | initFailed() {
method use (line 185) | use(): void {
class Phind (line 193) | class Phind extends Chat {
method constructor (line 223) | constructor(options?: ChatOptions) {
method support (line 227) | support(model: ModelType): number {
method preHandle (line 238) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method generateChallenge (line 246) | async generateChallenge(l: string) {
method askStream (line 258) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/pika/child.ts
class Child (line 20) | class Child extends ComChild<Account> {
method init (line 25) | async init() {
method saveToken (line 75) | saveToken() {
method initFailed (line 104) | initFailed() {
method use (line 111) | use() {
method generate (line 118) | async generate(prompt: string) {
method myLibrary (line 152) | async myLibrary(id: string) {
method fetch (line 166) | async fetch<T>(path: string, requestInit: RequestInit): Promise<T> {
FILE: model/pika/define.ts
type Account (line 4) | interface Account extends ComInfo {
type GenRequestOptions (line 13) | interface GenRequestOptions {
type GenFormDataBody (line 25) | interface GenFormDataBody {
type GenerationResponse (line 33) | interface GenerationResponse {
type LibraryVideo (line 72) | interface LibraryVideo {
FILE: model/pika/index.ts
class Pika (line 17) | class Pika extends Chat {
method constructor (line 18) | constructor(options?: ChatOptions) {
method support (line 58) | support(model: ModelType): number {
method askStream (line 67) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
method textToVideo (line 74) | async textToVideo(req: ChatRequest, stream: EventStream) {
method createVideoTask (line 131) | async createVideoTask(
method queryVideoTask (line 140) | async queryVideoTask(
FILE: model/poe/define.ts
function getModelConfig (line 199) | function getModelConfig(model: ModelType) {
function getModelPoints (line 209) | function getModelPoints(model: ModelType) {
function getModelName (line 213) | function getModelName(model: ModelType) {
function getModelContextTokens (line 217) | function getModelContextTokens(model: ModelType) {
function extractModelName (line 221) | function extractModelName(input: string): string {
function isMsg (line 225) | function isMsg(msg: string): boolean {
class Poe (line 234) | class Poe {
method setPage (line 237) | setPage(page: Page) {
method setLogger (line 240) | setLogger(logger: winston.Logger) {
method getCurrentModelName (line 244) | async getCurrentModelName() {
method closeSub (line 254) | async closeSub() {
method gotoModel (line 266) | async gotoModel(page: Page, model: ModelType) {
method clearContext (line 280) | async clearContext() {
method extractRemaining (line 285) | extractRemaining(text: string): { daily: number; monthly: number } {
method isLogin (line 302) | async isLogin() {
function extractPoeImageUrl (line 317) | function extractPoeImageUrl(input: string): string | null {
FILE: model/pweb/index.ts
type RealReq (line 21) | interface RealReq {
class PWeb (line 31) | class PWeb extends Chat {
method constructor (line 34) | constructor(options?: ChatOptions) {
method support (line 50) | support(model: ModelType): number {
method askStream (line 61) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/ram/index.ts
type Account (line 32) | type Account = {
type RealReq (line 42) | interface RealReq {
type Meta (line 51) | interface Meta {
type Content (line 56) | interface Content {
type ConversationItem (line 63) | interface ConversationItem {
type Part (line 68) | interface Part {
class RamAccountPool (line 73) | class RamAccountPool {
method constructor (line 78) | constructor() {
method syncfile (line 88) | public syncfile() {
method getByID (line 92) | public getByID(id: string) {
method delete (line 100) | public delete(id: string) {
method get (line 105) | public get(): Account {
method multiGet (line 134) | public multiGet(size: number): Account[] {
class Ram (line 143) | class Ram extends Chat implements BrowserUser<Account> {
method constructor (line 149) | constructor(options?: ChatOptions) {
method support (line 170) | support(model: ModelType): number {
method deleteID (line 179) | deleteID(id: string): void {
method newID (line 183) | newID(): string {
method init (line 188) | async init(
method askStream (line 216) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/runway/child.ts
class Child (line 37) | class Child extends ComChild<Account> {
method constructor (line 43) | constructor(label: string, info: any, options?: ChildOptions) {
method client (line 48) | get client() {
method init (line 125) | async init() {
method cookie (line 184) | get cookie() {
method saveCookies (line 188) | async saveCookies() {
method saveUA (line 194) | async saveUA() {
method checkLogin (line 199) | async checkLogin() {
method saveToken (line 206) | async saveToken() {
method saveTeamID (line 217) | async saveTeamID() {
method initFailed (line 228) | initFailed() {
method use (line 245) | use() {
method destroy (line 252) | async destroy(options?: DestroyOptions) {
method genTask (line 266) | async genTask(req: GenVideoTaskReq) {
method getTask (line 273) | async getTask(id: string) {
method uploads (line 299) | async uploads(filename: string) {
method upload (line 309) | async upload(filepath: string, contentType: string, url: string) {
method complete (line 321) | async complete(id: string, ETag: string) {
method autoUpload (line 336) | async autoUpload(url: string) {
FILE: model/runway/define.ts
type Account (line 7) | interface Account extends ComInfo {
type GenVideoAction (line 22) | interface GenVideoAction {
type TaskDetail (line 30) | interface TaskDetail {
type VideoDetails (line 40) | interface VideoDetails {
type Subscription (line 47) | interface Subscription {
type Plan (line 53) | interface Plan {
type UsageRes (line 61) | interface UsageRes {
type RunwayTaskType (line 87) | enum RunwayTaskType {
type RunwayTaskStatus (line 92) | enum RunwayTaskStatus {
type GenVideoOptions (line 99) | interface GenVideoOptions {
type GenVideoTaskReq (line 113) | interface GenVideoTaskReq {
type GenVideoTaskRes (line 120) | interface GenVideoTaskRes {
type ArtifactMetadata (line 124) | interface ArtifactMetadata {
type Artifact (line 134) | interface Artifact {
type VideoTask (line 155) | interface VideoTask {
type GetVideoTaskRes (line 172) | interface GetVideoTaskRes {
type UploadsReq (line 176) | interface UploadsReq {
type UploadsRes (line 182) | interface UploadsRes {
FILE: model/runway/index.ts
class Runway (line 37) | class Runway extends Chat {
method constructor (line 38) | constructor(options?: ChatOptions) {
method support (line 107) | support(model: ModelType): number {
method askStream (line 114) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
method dynamicRouter (line 251) | dynamicRouter(router: Router): boolean {
FILE: model/sincode/index.ts
type Account (line 23) | interface Account extends ComInfo {
type Events (line 28) | type Events = {
class Child (line 34) | class Child extends ComChild<Account> {
method changeMode (line 40) | public async changeMode(model: ModelType, page: Page) {
method isMsg (line 62) | isMsg(msg: string): boolean {
method startListener (line 71) | async startListener() {
method newChat (line 98) | async newChat(page: Page) {
method sendMsg (line 116) | async sendMsg(model: ModelType, prompt: string, events?: Events) {
method init (line 154) | async init(): Promise<void> {
method clearChat (line 178) | async clearChat(page: Page) {
method initFailed (line 208) | initFailed() {
method destroy (line 213) | destroy(options?: DestroyOptions) {
class SinCode (line 219) | class SinCode extends Chat {
method constructor (line 265) | constructor(options?: ChatOptions) {
method support (line 269) | support(model: ModelType): number {
method preHandle (line 280) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 292) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/skailar/index.ts
type AssistantMessage (line 13) | interface AssistantMessage {
type Model (line 18) | interface Model {
type RealReq (line 25) | interface RealReq {
class Skailar (line 33) | class Skailar extends Chat {
method constructor (line 36) | constructor(options?: ChatOptions) {
method support (line 48) | support(model: ModelType): number {
method askStream (line 57) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/stack/index.ts
type Account (line 27) | interface Account extends ComInfo {
class Child (line 36) | class Child extends ComChild<Account> {
method constructor (line 39) | constructor(label: string, info: any, options?: ChildOptions) {
method init (line 48) | async init(): Promise<void> {
method closeWelcome (line 123) | async closeWelcome(page: Page) {
method getToken (line 134) | async getToken(page: Page) {
method destroy (line 151) | destroy(options?: DestroyOptions) {
method initFailed (line 156) | initFailed() {
method use (line 161) | use(): void {
class Stack (line 169) | class Stack extends Chat {
method constructor (line 216) | constructor(options?: ChatOptions) {
method support (line 220) | support(model: ModelType): number {
method preHandle (line 233) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 240) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/suno/child.ts
class Child (line 28) | class Child extends ComChild<Account> {
method init (line 34) | async init() {
method updateSID (line 71) | async updateSID() {
method updateToken (line 91) | async updateToken() {
method updateCredit (line 138) | async updateCredit() {
method querySession (line 148) | async querySession() {
method createSong (line 157) | async createSong(options: SongOptions) {
method feedSong (line 181) | async feedSong(ids: string[]) {
method lyrics (line 188) | async lyrics(prompt: string) {
method lyricsTask (line 204) | async lyricsTask(id: string) {
method wholeSong (line 209) | async wholeSong(id: string) {
method getUploadTarget (line 217) | async getUploadTarget(
method uploadFinish (line 226) | async uploadFinish(id: string, file_name: string) {
method getUploadFileInfo (line 233) | async getUploadFileInfo(id: string): Promise<GetUploadFileRes> {
method initClip (line 240) | async initClip(id: string): Promise<string> {
method setMetadata (line 248) | async setMetadata(clip_id: string, image_url: string, title: string) {
method uploadFile (line 261) | async uploadFile(file_url: string) {
method queryBill (line 310) | async queryBill() {
method initFailed (line 315) | initFailed(e: any) {
method use (line 325) | use() {
method destroy (line 332) | destroy(options?: DestroyOptions) {
FILE: model/suno/define.ts
type Account (line 8) | interface Account extends ComInfo {
type BillInfo (line 19) | interface BillInfo {
type PlanDetail (line 36) | interface PlanDetail {
type CreditPack (line 40) | interface CreditPack {
type Plan (line 46) | interface Plan {
type User (line 54) | interface User {
type Model (line 64) | interface Model {
type Roles (line 71) | interface Roles {
type Flags (line 76) | interface Flags {
type SessionInfo (line 83) | interface SessionInfo {
type SongOptions (line 189) | interface SongOptions {
type CreateSongRes (line 202) | interface CreateSongRes {
type Clip (line 212) | interface Clip {
type Metadata (line 233) | interface Metadata {
type GoAmzGenReq (line 248) | interface GoAmzGenReq {
type GoAmzGenInput (line 254) | interface GoAmzGenInput {
type LyricTaskRes (line 266) | interface LyricTaskRes {
type GetUploadTargetRes (line 278) | interface GetUploadTargetRes {
type GetUploadFileRes (line 284) | interface GetUploadFileRes {
FILE: model/suno/index.ts
class Suno (line 31) | class Suno extends Chat {
method constructor (line 32) | constructor(options?: ChatOptions) {
method support (line 76) | support(model: ModelType): number {
method extractContent (line 89) | extractContent(key: string, str: string) {
method askStream (line 100) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
method createSong (line 290) | async createSong(ctx: Application.Context, req: SongOptions) {
method feedSong (line 296) | async feedSong(
method dynamicRouter (line 304) | dynamicRouter(router: Router) {
FILE: model/takeoff/index.ts
type Account (line 37) | interface Account extends ComInfo {
class Child (line 45) | class Child extends ComChild<Account> {
method constructor (line 49) | constructor(label: string, info: any, options?: ChildOptions) {
method init (line 59) | async init(): Promise<void> {
method getCookie (line 122) | async getCookie(page: Page) {
method initFailed (line 128) | initFailed() {
method destroy (line 133) | destroy(options?: DestroyOptions) {
method use (line 138) | use(): void {
class TakeOff (line 146) | class TakeOff extends Chat {
method constructor (line 165) | constructor(options?: ChatOptions) {
method support (line 169) | support(model: ModelType): number {
method preHandle (line 182) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 190) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/td/index.ts
type Account (line 26) | interface Account extends ComInfo {
class Child (line 34) | class Child extends ComChild<Account> {
method constructor (line 38) | constructor(label: string, info: any, options?: ChildOptions) {
method init (line 48) | async init(): Promise<void> {
method updateAuth (line 110) | async updateAuth() {
method saveRefreshToken (line 128) | async saveRefreshToken(page: Page) {
method initFailed (line 138) | initFailed() {
method destroy (line 143) | destroy(options?: DestroyOptions) {
class TD (line 149) | class TD extends Chat {
method constructor (line 165) | constructor(options?: ChatOptions) {
method support (line 169) | support(model: ModelType): number {
method preHandle (line 182) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 190) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
FILE: model/toyy/index.ts
class Toyy (line 7) | class Toyy extends Chat {
method constructor (line 10) | constructor(options?: ChatOptions) {
method support (line 25) | support(model: ModelType): number {
method askStream (line 38) | public async askStream(req: ChatRequest, stream: EventStream) {
method uR (line 66) | uR(e:string) {
FILE: model/vanus/index.ts
type Account (line 27) | interface Account extends ComInfo {
type ReplyMessage (line 37) | interface ReplyMessage {
type TextStreamData (line 55) | interface TextStreamData {
type TextStream (line 62) | interface TextStream {
class Child (line 68) | class Child extends ComChild<Account> {
method createGPT4 (line 69) | async createGPT4(page: Page) {
method getToken (line 81) | async getToken(page: Page) {
method getLeft (line 90) | async getLeft(page: Page) {
method getInfo (line 106) | async getInfo(page: Page) {
method init (line 120) | async init(): Promise<void> {
method use (line 194) | public use(): void {
class Vanus (line 202) | class Vanus extends Chat {
method constructor (line 221) | constructor(options?: ChatOptions) {
method support (line 234) | support(model: ModelType): number {
method preHandle (line 249) | async preHandle(req: ChatRequest): Promise<ChatRequest> {
method askStream (line 257) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/vidu/child.ts
class Child (line 23) | class Child extends ComChild<Account> {
method init (line 29) | async init() {
method cookie (line 152) | get cookie() {
method tasks (line 156) | async tasks(req: TaskReq) {
method taskState (line 161) | async taskState(id: string) {
method listenTaskState (line 168) | async listenTaskState(
method credits (line 192) | async credits() {
method saveCookies (line 197) | async saveCookies() {
method saveUA (line 207) | async saveUA() {
method checkLogin (line 212) | async checkLogin() {
method initFailed (line 220) | initFailed() {
method use (line 228) | use() {
method destroy (line 235) | destroy(options?: DestroyOptions) {
method GetClient (line 246) | static GetClient(pool: Pool<Account, Child>, id: string) {
method TaskState (line 269) | static async TaskState(
method History (line 281) | static async History(pool: Pool<Account, Child>, server_id: string) {
method HistoryOne (line 289) | static async HistoryOne(
method checkCredits (line 302) | async checkCredits() {
FILE: model/vidu/define.ts
type Account (line 5) | interface Account extends ComInfo {
type ErrorRes (line 19) | type ErrorRes = { detail: string };
type ETaskState (line 27) | enum ETaskState {
type ETaskType (line 33) | enum ETaskType {
type EViduModel (line 40) | enum EViduModel {
type EViduStyle (line 45) | enum EViduStyle {
type TextPrompt (line 50) | interface TextPrompt {
type Input (line 58) | interface Input {
type Settings (line 64) | interface Settings {
type TaskReq (line 71) | interface TaskReq {
type VideoResolution (line 77) | interface VideoResolution {
type VideoDetails (line 82) | interface VideoDetails {
type Creation (line 88) | interface Creation {
type Task (line 106) | interface Task {
type TaskRes (line 117) | interface TaskRes extends Task {}
type TaskStateProcess (line 119) | interface TaskStateProcess {
type CreditsRes (line 125) | interface CreditsRes {
type Action (line 132) | interface Action {
FILE: model/vidu/index.ts
class Vidu (line 35) | class Vidu extends Chat {
method constructor (line 36) | constructor(options?: ChatOptions) {
method support (line 106) | support(model: ModelType): number {
method askStream (line 115) | async askStream(req: ChatRequest, stream: EventStream): Promise<void> {
method dynamicRouter (line 248) | dynamicRouter(router: Router): boolean {
FILE: model/vita/index.ts
type RealReq (line 19) | interface RealReq {
class Vita (line 24) | class Vita extends Chat {
method constructor (line 27) | constructor(options?: ChatOptions) {
method support (line 40) | support(model: ModelType): number {
method askStream (line 49) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/vvm/index.ts
type Model (line 14) | interface Model {
type RealReq (line 34) | interface RealReq {
class VVM (line 42) | class VVM extends Chat {
method constructor (line 45) | constructor(options?: ChatOptions) {
method support (line 57) | support(model: ModelType): number {
method ask (line 70) | public async ask(req: ChatRequest): Promise<ChatResponse> {
method askStream (line 97) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: model/www/index.ts
type WWWChatRequest (line 23) | interface WWWChatRequest extends ChatRequest {
type Account (line 27) | interface Account extends ComInfo {}
class Child (line 29) | class Child extends ComChild<Account> {
method constructor (line 32) | constructor(label: string, info: any, options?: ChildOptions) {
method init (line 36) | async init(): Promise<void> {
method getURLInfo (line 44) | async getURLInfo(url: string): Promise<string> {
method initFailed (line 54) | initFailed() {
method destroy (line 59) | destroy(options?: DestroyOptions) {
method release (line 64) | async release() {
class WWW (line 70) | class WWW extends Chat {
method constructor (line 83) | constructor(options?: ChatOptions) {
method support (line 87) | support(model: ModelType): number {
method askStream (line 96) | async askStream(req: WWWChatRequest, stream: EventStream): Promise<voi...
FILE: model/xun/index.ts
type RealReq (line 20) | interface RealReq {
class Xun (line 30) | class Xun extends Chat {
method constructor (line 33) | constructor(options?: ChatOptions) {
method support (line 45) | support(model: ModelType): number {
method askStream (line 56) | public async askStream(req: ChatRequest, stream: EventStream) {
FILE: router.ts
type AskReq (line 94) | interface AskReq extends ChatRequest {
type AskRes (line 98) | interface AskRes extends ChatResponse {}
function checkApiKey (line 100) | async function checkApiKey(ctx: Context, next: Next) {
type OpenAIReq (line 315) | interface OpenAIReq {
type ClaudeReq (line 322) | interface ClaudeReq {
type Support (line 329) | interface Support {
function logRouters (line 598) | function logRouters(router: Router) {
FILE: utils/cache.ts
function initCache (line 9) | function initCache() {
class StringPool (line 27) | class StringPool {
method constructor (line 32) | constructor(redis: Redis, key: string) {
method add (line 38) | async add(value: string): Promise<number> {
method remove (line 43) | async remove(value: string): Promise<void> {
method random (line 48) | async random(): Promise<string | null> {
method size (line 53) | async size(): Promise<number> {
method clear (line 58) | async clear(): Promise<void> {
method pop (line 64) | async pop(): Promise<string | null> {
class MemoryStringPool (line 70) | class MemoryStringPool {
method add (line 73) | async add(value: string): Promise<number> {
method remove (line 78) | async remove(value: string): Promise<void> {
method random (line 82) | async random(): Promise<string | null> {
method size (line 90) | async size(): Promise<number> {
method clear (line 94) | async clear(): Promise<void> {
method pop (line 98) | async pop(): Promise<string | null> {
class CommCache (line 113) | class CommCache<T> {
method constructor (line 120) | constructor(
method key (line 133) | key(subkey: string) {
method get (line 137) | async get(subkey: string, init?: () => Promise<T | null>): Promise<T |...
method set (line 154) | async set(subkey: string, value: string): Promise<void> {
method clear (line 159) | async clear(subkey: string): Promise<void> {
class StringCache (line 165) | class StringCache<T> {
method constructor (line 171) | constructor(redis: Redis, key: string, expire: number) {
method key (line 178) | key(subkey: string) {
method get (line 182) | async get(subkey: string): Promise<T | null> {
method set (line 191) | async set(subkey: string, value: T): Promise<void> {
method clear (line 201) | async clear(subkey: string): Promise<void> {
FILE: utils/captcha.ts
class CaptchaSolver (line 11) | class CaptchaSolver {
method constructor (line 15) | constructor(apiKey: string) {
method sendCaptcha (line 20) | async sendCaptcha(base64Image: string): Promise<string> {
method getCaptchaResult (line 43) | async getCaptchaResult(captchaId: string): Promise<string> {
function getCaptchaCode (line 75) | async function getCaptchaCode(base64: string) {
function ifCF (line 90) | async function ifCF(page: Page) {
function handleCF (line 102) | async function handleCF(
function fuckCF (line 197) | async function fuckCF(target: Page) {
FILE: utils/config.ts
type SiteCfg (line 5) | type SiteCfg = {
type SizeCfg (line 16) | type SizeCfg = {
type MailCfg (line 21) | type MailCfg = {
type DiscordAccount (line 25) | type DiscordAccount = {
type GoogleMailAccount (line 31) | type GoogleMailAccount = {
type PoeModelConfig (line 39) | type PoeModelConfig = {
type ConfigData (line 47) | interface ConfigData {
class BaseConfig (line 405) | class BaseConfig {
method constructor (line 621) | constructor() {
method load (line 626) | load() {
method watchFile (line 646) | watchFile() {
FILE: utils/emailFactory.ts
type TempEmailType (line 9) | enum TempEmailType {
function CreateEmail (line 33) | function CreateEmail(
type BaseMailMessage (line 97) | interface BaseMailMessage {
type TempMailMessage (line 102) | interface TempMailMessage extends BaseMailMessage {
type BaseOptions (line 124) | interface BaseOptions {}
method constructor (line 127) | public constructor(options?: BaseOptions) {}
type TempMailOptions (line 134) | interface TempMailOptions extends BaseOptions {
class Inbox (line 138) | class Inbox extends BaseEmail {
method constructor (line 142) | constructor(options?: TempMailOptions) {
method getMailAddress (line 160) | public async getMailAddress(): Promise<string> {
method waitMails (line 167) | public async waitMails(): Promise<TempMailMessage[]> {
method getDomainsList (line 192) | async getDomainsList(): Promise<string[]> {
method randomDomain (line 197) | async randomDomain(): Promise<string> {
class TempMail (line 203) | class TempMail extends BaseEmail {
method constructor (line 208) | constructor(options?: TempMailOptions) {
method getMailAddress (line 223) | public async getMailAddress(): Promise<string> {
method waitMails (line 229) | public async waitMails(): Promise<TempMailMessage[]> {
method getDomainsList (line 255) | async getDomainsList(): Promise<string[]> {
method randomDomain (line 260) | async randomDomain(): Promise<string> {
class TempMail44 (line 266) | class TempMail44 extends BaseEmail {
method constructor (line 270) | constructor(options?: TempMailOptions) {
method getMailAddress (line 288) | public async getMailAddress(): Promise<string> {
method waitMails (line 298) | public async waitMails(): Promise<TempMailMessage[]> {
class TempMailLOL (line 328) | class TempMailLOL extends BaseEmail {
method constructor (line 333) | constructor(options?: TempMailOptions) {
method getMailAddress (line 340) | public async getMailAddress(): Promise<string> {
method waitMails (line 347) | public async waitMails(): Promise<TempMailMessage[]> {
class Internal (line 374) | class Internal extends BaseEmail {
method constructor (line 378) | constructor(options?: BaseOptions) {
method getMailAddress (line 386) | public async getMailAddress(): Promise<string> {
method waitMails (line 407) | public async waitMails(): Promise<BaseMailMessage[]> {
class SmailPro (line 439) | class SmailPro extends BaseEmail {
method constructor (line 443) | constructor(options: SmailProOptions) {
method getMailAddress (line 448) | async getMailAddress() {
method waitMails (line 502) | async waitMails(): Promise<BaseMailMessage[]> {
type GmailOptions (line 557) | interface GmailOptions extends BaseOptions {
type SmailProOptions (line 561) | interface SmailProOptions extends GmailOptions {
class Gmail (line 566) | class Gmail extends BaseEmail {
method constructor (line 572) | constructor(options: GmailOptions) {
method getMailAddress (line 591) | public async getMailAddress(): Promise<string> {
method check (line 606) | public async check(): Promise<[boolean, string]> {
method waitMails (line 622) | public async waitMails(): Promise<TempMailMessage[]> {
class EmailNator (line 657) | class EmailNator extends BaseEmail {
method constructor (line 662) | constructor(options?: BaseOptions) {
method getMailAddress (line 666) | async getMailAddress(): Promise<string> {
method getMails (line 710) | private async getMails() {
method getMailDetail (line 734) | async getMailDetail(mail: string, messageID: string) {
method waitMails (line 748) | async waitMails(): Promise<BaseMailMessage[]> {
class MailTM (line 783) | class MailTM extends BaseEmail {
method constructor (line 788) | constructor() {
method getMailAddress (line 793) | async getMailAddress(): Promise<string> {
method waitMails (line 801) | async waitMails(): Promise<BaseMailMessage[]> {
class YopMail (line 816) | class YopMail extends BaseEmail {
method getMailAddress (line 822) | async getMailAddress(): Promise<string> {
method waitMails (line 830) | async waitMails(): Promise<BaseMailMessage[]> {
method getMailSuffix (line 855) | async getMailSuffix(): Promise<string[]> {
method getMail (line 864) | async getMail() {
method getInbox (line 871) | async getInbox(
method getCookiesAndYP (line 882) | async getCookiesAndYP() {
method getYJ (line 896) | async getYJ(cookie: string) {
method shouldIncludeEmail (line 905) | shouldIncludeEmail(email: any, filteredSearch: string) {
method getDetailInboxFromPage (line 922) | getDetailInboxFromPage(html: string, filteredSearch: any) {
method fetchInboxPage (line 931) | async fetchInboxPage(
method getTotalMails (line 965) | async getTotalMails(html: string) {
method validateSearch (line 976) | async validateSearch(search: any) {
method parseEmail (line 991) | parseEmail(element: any) {
method detailInbox (line 1000) | async detailInbox(
method readMessage (line 1058) | async readMessage(
FILE: utils/file.ts
class SyncFileDebouncer (line 17) | class SyncFileDebouncer {
method constructor (line 22) | private constructor(debounceTime: number = 300) {
method getInstance (line 26) | public static getInstance(debounceTime?: number): SyncFileDebouncer {
method writeFileSync (line 33) | public writeFileSync(
function getImageExtension (line 52) | function getImageExtension(contentType: string): string {
function IsImageMineType (line 72) | function IsImageMineType(mimeType: string): boolean {
function extractVideoLastFrame (line 91) | async function extractVideoLastFrame(videoUrl: string): Promise<string> {
function getVideoInfo (line 138) | async function getVideoInfo(videoPath: string): Promise<{
function convertVideoFormat (line 169) | async function convertVideoFormat(
function mergeVideosExcludeLastFrame (line 215) | async function mergeVideosExcludeLastFrame(
function removeWatermarkFromVideo (line 258) | async function removeWatermarkFromVideo(
function getAudioDuration (line 314) | async function getAudioDuration(filePath: string): Promise<number> {
FILE: utils/index.ts
type eventFunc (line 31) | type eventFunc = (eventName: string, data: string) => void;
function toEventCB (line 35) | function toEventCB(arr: Uint8Array, emit: eventFunc) {
function toEventStream (line 51) | function toEventStream(arr: Uint8Array): Stream {
function md5 (line 57) | function md5(str: string): string {
function randomStr (line 64) | function randomStr(length: number = 6): string {
function randomNonce (line 75) | function randomNonce(length: number = 6): string {
function parseJSON (line 83) | function parseJSON<T>(str: string, defaultObj: T): T {
function encryptWithAes256Cbc (line 91) | function encryptWithAes256Cbc(data: string, key: string): string {
function sleep (line 102) | async function sleep(duration: number): Promise<void> {
function shuffleArray (line 108) | function shuffleArray<T>(array: T[]): T[] {
function shuffleEachArray (line 117) | async function shuffleEachArray<T>(
type ErrorData (line 129) | type ErrorData = { error: string; message?: string; status?: number };
type MessageData (line 130) | type MessageData = {
type SearchData (line 135) | type SearchData = { search: any };
type DoneData (line 136) | type DoneData = MessageData;
type Event (line 138) | enum Event {
type Data (line 145) | type Data<T extends Event> = T extends Event.error
type DataCB (line 155) | type DataCB<T extends Event> = (event: T, data: Data<T>) => void;
class EventStream (line 157) | class EventStream {
method setModel (line 161) | setModel(model: ModelType) {
method constructor (line 165) | constructor() {
method write (line 169) | public write<T extends Event>(event: T, data: Data<T>) {
method stream (line 177) | stream() {
method end (line 181) | end(cb?: () => void) {
method read (line 185) | public read(dataCB: DataCB<Event>, closeCB: () => void) {
class ThroughEventStream (line 212) | class ThroughEventStream extends EventStream {
method constructor (line 216) | constructor(
method destroy (line 225) | destroy() {
method write (line 230) | public write<T extends Event>(event: T, data: Data<T>) {
method end (line 234) | public end() {
class OpenaiEventStream (line 239) | class OpenaiEventStream extends EventStream {
method write (line 244) | write<T extends Event>(event: T, data: Data<T>) {
method read (line 314) | read(dataCB: DataCB<Event>, closeCB: () => void) {
class ClaudeEventStream (line 344) | class ClaudeEventStream extends EventStream {
method write (line 347) | write<T extends Event>(event: T, data: Data<T>) {
method read (line 381) | read(dataCB: DataCB<Event>, closeCB: () => void) {
function extractStrNumber (line 422) | function extractStrNumber(input: string): number {
function maskLinks (line 435) | function maskLinks(input: string): string {
class Lock (line 448) | class Lock {
method lock (line 453) | async lock(timeout = 5 * 60 * 1000) {
method unlock (line 479) | unlock() {
function encodeBase64 (line 492) | function encodeBase64(
function hashString (line 510) | function hashString(str: string): number {
function colorLabel (line 519) | function colorLabel(label: string) {
function getRandomOne (line 544) | function getRandomOne<T>(arr: T[]) {
function tokenEncode (line 550) | function tokenEncode(input: string) {
function getTokenCount (line 554) | function getTokenCount(input: string) {
class ComError (line 558) | class ComError extends Error {
method constructor (line 575) | constructor(
function removeRandomChars (line 590) | function removeRandomChars(str: string, percentage: number): string {
function TWToCN (line 597) | function TWToCN(str: string) {
function matchPattern (line 601) | function matchPattern(pattern: string, str: string): boolean {
function extractHttpURLs (line 621) | function extractHttpURLs(text: string): string[] {
function extractHttpFileURLs (line 627) | function extractHttpFileURLs(text: string): string[] {
function extractHttpImageFileURLs (line 634) | function extractHttpImageFileURLs(text: string): string[] {
function extractHttpVideoFileURLs (line 641) | function extractHttpVideoFileURLs(text: string): string[] {
function isImageURL (line 648) | function isImageURL(url: string): boolean {
function grepStr (line 668) | function grepStr(v: string, filter: string | RegExp): string[] {
function replaceStrInBuffer (line 683) | function replaceStrInBuffer(
function retryFunc (line 722) | async function retryFunc<T>(
function extractJSON (line 763) | function extractJSON<T>(str: string): T | null {
function getFilenameFromContentDisposition (line 789) | function getFilenameFromContentDisposition(content: string = '') {
function downloadFile (line 909) | async function downloadFile(fileUrl: string): Promise<{
function uploadFile (line 1027) | async function uploadFile(filePath: string): Promise<string> {
function getHostPortFromURL (line 1054) | function getHostPortFromURL(url: string): [string, number] {
function downloadAndUploadCDN (line 1059) | async function downloadAndUploadCDN(url: string): Promise<string> {
function extractFileToText (line 1109) | async function extractFileToText(fileURL: string) {
function parseFileToText (line 1114) | async function parseFileToText(filePath: string) {
function checkSensitiveWords (line 1142) | function checkSensitiveWords(text: string) {
function filterSensitiveWords (line 1150) | function filterSensitiveWords(text: string) {
function decodeJwt (line 1159) | function decodeJwt(token: string): { header: any; payload: any } {
function genPowToken (line 1188) | function genPowToken(
function preOrderUserAssistant (line 1225) | function preOrderUserAssistant(messages: Message[]) {
function parseCookie (line 1246) | function parseCookie(str: string): {
FILE: utils/log.ts
function replaceConsoleWithWinston (line 85) | function replaceConsoleWithWinston(): void {
function newLogger (line 98) | function newLogger(site?: string, extra?: Record<string, string>) {
class TraceLogger (line 104) | class TraceLogger {
method constructor (line 109) | constructor() {
method info (line 114) | info(msg: string, meta: any) {
type UDPTransportOptions (line 124) | interface UDPTransportOptions extends Transport.TransportStreamOptions {
class UDPTransport (line 129) | class UDPTransport extends Transport {
method constructor (line 133) | constructor(options: UDPTransportOptions) {
method log (line 144) | log(
method close (line 154) | close(): void {
method sendLog (line 158) | private sendLog(
function SaveMessagesToLogstash (line 187) | async function SaveMessagesToLogstash(
FILE: utils/pool.ts
type Info (line 13) | interface Info {
type PoolChild (line 18) | interface PoolChild<T extends Info> {
type ComInfo (line 37) | interface ComInfo extends Info {
type DestroyOptions (line 42) | interface DestroyOptions {
type ChildOptions (line 47) | interface ChildOptions {
class ComChild (line 55) | class ComChild<T extends ComInfo> implements PoolChild<T> {
method constructor (line 60) | constructor(label: string, info: T, options?: ChildOptions) {
method info (line 66) | get info() {
method update (line 70) | public update(v: Partial<T>) {
method init (line 75) | init(): Promise<void> {
method use (line 79) | public use(): void {
method destroy (line 88) | public destroy(options?: DestroyOptions): void {
method release (line 92) | public release(): void {
method initFailed (line 96) | public initFailed(e?: Error): void {
type PoolOptions (line 101) | interface PoolOptions<T extends Info> {
class Pool (line 115) | class Pool<U extends Info, T extends PoolChild<U>> {
method constructor (line 124) | constructor(
method read (line 137) | private read() {}
method save (line 139) | private save() {
method del (line 143) | private del(id: string, delFile: boolean, delMem: boolean) {
method stringify (line 154) | private stringify() {
method getOneOldInfo (line 158) | private getOneOldInfo() {
method create (line 170) | async create() {
method init (line 228) | async init() {
method pop (line 301) | async pop(): Promise<T> {
method popIf (line 320) | async popIf(condition: (v: U) => boolean) {
method getValidInfos (line 342) | getValidInfos() {
method getAllInfos (line 346) | getAllInfos() {
method findOne (line 350) | findOne(func: (v: U) => boolean) {
method updateOneInfo (line 354) | updateOneInfo(id: string, v: Partial<U>) {
method showInfosWithMarkdown (line 362) | showInfosWithMarkdown(title?: string) {
class PuppeteerUserDirPool (line 370) | class PuppeteerUserDirPool {
method constructor (line 375) | constructor() {
method readOldSite (line 379) | private readOldSite() {
method popUserDir (line 392) | popUserDir(site: string) {
method releaseUserDir (line 419) | releaseUserDir(userDir: string) {
FILE: utils/proxyAgent.ts
function CreateNewAxios (line 71) | function CreateNewAxios(
function CreateAxiosProxy (line 116) | function CreateAxiosProxy(
type CreateNewPageReturn (line 170) | type CreateNewPageReturn<T> = T extends true
function CreateNewPage (line 174) | async function CreateNewPage<
function CreateNewCachePage (line 353) | async function CreateNewCachePage<
function CreateNewPageWS (line 495) | async function CreateNewPageWS(
function CreateNewBrowser (line 542) | async function CreateNewBrowser() {
function launchChromeAndFetchWsUrl (line 563) | function launchChromeAndFetchWsUrl(): Promise<string | null> {
class WSS (line 613) | class WSS {
method constructor (line 617) | constructor(
method send (line 664) | send(data: string) {
method close (line 668) | close() {
method onData (line 672) | onData(cb: (data: string) => void) {
class WebFetchWithPage (line 689) | class WebFetchWithPage {
method constructor (line 693) | constructor(private page: Page) {
method isUsing (line 697) | public isUsing() {
method useEnd (line 701) | public useEnd() {
method getPage (line 705) | getPage() {
method close (line 709) | async close() {
method init (line 724) | async init() {
method fetch (line 755) | async fetch(url: string, init?: RequestInit) {
class WebFetchProxy (line 842) | class WebFetchProxy {
method constructor (line 849) | constructor(
method isUsing (line 858) | public isUsing() {
method useEnd (line 862) | public useEnd() {
method getPage (line 866) | getPage() {
method close (line 870) | async close() {
method init (line 885) | async init() {
method fetch (line 934) | async fetch(url: string, init?: RequestInit) {
function getDownloadClient (line 994) | function getDownloadClient(local: boolean) {
function downloadImageToBase64 (line 1011) | async function downloadImageToBase64(fileUrl: string): Promise<{
function CreateSocketIO (line 1061) | function CreateSocketIO(
FILE: utils/puppeteer.ts
type PageInfo (line 29) | interface PageInfo<T> {
type PrepareOptions (line 37) | type PrepareOptions = {
type PrepareFunc (line 41) | type PrepareFunc<T> = (
type BrowserUser (line 47) | interface BrowserUser<T> {
class BrowserPool (line 54) | class BrowserPool<T> {
method constructor (line 62) | constructor(
method init (line 77) | async init() {
method find (line 96) | find(id: string): PageInfo<T> | undefined {
method initOne (line 104) | async initOne(id: string): Promise<void> {
method deleteIDFile (line 187) | deleteIDFile(id: string) {
method get (line 194) | get(): [
function closeOtherPages (line 247) | async function closeOtherPages(browser: Browser, page: Page) {
type InterceptHandler (line 257) | type InterceptHandler = (req: HTTPRequest) => boolean;
function setPageInterception (line 259) | async function setPageInterception(
function simplifyPage (line 300) | async function simplifyPage(page: Page) {
function blockGoogleAnalysis (line 321) | async function blockGoogleAnalysis(page: Page) {
function simplifyPageAll (line 332) | async function simplifyPageAll(page: Page) {
function loginGoogle (line 353) | async function loginGoogle(
function loginGoogleNew (line 386) | async function loginGoogleNew(page: Page, opt: GoogleMailAccount) {
function googleScreenHandle (line 407) | async function googleScreenHandle(page: Page, opt: GoogleMailAccount) {
function GetSMSFromAPI (line 411) | async function GetSMSFromAPI(url: string) {
function checkGmailContinue (line 425) | async function checkGmailContinue(page: Page) {
function checkGmailIKnown (line 442) | async function checkGmailIKnown(page: Page) {
function checkRecoveryMail (line 456) | async function checkRecoveryMail(page: Page, email: string) {
function getRandomDevice (line 475) | function getRandomDevice() {
type CreateAxiosDefaults (line 479) | interface CreateAxiosDefaults {
type RequestConfig (line 485) | interface RequestConfig extends CreateAxiosDefaults {
type ResponseData (line 491) | interface ResponseData<T = any> {
class PuppeteerAxios (line 498) | class PuppeteerAxios {
method constructor (line 503) | constructor(page: Page, config: CreateAxiosDefaults = {}) {
method ensurePageInitialized (line 511) | private async ensurePageInitialized(): Promise<void> {}
method request (line 513) | async request<T = any>(config: RequestConfig): Promise<ResponseData<T>> {
method get (line 586) | async get<T = any>(
method post (line 593) | async post<T = any>(
method put (line 601) | async put<T = any>(
method delete (line 609) | async delete<T = any>(
FILE: utils/web.ts
function markdownToHTML (line 1) | function markdownToHTML(title: string, markdown: string) {
function jsonArrayToMarkdownTable (line 145) | function jsonArrayToMarkdownTable(jsonArray: any[]): string {
Condensed preview — 175 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,701K chars).
[
{
"path": ".dockerignore",
"chars": 30,
"preview": "run/\nnode_modules/\n.git\n.idea\n"
},
{
"path": ".github/workflows/docker-image.yml",
"chars": 1183,
"preview": "# docker-image.yml\nname: Publish Docker image # workflow名称,可以在Github项目主页的【Actions】中看到所有的workflow\n\non: # 配置触发workflow"
},
{
"path": ".gitignore",
"chars": 75,
"preview": ".idea/\n.vscode/\nyarn-error.log\npackage-lock.json\nnode_modules/\n.env\nrun/\n,\n"
},
{
"path": ".prettierrc",
"chars": 256,
"preview": "{\n \"printWidth\": 80,\n \"singleQuote\": true,\n \"trailingComma\": \"all\",\n \"proseWrap\": \"never\",\n \"overrides\": [{ \"files\""
},
{
"path": "Dockerfile",
"chars": 513,
"preview": "FROM xiangsx/chrome:118.0.5993.70\n\nUSER root\n\nWORKDIR /usr/src/build\n\nCOPY package.json /usr/src/build/\nENV NODE_ENV=dev"
},
{
"path": "HowToUse.md",
"chars": 2665,
"preview": "## 1. 项目接口介绍\n\n- /supports 查询项目支持哪些站点和哪些model\n- /ask 简化后的请求和返回参数格式,后面会说明参数格式,等整个对话完成再返回\n- /ask/stream 简化后的请求和返回参数格式,流式返回\n"
},
{
"path": "LICENSE.txt",
"chars": 35149,
"preview": " GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
},
{
"path": "README.md",
"chars": 11483,
"preview": "<div align=\"center\">\n\n# GPT4Free TypeScript Version 🆓\n###### Providing a free OpenAI GPT-4 API!\nEnglish | [中文](README_zh"
},
{
"path": "README_ja.md",
"chars": 8295,
"preview": "<div align=\"center\">\n\n# GPT4Free の TypeScript バージョン 🆓\n###### OpenAI GPT-4 API を無償で提供!\n[English](README.md) | [中文](README"
},
{
"path": "README_zh.md",
"chars": 11612,
"preview": "<div align=\"center\">\n\n# GPT4Free TypeScript Version 🆓\n###### 提供免费的GPT4 API\n[English](README.md) | 中文 | [日本語](README_ja.m"
},
{
"path": "asyncstore.ts",
"chars": 154,
"preview": "import { AsyncLocalStorage } from 'async_hooks';\n\nexport type StoreSN = {\n sn?: string;\n};\nexport const AsyncStoreSN = "
},
{
"path": "docker-compose.yaml",
"chars": 444,
"preview": "version: \"3.9\"\n\nservices:\n gpt4free-ts:\n build:\n context: .\n dockerfile: Dockerfile\n container_name: gp"
},
{
"path": "index.ts",
"chars": 1468,
"preview": "import { initLog } from './utils/log';\n\nrequire('dotenv').config();\nrequire('elastic-apm-node').start({\n serverUrl: pro"
},
{
"path": "koa.d.ts",
"chars": 152,
"preview": "import { Context } from 'koa';\nimport { TraceLogger } from './utils/log';\n\ndeclare module 'koa' {\n interface Context {\n"
},
{
"path": "model/acytoo/index.ts",
"chars": 2532,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n contentToString,\n ModelType,\n} from '../base';\nimport { AxiosInstance,"
},
{
"path": "model/ails/index.ts",
"chars": 4178,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n contentToString,\n Message,\n ModelType,\n} from '../bas"
},
{
"path": "model/airoom/index.ts",
"chars": 6389,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { ComError, Event, EventStream, randomStr } "
},
{
"path": "model/airops/index.ts",
"chars": 13300,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport {\n Event,\n EventStream,\n getRandomOne,\n "
},
{
"path": "model/askx/index.ts",
"chars": 6545,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n messagesToPrompt,\n ModelType,\n} from '../base';\nimport {\n Event,\n Ev"
},
{
"path": "model/auto.ts",
"chars": 10077,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n contentToString,\n ImageGenerationRequest,\n messagesToPrompt,\n ModelT"
},
{
"path": "model/bai/index.ts",
"chars": 1961,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n ModelType,\n} from '../base';\nimport {\n DoneData,\n Err"
},
{
"path": "model/base.ts",
"chars": 20089,
"preview": "import {\n ComError,\n ErrorData,\n Event,\n EventStream,\n extractHttpFileURLs,\n extractHttpImageFileURLs,\n getTokenC"
},
{
"path": "model/better/index.ts",
"chars": 2861,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n ModelType,\n} from '../base';\nimport { AxiosInstance, Ax"
},
{
"path": "model/bibi/child.ts",
"chars": 2145,
"preview": "import { ComChild } from '../../utils/pool';\nimport {\n Account,\n ChapterSummaryReq,\n ChapterSummaryRes,\n ChatReq,\n "
},
{
"path": "model/bibi/define.ts",
"chars": 3915,
"preview": "import { ComInfo } from '../../utils/pool';\nimport exp from 'constants';\nimport Joi from 'joi';\n\nexport interface Accoun"
},
{
"path": "model/bibi/index.ts",
"chars": 5658,
"preview": "import { Chat, ChatRequest, ModelType, Site } from '../base';\nimport {\n Event,\n EventStream,\n extractJSON,\n MessageD"
},
{
"path": "model/bibi/prompt.ts",
"chars": 367,
"preview": "export const BibiPrompt = `\n你是专业的AI链接总结工具助手\nDo not include any explanations, only provide a RFC8259 compliant JSON respo"
},
{
"path": "model/bing/index.ts",
"chars": 2713,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { Event, EventStream, sleep } from '../../ut"
},
{
"path": "model/bingcopilot/child.ts",
"chars": 4740,
"preview": "import { ComChild } from '../../utils/pool';\nimport { Account } from './define';\nimport { Page } from 'puppeteer';\nimpor"
},
{
"path": "model/bingcopilot/define.ts",
"chars": 1062,
"preview": "import { ComInfo } from '../../utils/pool';\n\nexport interface Account extends ComInfo {}\n\nexport interface MessageUpdate"
},
{
"path": "model/bingcopilot/index.ts",
"chars": 2393,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { Pool } from '../../utils/pool';\nimport { A"
},
{
"path": "model/chatbase/index.ts",
"chars": 1859,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n ModelType,\n} from '../base';\nimport { AxiosInstance, Ax"
},
{
"path": "model/chatdemo/index.ts",
"chars": 7901,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { Browser, Page, Protocol } from 'puppeteer'"
},
{
"path": "model/chatgateai/index.ts",
"chars": 8457,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport {\n Event,\n EventStream,\n parseJSON,\n ran"
},
{
"path": "model/chatgateai/test.js",
"chars": 322982,
"preview": "/*! For license information please see chatbot.js.LICENSE.txt */\n(() => {\n 'use strict';\n var n = {\n 856: (n, t, "
},
{
"path": "model/chim/index.ts",
"chars": 2420,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n Message,\n ModelType,\n} from '../base';\nimport { AxiosI"
},
{
"path": "model/chur/index.ts",
"chars": 2632,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n Message,\n ModelType,\n} from '../base';\nimport { AxiosI"
},
{
"path": "model/claude/index.ts",
"chars": 9814,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { Event, EventStream, parseJSON, randomStr }"
},
{
"path": "model/claudeapi/index.ts",
"chars": 9058,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n contentToString,\n getImagesFromContent,\n Message,\n ModelType,\n} from"
},
{
"path": "model/claudeauto/child.ts",
"chars": 5674,
"preview": "import { ComChild } from '../../utils/pool';\nimport { Account, MessagesParamsList, MessagesReq } from './define';\nimport"
},
{
"path": "model/claudeauto/define.ts",
"chars": 503,
"preview": "import { ComInfo } from '../../utils/pool';\nimport { ChatRequest } from '../base';\n\nexport interface Account extends Com"
},
{
"path": "model/claudeauto/index.ts",
"chars": 5479,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport {\n checkSensitiveWords,\n Event,\n EventStr"
},
{
"path": "model/copilot/index.ts",
"chars": 10125,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n ModelType,\n} from '../base';\nimport { Browser, Page } f"
},
{
"path": "model/cursor/index.ts",
"chars": 15043,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n contentToString,\n ModelType,\n} from '../base';\nimport "
},
{
"path": "model/ddg/define.ts",
"chars": 244,
"preview": "import { ModelType } from '../base';\n\nexport const ModelMap: Partial<Record<ModelType, string>> = {\n [ModelType.Mixtral"
},
{
"path": "model/ddg/index.ts",
"chars": 6712,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport {\n ComError,\n Event,\n EventStream,\n pars"
},
{
"path": "model/ddg/test.js",
"chars": 167335,
"preview": "'use strict';\n(self.webpackChunkddg = self.webpackChunkddg || []).push([\n [4368],\n {\n 33919: (e, t, a) => {\n a"
},
{
"path": "model/define.ts",
"chars": 4284,
"preview": "// Represents the audio file formats supported for transcription.\nimport { ModelType } from './base';\nimport FormData fr"
},
{
"path": "model/discord/child.ts",
"chars": 8294,
"preview": "import { ComChild, DestroyOptions } from '../../utils/pool';\nimport {\n DiscordAccount,\n GatewayDHello,\n GatewayEventN"
},
{
"path": "model/discord/define.ts",
"chars": 12939,
"preview": "import { ComInfo } from '../../utils/pool';\nimport exp from 'constants';\n\nexport interface DiscordAccount extends ComInf"
},
{
"path": "model/doc2x/child.ts",
"chars": 4217,
"preview": "import { ComChild } from '../../utils/pool';\nimport { Account, PageData, StatusData } from './define';\nimport { CreateNe"
},
{
"path": "model/doc2x/define.ts",
"chars": 520,
"preview": "import { ComInfo } from '../../utils/pool';\n\nexport interface Account extends ComInfo {\n apikey: string;\n}\n\nexport inte"
},
{
"path": "model/doc2x/index.ts",
"chars": 2805,
"preview": "import { Chat, ChatRequest, getFilesFromContent, ModelType } from '../base';\nimport { downloadFile, EventStream, sleep }"
},
{
"path": "model/domo/child.ts",
"chars": 9722,
"preview": "import {\n Account,\n AnimateCommand,\n DomoApplicationID,\n DomoProfileInfo,\n GenCommand,\n InfoCommand,\n parseMJProf"
},
{
"path": "model/domo/define.ts",
"chars": 10974,
"preview": "import {\n ApplicationCommand,\n ApplicationCommandType,\n MessageFlags,\n DiscordAccount,\n} from '../discord/define';\ni"
},
{
"path": "model/domo/index.ts",
"chars": 13620,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n contentToString,\n ModelType,\n Site,\n} from '../base';\nimport { Pool }"
},
{
"path": "model/domo/prompt.ts",
"chars": 2373,
"preview": "export const DomoVideoToVideoPrompt = `\nYou are domo ai, a video generation AI. \nDo not include any explanations, only p"
},
{
"path": "model/domo/test.js",
"chars": 9541,
"preview": "const a = {\n type: 2,\n application_id: '1153984868804468756',\n guild_id: '1203629291527737406',\n channel_id: '120362"
},
{
"path": "model/easychat/index.ts",
"chars": 9694,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n ModelType,\n} from '../base';\nimport { Browser, Page } f"
},
{
"path": "model/fakeopen/index.ts",
"chars": 11546,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n ModelType,\n} from '../base';\nimport { AxiosInstance, Ax"
},
{
"path": "model/fireworks/child.ts",
"chars": 6017,
"preview": "import { ComChild, DestroyOptions } from '../../utils/pool';\nimport { Account, extractSecretKey, getFireworksModel } fro"
},
{
"path": "model/fireworks/define.ts",
"chars": 2317,
"preview": "import { ComInfo } from '../../utils/pool';\nimport { Protocol } from 'puppeteer';\nimport { ModelType } from '../base';\n\n"
},
{
"path": "model/fireworks/index.ts",
"chars": 2723,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType, Site } from '../base';\nimport { Pool } from '../../utils/pool';\nimpo"
},
{
"path": "model/fireworks/prompt.ts",
"chars": 569,
"preview": "export const LumaPrompt = `\nYou are a video prompt maker for Luma Video AI.\nDo not include any explanations, only provid"
},
{
"path": "model/flux/child.ts",
"chars": 5448,
"preview": "import { ChildOptions, ComChild, DestroyOptions } from '../../utils/pool';\nimport {\n Account,\n ClertAuth,\n Prediction"
},
{
"path": "model/flux/define.ts",
"chars": 3013,
"preview": "import { ComInfo } from '../../utils/pool';\nimport { Protocol } from 'puppeteer';\nimport { DefaultRedis, StringCache } f"
},
{
"path": "model/flux/index.ts",
"chars": 9441,
"preview": "import { Chat, ChatRequest, ModelType, Site } from '../base';\nimport { CreateNewAxios } from '../../utils/proxyAgent';\ni"
},
{
"path": "model/forefront/index.ts",
"chars": 13343,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n ModelType,\n} from '../base';\nimport { Browser, Page, Pr"
},
{
"path": "model/freegpt35/child.ts",
"chars": 3989,
"preview": "import { ComChild, DestroyOptions } from '../../utils/pool';\nimport { Account, Conversation } from './define';\nimport { "
},
{
"path": "model/freegpt35/define.ts",
"chars": 925,
"preview": "import { ComInfo } from '../../utils/pool';\n\nexport interface Account extends ComInfo {}\n\ninterface MessageContent {\n t"
},
{
"path": "model/freegpt35/index.ts",
"chars": 1397,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { EventStream } from '../../utils';\nimport {"
},
{
"path": "model/freegpt4/define.ts",
"chars": 257,
"preview": "export interface ApiKeyBase {\n name: string;\n models: string[];\n quota: number;\n}\n\nexport interface ApiKey extends Ap"
},
{
"path": "model/freegpt4/index.ts",
"chars": 9302,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { Event, EventStream, parseJSON, randomStr, "
},
{
"path": "model/gemini/define.ts",
"chars": 375,
"preview": "import { ChatRequest, ModelType } from '../base';\n\nexport interface GeminiRequest extends ChatRequest {\n temperature?: "
},
{
"path": "model/gemini/index.ts",
"chars": 10793,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n contentToString,\n Message,\n ModelType,\n} from '../base';\nimport { Axi"
},
{
"path": "model/glm/define.ts",
"chars": 1136,
"preview": "import { ModelType } from '../base';\n\nexport interface VideoGenerationsReq {\n model: ModelType;\n prompt: string;\n ima"
},
{
"path": "model/glm/index.ts",
"chars": 10445,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ImageGenerationRequest,\n ModelType,\n Site,\n SpeechRequest,\n} from '."
},
{
"path": "model/glm/prompt.ts",
"chars": 438,
"preview": "export const GlmCogViewXPrompt = `\nYou are a video prompt maker for ZhiPu CogVideoX AI.\nDo not include any explanations,"
},
{
"path": "model/google/index.ts",
"chars": 2601,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { Event, EventStream, sleep } from '../../ut"
},
{
"path": "model/gptgod/index.ts",
"chars": 2647,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { Event, EventStream, getRandomOne, sleep } "
},
{
"path": "model/gra/index.ts",
"chars": 3608,
"preview": "import {Chat, ChatOptions, ChatRequest, ChatResponse, ModelType} from \"../base\";\nimport {AxiosInstance, AxiosRequestConf"
},
{
"path": "model/groq/child.ts",
"chars": 8641,
"preview": "import { ComChild, DestroyOptions, Pool } from '../../utils/pool';\nimport { Account, ProfileRes } from './define';\nimpor"
},
{
"path": "model/groq/define.ts",
"chars": 3480,
"preview": "import { ComInfo } from '../../utils/pool';\nimport { Protocol } from 'puppeteer';\nimport exp from 'constants';\nimport { "
},
{
"path": "model/groq/index.ts",
"chars": 2495,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType, Site } from '../base';\nimport { Pool } from '../../utils/pool';\nimpo"
},
{
"path": "model/groq/prompt.ts",
"chars": 569,
"preview": "export const LumaPrompt = `\nYou are a video prompt maker for Luma Video AI.\nDo not include any explanations, only provid"
},
{
"path": "model/hypotenuse/index.ts",
"chars": 6985,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport {\n Event,\n EventStream,\n getRandomOne,\n "
},
{
"path": "model/ideogram/child.ts",
"chars": 9102,
"preview": "import { ChildOptions, ComChild, DestroyOptions } from '../../utils/pool';\nimport {\n Account,\n ClertAuth,\n ideogram,\n"
},
{
"path": "model/ideogram/define.ts",
"chars": 7672,
"preview": "import { ComInfo } from '../../utils/pool';\nimport { Protocol } from 'puppeteer';\nimport { DefaultRedis, StringCache } f"
},
{
"path": "model/ideogram/index.ts",
"chars": 7615,
"preview": "import { Chat, ChatRequest, ModelType, Site } from '../base';\nimport {\n Account,\n ideogram,\n IdeogramPrompt,\n ModelV"
},
{
"path": "model/index.ts",
"chars": 9649,
"preview": "import { Chat, ChatOptions, ModelType, Site } from './base';\nimport { Mcbbs } from './mcbbs';\nimport { Phind } from './p"
},
{
"path": "model/izea/index.ts",
"chars": 10720,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n contentToString,\n ModelType,\n} from '../base';\nimport { CDPSession, Pa"
},
{
"path": "model/jasper/index.ts",
"chars": 10355,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n ModelType,\n} from '../base';\nimport { Browser, EventEmi"
},
{
"path": "model/langdock/index.ts",
"chars": 14021,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport {\n Event,\n EventStream,\n getRandomOne,\n "
},
{
"path": "model/magic/index.ts",
"chars": 6702,
"preview": "import { Chat, ChatOptions, ChatRequest, Message, ModelType } from '../base';\nimport { Browser, Page } from 'puppeteer';"
},
{
"path": "model/mcbbs/index.ts",
"chars": 2406,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n ModelType,\n} from '../base';\nimport { AxiosInstance, Ax"
},
{
"path": "model/merlin/child.ts",
"chars": 8166,
"preview": "import {\n ChildOptions,\n ComChild,\n ComInfo,\n DestroyOptions,\n} from '../../utils/pool';\nimport { Account } from './"
},
{
"path": "model/merlin/define.ts",
"chars": 691,
"preview": "import { ComInfo } from '../../utils/pool';\nimport { ModelType } from '../base';\n\nexport interface Account extends ComIn"
},
{
"path": "model/merlin/index.ts",
"chars": 5324,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { Event, EventStream, parseJSON } from '../."
},
{
"path": "model/merlingmail/child.ts",
"chars": 1645,
"preview": "import { Child } from '../merlin/child';\nimport { CreateNewPage } from '../../utils/proxyAgent';\nimport { sleep } from '"
},
{
"path": "model/merlingmail/index.ts",
"chars": 5674,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport {\n Event,\n EventStream,\n parseJSON,\n ran"
},
{
"path": "model/midjourney/child.ts",
"chars": 9620,
"preview": "import {\n Account,\n BlendCommand,\n DimensionsList,\n DimensionsType,\n getPrompt,\n ImagineCommand,\n InfoCommand,\n "
},
{
"path": "model/midjourney/define.ts",
"chars": 7331,
"preview": "import {\n ApplicationCommand,\n ApplicationCommandOptionType,\n ApplicationCommandType,\n DiscordAccount,\n} from '../di"
},
{
"path": "model/midjourney/index.ts",
"chars": 12771,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType, Site } from '../base';\nimport { Pool } from '../../utils/pool';\nimpo"
},
{
"path": "model/midjourney/prompt.ts",
"chars": 4773,
"preview": "export const MJPrompt = ` Do not include any explanations, only provide a RFC8259 compliant JSON response following this"
},
{
"path": "model/mixer/index.ts",
"chars": 9130,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n MessageContent,\n ModelType,\n} from '../base';\nimport {\n Event,\n Even"
},
{
"path": "model/mjplus/child.ts",
"chars": 2267,
"preview": "import { ComChild } from '../../utils/pool';\nimport {\n Account,\n ActionRequest,\n BlendRequest,\n ComReturn,\n Discord"
},
{
"path": "model/mjplus/define.ts",
"chars": 2702,
"preview": "import { ComInfo } from '../../utils/pool';\n\nexport interface Account extends ComInfo {\n base_url: string;\n api_key: s"
},
{
"path": "model/mjplus/index.ts",
"chars": 10667,
"preview": "import { Chat, ChatRequest, ModelType, Site } from '../base';\nimport {\n ComError,\n downloadAndUploadCDN,\n Event,\n Ev"
},
{
"path": "model/mjplus/prompt.ts",
"chars": 4974,
"preview": "export const MJPlusPrompt = ` Do not include any explanations, only provide a RFC8259 compliant JSON response following "
},
{
"path": "model/mjweb/child.ts",
"chars": 6313,
"preview": "import { ChildOptions, ComChild, DestroyOptions } from '../../utils/pool';\nimport {\n Account,\n ClertAuth,\n Prediction"
},
{
"path": "model/mjweb/define.ts",
"chars": 3013,
"preview": "import { ComInfo } from '../../utils/pool';\nimport { Protocol } from 'puppeteer';\nimport { DefaultRedis, StringCache } f"
},
{
"path": "model/mjweb/index.ts",
"chars": 9317,
"preview": "import { Chat, ChatRequest, ModelType, Site } from '../base';\nimport { FluxPrompt, FluxServerCache, PredictionsReq } fro"
},
{
"path": "model/myshell/index.ts",
"chars": 14192,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n ModelType,\n} from '../base';\nimport { Browser, Page, Pr"
},
{
"path": "model/navit/index.ts",
"chars": 10423,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { Event, EventStream, parseJSON, sleep } fro"
},
{
"path": "model/oneapi/index.ts",
"chars": 3210,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n Message,\n ModelType,\n} from '../base';\nimport { AxiosI"
},
{
"path": "model/openai/index.ts",
"chars": 7071,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ImageGenerationRequest,\n ModelType,\n SpeechRequest,\n TextEmbeddingRe"
},
{
"path": "model/openaiauto/child.ts",
"chars": 2904,
"preview": "import { ComChild } from '../../utils/pool';\nimport {\n Account,\n MessagesParamsList,\n MessagesReq,\n OpenaiError,\n} f"
},
{
"path": "model/openaiauto/define.ts",
"chars": 842,
"preview": "import { ComInfo } from '../../utils/pool';\nimport { ChatRequest } from '../base';\n\nexport interface Account extends Com"
},
{
"path": "model/openaiauto/index.ts",
"chars": 5029,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport {\n checkSensitiveWords,\n Event,\n EventStr"
},
{
"path": "model/openprompt/index.ts",
"chars": 8776,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n ModelType,\n} from '../base';\nimport { Browser, Page, Pr"
},
{
"path": "model/opensess/index.ts",
"chars": 7961,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport {\n Event,\n EventStream,\n parseJSON,\n ran"
},
{
"path": "model/pap/index.ts",
"chars": 2661,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n ModelType,\n} from '../base';\nimport { AxiosInstance, Ax"
},
{
"path": "model/perauto/child.ts",
"chars": 8166,
"preview": "import { ComChild, DestroyOptions } from '../../utils/pool';\nimport {\n Account,\n DefaultPerEventReq,\n FocusType,\n Mo"
},
{
"path": "model/perauto/define.ts",
"chars": 3911,
"preview": "import { ComInfo } from '../../utils/pool';\nimport { ChatRequest, ModelType } from '../base';\n\ntype UseLeft = Partial<Re"
},
{
"path": "model/perauto/index.ts",
"chars": 3333,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { ComError, Event, EventStream } from '../.."
},
{
"path": "model/perlabs/cfpool.ts",
"chars": 1999,
"preview": "import { Page } from 'puppeteer';\nimport { CreateNewPage, getProxy } from '../../utils/proxyAgent';\nimport { v4 } from '"
},
{
"path": "model/perlabs/child.ts",
"chars": 4015,
"preview": "import { ComChild, DestroyOptions } from '../../utils/pool';\nimport { Account, MessageReq, MessageRes, PerLabEvents } fr"
},
{
"path": "model/perlabs/define.ts",
"chars": 1354,
"preview": "import { ComInfo } from '../../utils/pool';\nimport { Message, ModelType } from '../base';\n\nexport interface Account exte"
},
{
"path": "model/perlabs/index.ts",
"chars": 1186,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { Pool } from '../../utils/pool';\nimport { C"
},
{
"path": "model/perplexity/index.ts",
"chars": 15567,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { CDPSession, Page } from 'puppeteer';\nimpor"
},
{
"path": "model/phind/index.ts",
"chars": 10131,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n contentToString,\n ModelType,\n} from '../base';\nimport { Event, EventSt"
},
{
"path": "model/pika/child.ts",
"chars": 6092,
"preview": "import { ComChild } from '../../utils/pool';\nimport {\n Account,\n GenerationResponse,\n GenRequestOptions,\n LibraryVid"
},
{
"path": "model/pika/define.ts",
"chars": 2678,
"preview": "import { ComInfo } from '../../utils/pool';\nimport { Protocol } from 'puppeteer';\n\nexport interface Account extends ComI"
},
{
"path": "model/pika/index.ts",
"chars": 4056,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n contentToString,\n ModelType,\n} from '../base';\nimport { Pool } from '."
},
{
"path": "model/poe/define.ts",
"chars": 8619,
"preview": "import { ModelType } from '../base';\nimport { Config, PoeModelConfig } from '../../utils/config';\nimport { Page } from '"
},
{
"path": "model/pweb/index.ts",
"chars": 2264,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n ModelType,\n} from '../base';\nimport { AxiosInstance, Ax"
},
{
"path": "model/ram/index.ts",
"chars": 7221,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n contentToString,\n ModelType,\n} from '../base';\nimport "
},
{
"path": "model/runway/child.ts",
"chars": 10302,
"preview": "import { ChildOptions, ComChild, DestroyOptions, Pool } from '../../utils/pool';\nimport {\n Account,\n GenVideoTaskReq,\n"
},
{
"path": "model/runway/define.ts",
"chars": 3654,
"preview": "import { ComInfo } from '../../utils/pool';\nimport { Protocol } from 'puppeteer';\nimport exp from 'constants';\nimport { "
},
{
"path": "model/runway/index.ts",
"chars": 9967,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType, Site } from '../base';\nimport { Pool } from '../../utils/pool';\nimpo"
},
{
"path": "model/runway/prompt.ts",
"chars": 494,
"preview": "export const RunwayPrompt = `\nYou are a video prompt maker for Luma Video AI.\nDo not include any explanations, only prov"
},
{
"path": "model/sincode/index.ts",
"chars": 9077,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { CDPSession, Page } from 'puppeteer';\nimpor"
},
{
"path": "model/skailar/index.ts",
"chars": 2109,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n ModelType,\n} from '../base';\nimport { AxiosInstance, Ax"
},
{
"path": "model/stack/index.ts",
"chars": 15237,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport {\n Event,\n EventStream,\n getRandomOne,\n "
},
{
"path": "model/suno/child.ts",
"chars": 9503,
"preview": "import { ComChild, DestroyOptions } from '../../utils/pool';\nimport {\n Account,\n BillInfo,\n Clip,\n CreateSongRes,\n "
},
{
"path": "model/suno/define.ts",
"chars": 5459,
"preview": "import { ComInfo } from '../../utils/pool';\nimport { Protocol } from 'puppeteer';\nimport exp from 'constants';\nimport { "
},
{
"path": "model/suno/index.ts",
"chars": 16419,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType, Site } from '../base';\nimport { Pool } from '../../utils/pool';\nimpo"
},
{
"path": "model/suno/prompt.ts",
"chars": 3814,
"preview": "export const prompt = `\nYou are sono ai, a songwriting AI. \nDo not include any explanations, only provide a RFC8259 comp"
},
{
"path": "model/takeoff/index.ts",
"chars": 6973,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n messagesToPrompt,\n ModelType,\n} from '../base';\nimport {\n Event,\n Ev"
},
{
"path": "model/td/index.ts",
"chars": 8221,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport {\n Event,\n EventStream,\n getTokenCount,\n "
},
{
"path": "model/toyy/index.ts",
"chars": 2255,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { AxiosInstance, AxiosRequestConfig, CreateA"
},
{
"path": "model/vanus/index.ts",
"chars": 9424,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { Page } from 'puppeteer';\nimport {\n Event,"
},
{
"path": "model/vidu/child.ts",
"chars": 8941,
"preview": "import { ComChild, DestroyOptions, Pool } from '../../utils/pool';\nimport {\n Account,\n CreditsRes,\n Task,\n TaskReq,\n"
},
{
"path": "model/vidu/define.ts",
"chars": 2703,
"preview": "import { ComInfo } from '../../utils/pool';\nimport { Protocol } from 'puppeteer';\nimport { DefaultRedis, StringCache } f"
},
{
"path": "model/vidu/index.ts",
"chars": 11213,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType, Site } from '../base';\nimport { Pool } from '../../utils/pool';\nimpo"
},
{
"path": "model/vidu/prompt.ts",
"chars": 564,
"preview": "export const ViduPrompt = `\nYou are a video prompt maker for Luma Video AI.\nDo not include any explanations, only provid"
},
{
"path": "model/vita/index.ts",
"chars": 2412,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n ModelType,\n} from '../base';\nimport { AxiosInstance, Ax"
},
{
"path": "model/vvm/index.ts",
"chars": 2936,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n Message,\n ModelType,\n} from '../base';\nimport { AxiosI"
},
{
"path": "model/www/index.ts",
"chars": 3140,
"preview": "import { Chat, ChatOptions, ChatRequest, ModelType } from '../base';\nimport { Event, EventStream, getTokenCount } from '"
},
{
"path": "model/xun/index.ts",
"chars": 2592,
"preview": "import {\n Chat,\n ChatOptions,\n ChatRequest,\n ChatResponse,\n Message,\n ModelType,\n} from '../base';\nimport { AxiosI"
},
{
"path": "package.json",
"chars": 2727,
"preview": "{\n \"name\": \"gpt4free-ts\",\n \"version\": \"0.0.1\",\n \"description\": \"gpt4free typescript version\",\n \"main\": \"index.js\",\n "
},
{
"path": "router.ts",
"chars": 20055,
"preview": "import Koa, { Context, Middleware, Next } from 'koa';\nimport {\n ChatRequest,\n ChatResponse,\n countMessagesToken,\n Me"
},
{
"path": "tsconfig.json",
"chars": 12309,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig to read more about this file */\n \"outDir\": \"dist\",\n "
},
{
"path": "utils/cache.ts",
"chars": 4982,
"preview": "import Redis from 'ioredis';\nimport { Config } from './config';\nimport { newLogger } from './log';\nimport { Logger } fro"
},
{
"path": "utils/captcha.ts",
"chars": 5429,
"preview": "import { AxiosInstance } from 'axios';\nimport { randomStr, sleep } from './index';\nimport { CreateAxiosProxy } from './p"
},
{
"path": "utils/config.ts",
"chars": 15209,
"preview": "import { existsSync, readFileSync, statSync } from 'fs';\nimport { ModelType, Site } from '../model/base';\nimport { TempE"
},
{
"path": "utils/emailFactory.ts",
"chars": 33560,
"preview": "import { AxiosInstance, AxiosRequestConfig, CreateAxiosDefaults } from 'axios';\nimport { getRandomOne, Lock, md5, random"
},
{
"path": "utils/file.ts",
"chars": 8671,
"preview": "import * as fs from 'fs';\nimport { PathOrFileDescriptor, WriteFileOptions } from 'fs';\nimport ffmpeg from 'fluent-ffmpeg"
},
{
"path": "utils/index.ts",
"chars": 33810,
"preview": "import es from 'event-stream';\nimport { PassThrough, pipeline, Stream } from 'stream';\nimport * as crypto from 'crypto';"
},
{
"path": "utils/log.ts",
"chars": 5858,
"preview": "import path from 'path';\nimport winston, { Logger } from 'winston';\n// @ts-ignore\nimport Transport from 'winston-transpo"
},
{
"path": "utils/middleware.ts",
"chars": 1294,
"preview": "import { Context, Next } from 'koa';\nimport Joi, { string, ValidationOptions } from 'joi';\nimport { ComError, retryFunc "
},
{
"path": "utils/pool.ts",
"chars": 11715,
"preview": "import { v4 } from 'uuid';\nimport winston from 'winston';\nimport moment from 'moment';\nimport { ComError, parseJSON, shu"
},
{
"path": "utils/proxyAgent.ts",
"chars": 28876,
"preview": "import axios, { AxiosError, AxiosInstance, CreateAxiosDefaults } from 'axios';\nimport HttpsProxyAgent from 'https-proxy-"
},
{
"path": "utils/puppeteer.ts",
"chars": 15904,
"preview": "import normalPPT, {\n Browser,\n HTTPRequest,\n KnownDevices,\n Page,\n PuppeteerLaunchOptions,\n} from 'puppeteer';\nimpo"
},
{
"path": "utils/web.ts",
"chars": 5175,
"preview": "export function markdownToHTML(title: string, markdown: string) {\n return `<!DOCTYPE html>\n<html lang=\"zh-CN\">\n<head>\n "
}
]
About this extraction
This page contains the full source code of the xiangsx/gpt4free-ts GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 175 files (1.6 MB), approximately 423.9k tokens, and a symbol index with 1979 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.