Giter Site home page Giter Site logo

pandoratov1api's Introduction

项目简介

Important

Respect Zhile大佬, Respect Pandora!

为了方便大家将 Pandora-Next 项目与各种其他项目结合完成了本项目。

本项目支持:

  1. 将 Pandora-Next proxy 模式下的 backend-api 转为 /v1/chat/completions 接口,支持流式和非流式响应。

  2. 将 Pandora-Next proxy 模式下的 backend-api 转为 /v1/images/generations 接口

如果你想要尝试自己生成Arkose Token从而将PandoraNext的额度消耗降低到1:4,你可以看看这个项目:GenerateArkose,但是请注意,该项目并不保证使用该项目生成的Arkose Token不会封号,使用该项目造成的一切后果由使用者自行承担

如果本项目对你有帮助的话,请点个小星星吧~

如果有什么在项目的使用过程中的疑惑或需求,欢迎提 Issue,或者加入 Community Telegram Channel: Inker 的魔法世界 来和大家一起交流一下~

更新日志

Release 页面。

功能列表

  • 支持 代码解释器、联网、绘图

  • 支持 gpt-4-s

  • 支持 gpt-4-mobile

  • 支持 gpt-3.5-turbo

  • 支持 gpts

  • 支持 流式输出

  • 支持 非流式输出

  • 支持 dalle 绘图接口

  • 支持 接口保活

  • 支持 自定义接口前缀

  • 支持 日志等级划分

  • 支持 gpt-4-vision

  • 支持 Bot模式(QQ、微信机器人等建议开启,网页应用请不要开启)

  • 支持 指定进程、线程数

  • 支持文件生成

注意

Caution

  1. 本项目的运行需要 Pandora-Next 开启 auto_conv_arkose:true,同时请尽量升级最新版本的 Pandora-Next,以确保支持此功能。

  2. 本项目对话次数对Pandora-Next的对话额度消耗比例为:

    • gpt-4-sgpt-4-mobileGPTS1:14
    • gpt-3.5-turbo1:4
  3. 本项目实际为将来自 /v1/chat/completions 的请求转发到Pandora-Next的 /backend-api/conversation 接口,因此本项目并不支持高并发操作,请不要接入如 沉浸式翻译 等高并发项目。

  4. 本项目并不能绕过 OpenAI 和 PandoraNext 官方的限制,只提供便利,不提供绕过。

  5. 提问的艺术:当出现项目不能正常运行时,请携带 DEBUG 级别的日志在 Issue 或者社区群内提问,否则将开启算命模式~

支持的模型

目前支持的模型包括:

  1. gpt-4-s:支持代码解释器、bing联网、dalle绘图的 GPT-4,对应的是官方的默认 GPT-4(绘图的响应有时候有些不稳定)

  2. gpt-4-mobile:支持代码解释器、bing联网、dalle绘图的 GPT-4,对应的是官方的手机版 GPT-4,截止至2023年12月15日,本模型使用量不计入 GPT-4 用量(即不受每 3 小时 40 次的限制)

  3. 几乎所有的 GPTS(配置方式见下文)

  4. gpt-3.5-turbo

Docker-Compose 部署

仓库内已包含相关文件和目录,拉到本地后修改 docker-compose.yml 文件里的环境变量后运行docker-compose up -d即可。

config.json 变量说明:

  • log_level: 用于设置日志等级,可选值为:DEBUGINFOWARNINGERROR,默认为 DEBUG

  • need_log_to_file: 用于设置是否需要将日志输出到文件,可选值为:truefalse,默认为 true,日志文件路径为:./log/access.log,默认每天会自动分割日志文件。

  • process_workers: 用于设置进程数,如果不需要设置,可以保持不变,如果需要设置,可以设置为需要设置的值,如果设置为 1,则会强制设置为单进程模式。

  • process_threads: 用于设置线程数,如果不需要设置,可以保持不变,如果需要设置,可以设置为需要设置的值,如果设置为 1,则会强制设置为单线程模式。

  • pandora_base_url: Pandora-Next 的部署地址,如:https://pandoranext.com,注意:不要以 / 结尾。可以填写为本项目可以访问到的 PandoraNext 的内网地址。

  • pandora_api_prefix: PandoraNext Proxy 模式下的 API 前缀

  • backend_container_url: 用于dalle模型生成图片的时候展示所用,需要设置为使用如 ChatGPT-Next-Web 的用户可以访问到的本项目地址,如:http://1.2.3.4:50011,同原环境变量中的 UPLOAD_BASE_URL

  • backend_container_api_prefix: 用于设置本项目 /v1/xxx 接口的前缀,如果留空则与官方api调用接口一致。设置示例:666

  • key_for_gpts_info: 仅获取 GPTS 信息的 key,需要该 key 能够访问所有配置的 GPTS。后续发送消息仍需要在请求头携带请求所用的 key,如果未配置该项,请将 gpts.json 文件修改为:

{}
  • gpt_4_s_new_namegpt_4_mobile_new_namegpt_3_5_new_name: 用于设置 gpt-4-s、gpt-4-mobile、gpt-3.5-turbo 的模型名称与别名,如果不需要修改,可以保持不变。如果需要修改,每个模型均支持设置多个别名,多个别名之间以英文逗号隔开,例如:gpt-4-s 的别名可以设置为 gpt-4-s,dall-e-3,这样在调用的时候就可以使用 gpt-4-s 或者 dall-e-3 来调用该模型。

  • need_delete_conversation_after_response: 用于设置是否在响应后删除对话,可选值为:truefalse,默认为 false,如果设置为 true,则会在响应后删除对话,这样可以保证在页面上不会留下通过本项目调用的对话记录.

  • use_oaiusercontent_url: 是否使用OpenAI官方图片域名,可选值为:truefalse,默认为 false,如果设置为 true,则会使用OpenAI的图片域名,否则使用 backend_container_url 参数的值作为图片域名。如果设置为 true,则 backend_container_url 可以不填且图片不会下载到image文件夹中。

  • use_pandora_file_server: 是否使用PandoraNext的文件服务器,可选值为:truefalse,默认为 true,如果设置为 true,则会从PandoraNext的文件服务器下载图片等文件,否则将直接从openai的文件服务器下载文件。

  • custom_arkose_url: 是否需要自定义Arkose Token获取地址,可选值为:truefalse,默认为 false,如果设置为 true,则会使用 arkose_urls 参数的值作为Arkose Token获取地址,否则使用默认的PandoraNext Arkose Token获取地址。

  • arkose_urls: Arkose Token获取地址,如果 custom_arkose_urlfalse,则该参数无效,如果 custom_arkose_urltrue,则该参数必填,且需要填写为可以获取Arkose Token的地址列表,例如:https://arkose-proxy-1.pandoranext.com/<proxy-prefix>,https://arkose-proxy-2.pandoranext.com/<proxy-prefix>,支持同时设置多个Arkose Token获取地址,从前往后轮询调用,如果第一个获取失败则自动从第二个获取,以此类推。

  • dalle_prompt_prefix: 自定义的DALLE接口prompt前缀,可以引导gpt完成绘图任务。

PS. 注意,arkose_urls中的地址需要支持PandoraNext的Arkose Token获取路径与参数,并与PandoraNext的Arkose Token获取接口的响应格式保持一致。

  • bot_mode

    • enabled: 用于设置是否开启 Bot 模式,可选值为:truefalse,默认为 false,开启 Bot 模式后,将可以自定义联网插件的引引用、绘图插件的markdown格式的图片以及插件执行过程的输出,仅建议在 QQ、微信机器人等 Bot 项目中开启,网页应用请不要开启。

    • enabled_markdown_image_output: 用于设置是否开启 Bot 模式下绘图插件的markdown格式的图片输出,可选值为:truefalse,默认为 false,开启后,将会输出markdown格式的图片输出,仅在 bot_mode.enabledtrue 时生效。

    • enabled_plain_image_url_output: 用于设置是否开启 Bot 模式下绘图插件的纯图片链接(非markdown格式)输出,可选值为:truefalse,默认为 false,开启后,将会输出纯图片链接输出,仅在 bot_mode.enabledtrue 时生效。注意:与enabled_markdown_image_output 同时开启时,只会输出非 markdown 格式的图片。

    • enabled_bing_reference_output: 用于设置是否开启 Bot 模式下联网插件的引用输出,可选值为:truefalse,默认为 false,开启后,将会输出联网插件的引用,仅在 bot_mode.enabledtrue 时生效。

    • enabled_plugin_output: 用于设置是否开启 Bot 模式下插件执行过程的输出,可选值为:truefalse,默认为 false,开启后,将会输出插件执行过程的输出,仅在 bot_mode.enabledtrue 时生效。

  • redis

    • host: Redis的ip地址,例如:1.2.3.4,默认是 redis 容器

    • port: Redis的端口,默认:6379,如有特殊需求,你可以将此值设置为其他端口

    • password: Redis的密码,默认为空,如果你的Redis服务设置了密码,请将其设置为你的密码

    • db: Redis的数据库,默认:0,如有特殊需求,你可以将此值设置为其他数据库

GPTS配置说明

如果需要使用 GPTS,需要修改 gpts.json 文件,其中每个对象的key即为调用对应 GPTS 的时候使用的模型名称,而 id 则为对应的模型id,该 id 对应每个 GPTS 的链接的后缀。配置多个GPTS的时候用逗号隔开。

例如:PandoraNext的官方 GPTS 的链接为:https://chat.oaifree.com/g/g-CFsXuTRfy-pandoranextzhu-shou,则该模型的 id 的值应为 g-CFsXuTRfy-pandoranextzhu-shou,而模型名可以自定义。

示例:

{
    "gpt-4-classic": {
        "id":"g-YyyyMT9XH-chatgpt-classic"
    },
    "pandoraNext":{
        "id":"g-CFsXuTRfy-pandoranextzhu-shou"
    }
}

注意:使用该配置的时候需要保证正确填写 docker-compose.yml 的环境变量 KEY_FOR_GPTS_INFO,同时该变量设置的 key 允许访问所有配置的 GPTS。

绘图接口使用说明

接口URI:/v1/images/generations

请求方式:POST

请求头:正常携带 AuthorizationContent-Type 即可,Authorization 的值为 Bearer <Pandora-Next 的 fk>Content-Type 的值为 application/json

请求体格式示例:

{
    "model": "gpt-4-s",
    "prompt": "A cute baby sea otter"
}

请求体参数说明:

  • model:模型名称,需要支持绘图功能,否则绘图结果将为空

  • prompt:绘图的 Prompt

响应体格式示例:

{
    "created": 1702788293,
    "data": [
        {
            "url": "http://<upload 容器公网ip>:50012/images/image_20231217044452.png"
        }
    ],
    "reply": "\n```\n{\"size\":\"1024x1024\",\"prompt\":\"A cute baby sea otter floating on its back in calm, clear waters. The otter has soft, fluffy brown fur, and its small, round eyes are shining brightly. It's holding a small starfish in its tiny paws. The sun is setting in the background, casting a golden glow over the scene. The water reflects the colors of the sunset, with gentle ripples around the otter. There are a few seagulls flying in the distance under the pastel-colored sky.\"}Here is the image of a cute baby sea otter floating on its back."
}

文件识别接口使用说明

调用方式同官方 gpt-4-vision-preview API

接口URI:/v1/chat/completions

请求方式:POST

请求体格式示例(以 url 形式传入文件):

{
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "这个pdf里写了什么,用中文回复"
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://bitcoin.org/bitcoin.pdf"
                    }
                }
            ]
        }
    ],
    "stream": false,
    "model": "gpt-4",
    "temperature": 0.5,
    "presence_penalty": 0,
    "frequency_penalty": 0,
    "top_p": 1
}

请求体示例(以 Base64 形式传入文件):

{
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "这张图里画了什么"
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "data:<mime>;base64,<文件的Base64>"
                    }
                }
            ]
        }
    ],
    "stream": false,
    "model": "gpt-4-s",
    "temperature": 0.5,
    "presence_penalty": 0,
    "frequency_penalty": 0,
    "top_p": 1
}

MIME 支持列表,包括但不限于(如果非列表中的类型会直接转成纯文本txt执行上传操作):

"image/jpeg", "image/webp", "image/png", "image/gif","text/x-php", "application/msword", "text/x-c", "text/html",  "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/json", "text/javascript", "application/pdf", "text/x-java", "text/x-tex", "text/x-typescript", "text/x-sh", "text/x-csharp", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "text/x-c++", "application/x-latext", "text/markdown", "text/plain", "text/x-ruby", "text/x-script.python"

响应体格式示例:

{
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "message": {
                "content": "\n```\nopen_url(\"file-xxxxxxx\")\n```\n这个PDF文件是关于比特币的原始论文,名为《比特币:一种点对点的电子现金系统》,作者是中本聪。这篇论文介绍了一种全新的数字货币系统,它不依赖于任何中心化的金融机构。比特币通过一种去中心化的网络和一种称为区块链的技术来维持交易的安全和完整性。这个系统使用数字签名来确认交易,并通过一种被称为工作量证明的机制来防止双重支付。整个系统旨在创建一个安全、去中心化、对用户友好的数字货币。",
                "role": "assistant"
            }
        }
    ],
    "created": 1703063445,
    "id": "chatcmpl-xxxxxxxx",
    "model": "gpt-4",
    "object": "chat.completion",
    "system_fingerprint": null,
    "usage": {
        "completion_tokens": 0,
        "prompt_tokens": 0,
        "total_tokens": 0
    }
}

示例

以ChatGPT-Next-Web项目的docker-compose部署为例,这里提供一个简单的部署配置文件示例:

version: '3'
services:
  chatgpt-next-web:
    image: yidadaa/chatgpt-next-web
    ports:
      - "50013:3000"
    environment:
      - OPENAI_API_KEY=<Pandora-Next 的 fk>
      - BASE_URL=<backend-to-api容器地址>
      - CUSTOM_MODELS=+gpt-4-s,+gpt-4-mobile,+<gpts.json 中的模型名>

功能演示

联网

api-1

代码解释器

api-2

绘图

api-3

GPT-4-Mobile

api-4

GPTS

api-5

Bot 模式

开启 Bot 模式

image

关闭 Bot 模式

image

贡献者们

感谢所有让这个项目变得更好的贡献者们!

Contributors

平台推荐

Cloudflare

世界领先的互联网基础设施和安全公司,为您的网站提供 CDN、DNS、DDoS 保护和安全性服务,可以帮助你的项目尽可能避免遭受网络攻击或爬虫行为。 Cloudflare

Star 历史

Stargazers over time

pandoratov1api's People

Contributors

biek12 avatar ink-osier avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pandoratov1api's Issues

0.0.9 ChatGPT-Next-Web 仍然返回 Failed to fetch

docker 后台log:

[2023-12-15 06:59:56.195901] New Request
api_key: ***
model: gpt-4-mobile
content_type: text
last_content_type: None
content_type: text
last_content_type: None
content_type: text
last_content_type: None
content_type: text
last_content_type: None
38.*** - - [15/Dec/2023:06:59:58 +0000] "POST /v1/chat/completions HTTP/1.1" 200 0 "http://***:3000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
[2023-12-15 06:59:58 +0000] [9] [ERROR] Error handling request /v1/chat/completions
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/gthread.py", line 282, in handle
    keepalive = self.handle_request(req, conn)
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/gthread.py", line 339, in handle_request
    for item in respiter:
  File "/usr/local/lib/python3.9/site-packages/werkzeug/wsgi.py", line 256, in __next__
    return self._next()
  File "/usr/local/lib/python3.9/site-packages/werkzeug/wrappers/response.py", line 32, in _iter_encoded
    for item in iterable:
  File "/app/main.py", line 381, in generate
    message_status = message.get("status")
AttributeError: 'NoneType' object has no attribute 'get'
38.*** - - [15/Dec/2023:06:59:58 +0000] "POST /v1/chat/completions HTTP/1.1" 500 0 "-" "-"

建议使用第三方工具生成arkose,以增加Pandora可用次数

可以在程序中生成arkosetoken,而不是用pandora,这样能大幅度降低Pandora额度消耗。
推荐这个库:Arkose Fetch
这是一个go语言的项目。如果想整合到python中,可以使用C共享库,以下是一个例子:

//main.go

package main

/*
#include <stdlib.h>
*/
import "C"
import (
	"github.com/acheong08/funcaptcha"
)

//export ArkoseToken
func ArkoseToken() *C.char {
	_, token, _ := funcaptcha.GetOpenAIToken()
	return C.CString(token) // 将Go字符串转换为C字符串
}

func main() {}

使用go build编译这个文件为c共享库

go build -o arkose_token.so -buildmode=c-shared main.go

然后就可以在python中调用了

import ctypes

# 加载共享库
lib = ctypes.CDLL('./arkose_token.so')

# 调用函数
lib.ArkoseToken.restype = ctypes.c_char_p  # 设置返回类型为字符串
token = lib.ArkoseToken()
print('Token:', token.decode('utf-8'))  # 解码C字符串为Python字符串

然后每次调用backend时使用生成的arkosetoken即可,这样gpt4每条的消耗就从14条变为了4条,可用性将会大大提高。

RN vps 运行报错

不知道是不是python版本问题?

backend-to-api_1 | [2023-12-19 14:22:09 +0000] [8] [ERROR] Exception in worker process
backend-to-api_1 | Traceback (most recent call last):
backend-to-api_1 | File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
backend-to-api_1 | worker.init_process()
backend-to-api_1 | File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/gthread.py", line 95, in init_process
backend-to-api_1 | super().init_process()
backend-to-api_1 | File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 142, in init_process
backend-to-api_1 | self.run()
backend-to-api_1 | File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/gthread.py", line 214, in run
backend-to-api_1 | callback(key.fileobj)
backend-to-api_1 | File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/gthread.py", line 150, in on_client_socket_readable
backend-to-api_1 | self.enqueue_req(conn)
backend-to-api_1 | File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/gthread.py", line 117, in enqueue_req
backend-to-api_1 | fs = self.tpool.submit(self.handle, conn)
backend-to-api_1 | File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 176, in submit
backend-to-api_1 | self._adjust_thread_count()
backend-to-api_1 | File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 199, in _adjust_thread_count
backend-to-api_1 | t.start()
backend-to-api_1 | File "/usr/local/lib/python3.9/threading.py", line 899, in start
backend-to-api_1 | _start_new_thread(self._bootstrap, ())
backend-to-api_1 | RuntimeError: can't start new thread
backend-to-api_1 | [2023-12-19 14:22:09 +0000] [8] [INFO] Worker exiting (pid: 8)
backend-to-api_1 | [2023-12-19 14:22:09 +0000] [1] [ERROR] Worker (pid:8) exited with code 255
backend-to-api_1 | [2023-12-19 14:22:09 +0000] [1] [ERROR] Worker (pid:8) exited with code 255.
backend-to-api_1 | [2023-12-19 14:22:09 +0000] [11] [INFO] Booting worker with pid: 11

部分plus账户无法正常使用

我有俩plus账户,一个是我自己独享的,一个是和别人拼车的。
独享的那个拿来做这个没什么问题,但是如果拿拼车的那个,其他条件都一样,也是用pandoranext拼接的fk key,然后不管输入什么返回结果都是
2024-01-15 07:59:55,330 [INFO] - New Request
2024-01-15 07:59:55,331 [INFO] - api_key: fk-
2024-01-15 07:59:55,332 [INFO] - model: gpt-4-mobile
2024-01-15 07:59:55,334 [INFO] - 原模型名: gpt-4-mobile
2024-01-15 07:59:55,335 [DEBUG] - payload: {'action': 'next', 'messages': [{'id': '9d4859e8-8742-464f-8d54-3f062bdb0db4', 'author': {'role': 'user'}, 'content': {'content_type': 'text', 'parts': ['你好']}, 'metadata': {}}], 'parent_message_id': '171905d0-eb68-4798-9d11-7ed2a8e5d6d2', 'model': 'gpt-4-mobile', 'timezone_offset_min': -480, 'suggestions': ['Give me 3 ideas about how to plan good New Years resolutions. Give me some that are personal, family, and professionally-oriented.', 'Write a text asking a friend to be my plus-one at a wedding next month. I want to keep it super short and casual, and offer an out.', 'Design a database schema for an online merch store.', 'Compare Gen Z and Millennial marketing strategies for sunglasses.'], 'history_and_training_disabled': False, 'conversation_mode': {'kind': 'primary_assistant'}, 'force_paragen': False, 'force_rate_limit': False}
2024-01-15 07:59:55,338 [DEBUG] - Starting new HTTPS connection (1): :443
2024-01-15 07:59:56,983 [DEBUG] - https://ai.alizoed.top:443 "POST HTTP/1.1" 200 473
2024-01-15 07:59:56,986 [INFO] - 发送最后的数据: data: {"id": "chatcmpl-8875428086694334adf67f866e71732e", "object": "chat.completion.chunk", "created": 1705305596, "model": "error", "choices": [{"index": 0, "delta": {"content": "\n\u672a\u77e5\u9519\u8bef\n"}, "finish_reason": null}]}

2024-01-15 07:59:56,987 [INFO] - 会话结束
2024-01-15 07:59:56,990 [INFO] - 完整消息: ```
未知错误

2024-01-15 07:59:56,992 [DEBUG] - 会话结束-外层
2024-01-15 08:04:29,725 [INFO] - ==========================================
然后就会显示未知错误。
单独使用这个accesstoken去pandoranext项目上使用,不管是mobile还是普通gpt4都能正常使用

使用curl无法联通

使用ToV1api+使用gpt-3.5-turbo模型

curl http://ToV1api_url:50011/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer fk-*****" -d '{ "model": "gpt-3.5-turbo", "messages": [{"role": "system","content": "You are a helpful assistant."},{"role": "user","content": "Hello!"}]}'

<!doctype html>
<html lang=en>
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>

使用ToV1api+使用gpt-4模型

curl http://ToV1api_url:50011/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer fk-*****" -d '{ "model": "gpt-4", "messages": [{"role": "system","content": "You are a helpful assistant."},{"role": "user","content": "Hello!"}]}'

{"error":"model is not accessible"}

另外,我将生成的sharetoken放到one-api里面,渠道API地址设置成http://ToV1api_url:50011,也无法使用。

请问该如何写请求,以使用gpt-4-s、gpt-4-mobile这几个模型?谢谢大佬

【功能】RefreshAccessTokenError

session token和refresh token可自动刷新。
{
"test_1": {
"token": "session_token",
"shared": false,
"show_user_info": true
}
}
按照文档配置token.json的session token,一周后登录提示RefreshAccessTokenError错误,请问下是什么问题?

初步尝试有问题,返回了{"message":"Welcome to Inker's World"}

大佬,我的config的配置如下:
{
"log_level": "DEBUG",
"need_log_to_file": "true",
"process_workers": 2,
"process_threads": 2,
"pandora_base_url": "http://10.0.8.8:8181",
"pandora_api_prefix": "tokensTool01",
"backend_container_url": "http://10.0.8.8:50011",
"backend_container_api_prefix": "",
"key_for_gpts_info": "fk-",
"gpt_4_s_new_name": "gpt-4-s",
"gpt_4_mobile_new_name": "gpt-4-mobile,dall-e-3",
"gpt_3_5_new_name": "gpt-3.5-turbo",
"need_delete_conversation_after_response": "false",
"use_oaiusercontent_url": "false",
"use_pandora_file_server": "true",
"custom_arkose_url": "false",
"arkose_urls": "",
"dalle_prompt_prefix": "请严格根据我的以下要求完成绘图任务,如果我没有发出指定的绘画指令,则绘制出我发出的文字对应的图片:",
"bot_mode": {
"enabled": "true",
"enabled_markdown_image_output": "true",
"enabled_plain_image_url_output": "false",
"enabled_bing_reference_output": "false",
"enabled_plugin_output": "false"
}
}
我使用curl命令如下:
curl http://10.0.8.8:50011/v1/images/completions
-H "Content-Type: application/json"
-H "Authorization: Bearer fk-
"
-d '{
"model": "gpt-4-s",
"prompt": "A cute baby sea otter"
}'
我在测试过程中,命令行调用结果如下:
image
日志如下:

2024-01-08 08:10:15,867 [DEBUG] - 请求体: b'{\n    "model": "gpt-4-s",\n    "prompt": "A cute baby sea otter"\n  }'
10.0.8.8 - - [08/Jan/2024:08:10:15 +0000] "POST /v1/images/completions HTTP/1.1" 200 39 "-" "curl/7.29.0"
2024-01-08 08:23:36,138 [DEBUG] - 未知请求: v1/images/completions
2024-01-08 08:23:36,138 [DEBUG] - 请求方法: POST
2024-01-08 08:23:36,138 [DEBUG] - 请求头: User-Agent: curl/7.29.0
Host: 10.0.8.8:50011
Accept: */*
Content-Type: application/json
Authorization: Bearer fk-xxx
Content-Length: 67


2024-01-08 08:23:36,139 [DEBUG] - 请求体: b'{\n    "model": "gpt-4-s",\n    "prompt": "A cute baby sea otter"\n  }'
10.0.8.8 - - [08/Jan/2024:08:23:36 +0000] "POST /v1/images/completions HTTP/1.1" 200 39 "-" "curl/7.29.0"

初始启动日志如下:

2024-01-08 07:53:34,275 [INFO] - need_delete_conversation_after_response: False
2024-01-08 07:53:34,275 [INFO] - use_oaiusercontent_url: False
2024-01-08 07:53:34,275 [INFO] - Chat 接口 URI: /v1/chat/completions
2024-01-08 07:53:34,275 [INFO] - use_pandora_file_server: True
2024-01-08 07:53:34,275 [INFO] - 绘图接口 URI: /v1/images/generations
2024-01-08 07:53:34,276 [INFO] - custom_arkose_url: False
2024-01-08 07:53:34,276 [INFO] - need_delete_conversation_after_response: False
2024-01-08 07:53:34,276 [INFO] - DALLE_prompt_prefix: 请严格根据我的以下要求完成绘图任务,如果我没有发出指定的绘画指令,则绘制出我发出的文字对应的图片:
2024-01-08 07:53:34,276 [INFO] - use_oaiusercontent_url: False
2024-01-08 07:53:34,276 [INFO] - ==========================================
2024-01-08 07:53:34,276 [INFO] - use_pandora_file_server: True
2024-01-08 07:53:34,276 [INFO] - GPTS 配置信息
2024-01-08 07:53:34,276 [INFO] - custom_arkose_url: False
2024-01-08 07:53:34,276 [INFO] - DALLE_prompt_prefix: 请严格根据我的以下要求完成绘图任务,如果我没有发出指定的绘画指令,则绘制出我发出的文字对应的图片:
2024-01-08 07:53:34,276 [INFO] - ==========================================
2024-01-08 07:53:34,276 [INFO] - GPTS 配置信息
2024-01-08 07:53:34,278 [DEBUG] - Starting new HTTP connection (1): 10.0.8.8:8181
2024-01-08 07:53:34,278 [DEBUG] - Starting new HTTP connection (1): 10.0.8.8:8181
2024-01-08 07:53:35,252 [DEBUG] - http://10.0.8.8:8181 "GET /tokensTool01/backend-api/gizmos/g-YyyyMT9XH-chatgpt-classic HTTP/1.1" 200 1842
2024-01-08 07:53:35,254 [DEBUG] - Starting new HTTP connection (1): 10.0.8.8:8181
2024-01-08 07:53:35,779 [DEBUG] - http://10.0.8.8:8181 "GET /tokensTool01/backend-api/gizmos/g-CFsXuTRfy-pandoranextzhu-shou HTTP/1.1" 200 None
2024-01-08 07:53:35,780 [INFO] - 当前可用 GPTS 列表: ['gpt-4-s', 'gpt-4-mobile', 'dall-e-3', 'gpt-3.5-turbo', 'gpt-4-classic', 'pandoraNext']
2024-01-08 07:53:35,780 [INFO] - ==========================================
2024-01-08 07:53:36,206 [DEBUG] - http://10.0.8.8:8181 "GET /tokensTool01/backend-api/gizmos/g-YyyyMT9XH-chatgpt-classic HTTP/1.1" 200 1842
2024-01-08 07:53:36,208 [DEBUG] - Starting new HTTP connection (1): 10.0.8.8:8181
2024-01-08 07:53:36,940 [DEBUG] - http://10.0.8.8:8181 "GET /tokensTool01/backend-api/gizmos/g-CFsXuTRfy-pandoranextzhu-shou HTTP/1.1" 200 None
2024-01-08 07:53:36,941 [INFO] - 当前可用 GPTS 列表: ['gpt-4-s', 'gpt-4-mobile', 'dall-e-3', 'gpt-3.5-turbo', 'gpt-4-classic', 'pandoraNext']
2024-01-08 07:53:36,941 [INFO] - ==========================================
2024-01-08 07:57:12,164 [DEBUG] - 未知请求: v1/completions
2024-01-08 07:57:12,165 [DEBUG] - 请求方法: POST
2024-01-08 07:57:12,165 [DEBUG] - 请求头: User-Agent: curl/7.29.0
Host: 10.0.8.8:50011

我想请问下这配置中是否有什么错误么,无论我把model修改为其他的,返回的都是{"message":"Welcome to Inker's World"}

能不能添加backend模式

目前是全用proxy模式 但是像这种next调用又是用历史会话发送。其实希望可以优化一下 不走 /v1/chat/completions 走/backend-api/* 这样。然后处理一下用一个固定key后台刷新Accesstoken去请求。
现在这样也是用模拟对话模式 两种实际上都一样。但是现在这样反而记不住上下文。还要舍近求远压缩历史对话再发送 不如原来的聪明。

希望可以考虑一下 感谢。

⚠️ 在高并发请求的场景中很快被封

pandoratov1api-backend-to-api-1  | message 为空: data_json: {'message': None, 'conversation_id': 'XXXXXXX-c5b9-4c84-ae24-XXXXXXXXXXXX', 'error': 'Our systems have detected unusual activity from your system. Please try again later.'}

尝试在“沉浸式翻译”中使用本插件,每秒最大请求数 10,很快就被封了😭。

作者最好提醒一下,在“对话”场景中用没问题,其他场景中还是悠着点...

返回格式上的一些问题

pandoraNext 的 /v1/chat/completions 接口响应如下

b'data: {"id":"chatcmpl-oh0UFdq9cCceAKWoS4e3LyDxojf8V","object":"chat.completion.chunk","created":1703783665,"model":"gpt-4-32k","choices":[{"delta":{"role":"assistant"},"index":0,"finish_reason":null}]}\n\ndata: {"id":"chatcmpl-oh0UFdq9cCceAKWoS4e3LyDxojf8V","object":"chat.completion.chunk","created":1703783665,"model":"gpt-4-32k","choices":[{"delta":{"content":"Hello"},"index":0,"finish_reason":null}]}\n\ndata: {"id":"chatcmpl-oh0UFdq9cCceAKWoS4e3LyDxojf8V","object":"chat.completion.chunk","created":1703783665,"model":"gpt-4-32k","choices":[{"delta":{"content":"!"},"index":0,"finish_reason":null}]}\n\ndata: {"id":"chatcmpl-oh0UFdq9cCceAKWoS4e3LyDxojf8V","object":"chat.completion.chunk","created":1703783665,"model":"gpt-4-32k","choices":[{"delta":{"content":" How"},"index":0,"finish_reason":null}]}\n\ndata: {"id":"chatcmpl-oh0UFdq9cCceAKWoS4e3LyDxojf8V","object":"chat.completion.chunk","created":1703783665,"model":"gpt-4-32k","choices":[{"delta":{"content":" can"},"index":0,"finish_reason":null}]}\n\ndata: {"id":"chatcmpl-oh0UFdq9cCceAKWoS4e3LyDxojf8V","object":"chat.completion.chunk","created":1703783665,"model":"gpt-4-32k","choices":[{"delta":{"content":" I"},"index":0,"finish_reason":null}]}\n\ndata: {"id":"chatcmpl-oh0UFdq9cCceAKWoS4e3LyDxojf8V","object":"chat.completion.chunk","created":1703783665,"model":"gpt-4-32k","choices":[{"delta":{"content":" assist"},"index":0,"finish_reason":null}]}\n\ndata: {"id":"chatcmpl-oh0UFdq9cCceAKWoS4e3LyDxojf8V","object":"chat.completion.chunk","created":1703783665,"model":"gpt-4-32k","choices":[{"delta":{"content":" you"},"index":0,"finish_reason":null}]}\n\ndata: {"id":"chatcmpl-oh0UFdq9cCceAKWoS4e3LyDxojf8V","object":"chat.completion.chunk","created":1703783665,"model":"gpt-4-32k","choices":[{"delta":{"content":" today"},"index":0,"finish_reason":null}]}\n\ndata: {"id":"chatcmpl-oh0UFdq9cCceAKWoS4e3LyDxojf8V","object":"chat.completion.chunk","created":1703783665,"model":"gpt-4-32k","choices":[{"delta":{"content":"?"},"index":0,"finish_reason":null}]}\n\ndata: {"id":"chatcmpl-oh0UFdq9cCceAKWoS4e3LyDxojf8V","object":"chat.completion.chunk","created":1703783665,"model":"gpt-4-32k","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}\n\ndata: [DONE]\n\n'

本项目响应如下:

b'data:{"id": "chatcmpl-f0a45ac3f5f04e80aad66500c9be45fb", "object": "chat.completion.chunk", "created": 1703783102, "model": "gpt-4", "choices": [{"index": 0, "delta": {"content": ""}, "finish_reason": null}]}\n\ndata: {"id": "chatcmpl-f0a45ac3f5f04e80aad66500c9be45fb", "object": "chat.completion.chunk", "created": 1703783102, "model": "gpt-4", "choices": [{"index": 0, "delta": {"content": "Hello"}, "finish_reason": null}]}\n\ndata: {"id": "chatcmpl-f0a45ac3f5f04e80aad66500c9be45fb", "object": "chat.completion.chunk", "created": 1703783102, "model": "gpt-4", "choices": [{"index": 0, "delta": {"content": "!"}, "finish_reason": null}]}\n\ndata: {"id": "chatcmpl-f0a45ac3f5f04e80aad66500c9be45fb", "object": "chat.completion.chunk", "created": 1703783102, "model": "gpt-4", "choices": [{"index": 0, "delta": {"content": " How"}, "finish_reason": null}]}\n\ndata: {"id": "chatcmpl-f0a45ac3f5f04e80aad66500c9be45fb", "object": "chat.completion.chunk", "created": 1703783102, "model": "gpt-4", "choices": [{"index": 0, "delta": {"content": " can"}, "finish_reason": null}]}\n\ndata: {"id": "chatcmpl-f0a45ac3f5f04e80aad66500c9be45fb", "object": "chat.completion.chunk", "created": 1703783102, "model": "gpt-4", "choices": [{"index": 0, "delta": {"content": " I"}, "finish_reason": null}]}\n\ndata: {"id": "chatcmpl-f0a45ac3f5f04e80aad66500c9be45fb", "object": "chat.completion.chunk", "created": 1703783102, "model": "gpt-4", "choices": [{"index": 0, "delta": {"content": " assist"}, "finish_reason": null}]}\n\ndata: {"id": "chatcmpl-f0a45ac3f5f04e80aad66500c9be45fb", "object": "chat.completion.chunk", "created": 1703783102, "model": "gpt-4", "choices": [{"index": 0, "delta": {"content": " you"}, "finish_reason": null}]}\n\ndata: {"id": "chatcmpl-f0a45ac3f5f04e80aad66500c9be45fb", "object": "chat.completion.chunk", "created": 1703783102, "model": "gpt-4", "choices": [{"index": 0, "delta": {"content": " today"}, "finish_reason": null}]}\n\ndata: {"id": "chatcmpl-f0a45ac3f5f04e80aad66500c9be45fb", "object": "chat.completion.chunk", "created": 1703783102, "model": "gpt-4", "choices": [{"index": 0, "delta": {"content": "?"}, "finish_reason": null}]}\n\ndata: [DONE]\n\n'

可以发现相对于 pandoraNext 的接口,少了第一行关于 "choices":[{"delta":{"role":"assistant"},"index":0,"finish_reason":null}] 的响应,和最后一行关于 "choices":[{"delta":{},"index":0,"finish_reason":"stop"}] 的响应,在某些平台可能出错。

感谢大佬支持了bot模式。不过有一个疑问

在让机器人画图且用gpt-4-mobile模型的情况下,他返回的消息已经不带图片的upload地址了,可否设置如果是画图upload的地址继续保留,而search的链接来源删除了。

返回的消息如:

{"size":"1024x1024","prompt":"A festive greeting card for the Winter Solstice. The card features a serene winter landscape with snow-covered trees and a small, cozy cottage with smoke rising from its chimney. In the foreground, a family of snowmen stands, wearing scarves and hats, symbolizing warmth and togetherness. The sky is clear and starry, suggesting a peaceful winter night. The words 'Happy Winter Solstice' are elegantly written at the top of the card in a decorative font, with a touch of glitter to make the text stand out. The overall tone is warm, inviting, and celebratory, capturing the spirit of the Winter Solstice."}

Here is a festive greeting card created for the Winter Solstice. I hope it captures the warmth and celebratory spirit of the occasion!


希望保留图片生成地址/文档地址

风控最近收紧了?

2024-01-19 03:06:54 2024-01-18 19:06:54,820 [DEBUG] - message 为空: data_json: {'message': None, 'conversation_id': 'fee775d8-423e-4260-8cf2-bf9bf2c0826d', 'error': 'Our systems have detected unusual activity from your system. Please try again later.'}
2024-01-19 03:06:54 2024-01-18 19:06:54,822 [ERROR] - Exception: 'NoneType' object has no attribute 'get'
2024-01-19 03:06:54 2024-01-18 19:06:54,823 [INFO] - 会话结束
2024-01-19 03:06:54 2024-01-18 19:06:54,824 [INFO] - 完整消息:
2024-01-19 03:06:54 2024-01-18 19:06:54,826 [DEBUG] - 会话结束-外层
2024-01-19 03:06:55 2024-01-18 19:06:55,821 [DEBUG] - 接受到停止信号,停止保活线程
这估计就是真风控了

对于gpt-4-mobile的画图功能,返回的是prompt 英文文字+图案地址,如何跟官方画图api保持一致只返回图片地址?

因为接入微信机器人,如果是这样的话机器人返回的不直接是图片。如:

我发送消息:画一个可爱的小恐龙

机器人回复:

{"prompt":"A cute cartoon dinosaur, with bright green scales and big, expressive eyes. It has a friendly smile, small arms, and a long tail. The dinosaur stands in a playful pose in a lush, colorful prehistoric landscape with ferns and prehistoric plants. The sky is clear and blue. The scene exudes a cheerful and child-friendly atmosphere.","size":"1024x1024"}

image
下载链接
Here's the illustration of a cute cartoon dinosaur that I created for you!

如果plus掉了之后,使用gpt-4-mobile模型会默认转向gpt-3.5

前几天刷过几个team上车号,最近陆陆续续掉了

掉了之后发现,如果再次请求gpt-4-mobile的时候,会自动转向gpt-3.5。如果是一个两个账号还好,很多账号混在一起时,如使用oneapi转发,有plus有非plus,其调用就很随机,是否可以加一个逻辑:如果没有gpt-4-mobile的时候,返回错误。

这种情况不只是在bug号上,在那些到期时间不一样的共享号上一样有可能出现。

希望大佬考虑一下,感谢!

哪些地方可以用内网地址

我的理解是用户不需要访问潘多拉,能访问这个项目api就好了。潘多拉甚至可以不放公网只内网让这个调用 但是看说明都是公网地址 有点奇怪 哪些可以填内网 这样延迟也低点。

关于need_delete_conversation_after_response

我设置了false后想看看记录长啥样,我用的微信机器人

然后我跟机器人发了两次指令(间隔1分钟不到)结果在pandora web ui里面显示是两个new chat。
第一个是第一句对话。第二个chat是有两句对话。也就意味着这样子的话是重复了第一句对话?这样对于额度的消耗是否不断重复了?不知道是机器人设置的问题还是。。

image image

无法使用gpt-4-s或mobile

在Pandoranext都正常;
但在PandoraToV1Api中,gpt-3.5-turbo可正常使用,而无法使用gpt-4。

日志
api_key: fk-xxxxxxxxxxxxx
model: gpt-4-mobile
content_type: text
last_content_type: None
content_type: text
last_content_type: None
content_type: text
last_content_type: None
content_type: text
last_content_type: None
message 为空: data_json: {'message': None, 'conversation_id': 'xxxxxxxxxxxxx', 'error': 'Our systems have detected unusual activity from your system. Please try again later.'}
172.20.0.5 - - [16/Dec/2023:07:22:11 +0000] "POST /v1/chat/completions HTTP/1.1" 200 0 "-" "Go-http-client/1.1"
[2023-12-16 07:22:11 +0000] [11] [ERROR] Error handling request /v1/chat/completions
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/gthread.py", line 282, in handle
keepalive = self.handle_request(req, conn)
File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/gthread.py", line 339, in handle_request
for item in respiter:
File "/usr/local/lib/python3.9/site-packages/werkzeug/wsgi.py", line 256, in next
return self._next()
File "/usr/local/lib/python3.9/site-packages/werkzeug/wrappers/response.py", line 32, in _iter_encoded
for item in iterable:
File "/app/main.py", line 417, in generate
message_status = message.get("status")
AttributeError: 'NoneType' object has no attribute 'get'
172.20.0.5 - - [16/Dec/2023:07:22:11 +0000] "POST /v1/chat/completions HTTP/1.1" 500 0 "-" "-"

请教下关于上下文的问题

大佬你好,我使用l微信机器人,微信机器人项目地址为:https://github.com/zhayujie/chatgpt-on-wechat/tree/master,
我想请问下的是我设置了该项目中在群聊中开启同一个会话然后保证上下文,但是实际过程中,他会打开多个窗口进行提问,如下所示,
image
我的config.json如下:

{
    "log_level": "ERROR",
    "need_log_to_file": "true",
    "process_workers": 2,
    "process_threads": 2,
    "pandora_base_url": "http://10.0.8.8:8181",
    "pandora_api_prefix": "tokensTool01",
    "backend_container_url": "http://10.0.8.8:50011",
    "backend_container_api_prefix": "",
    "key_for_gpts_info": "fk-***",
    "gpt_4_s_new_name": "gpt-4-s,gpt-4",
    "gpt_4_mobile_new_name": "gpt-4-mobile,dall-e-3",
    "gpt_3_5_new_name": "gpt-3.5-turbo",
    "need_delete_conversation_after_response": "false",
    "use_oaiusercontent_url": "false",
    "use_pandora_file_server": "true",
    "custom_arkose_url": "false",
    "arkose_urls": "",
    "dalle_prompt_prefix": "请严格根据我的以下要求完成绘图任务,如果我没有发出指定的绘画指令,则绘制出我发出的文字对应的图片:",
    "bot_mode": {
        "enabled": "true",
        "enabled_markdown_image_output": "true",
        "enabled_plain_image_url_output": "true",
        "enabled_bing_reference_output": "false",
        "enabled_plugin_output": "false"
    }
}

我在微信项目中的配置地址为http://10.0.8.8:50011/v1,传入的model名称为gpt-4,是可以调用的,但是同一个群聊会一直新增窗口,想知道是不是哪里配置不对导致没有在同一个会话窗口中

请教一个问题

这个可以支持tool calls吗?现在用不了类似lobechat那样的插件

Dalle-3回复格式问题

官方格式:

{
    "created": 1704003120,
    "data": [
        {
            "revised_prompt": "A depiction of a baby sea otter exuding cuteness as it floats on its back on the surface of a calm sea. Its fur is rich and brown, tiny paws are playfully poised in the air as if reaching for an imaginary plaything. The otter's round, innocent eyes are wide with curiosity and a hint of mirth, its small nose twitching slightly. The sun casts a warm glow on the scene, illuminating the rippling water around the otter and giving its fur a shiny, wet look.",
            "url": "xxx"
        }
    ]
}

ToV1Api回复格式:

{
    "created": 1704003006,
    "data": [
        {
            "url": "xxx"
        }
    ],
    "reply": "\n```\n{\"size\":\"1024x1024\",\"prompt\":\"A cute baby sea otter floating on its back in calm blue water. The sea otter has fluffy brown fur, big curious eyes, and is holding a small starfish in its tiny paws. The sunlight is gently reflecting off the water, creating a peaceful and serene atmosphere.\"}Here is the image of a cute baby sea otter floating on its back in calm blue water, holding a small starfish."
}

希望匹配官方格式,以兼容更多客户端(如opencat使用目前的格式会报错)

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

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

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.