Coder Social home page Coder Social logo

tbxark / chatgpt-telegram-workers Goto Github PK

View Code? Open in Web Editor NEW
3.2K 27.0 780.0 1.4 MB

Deploy your own Telegram ChatGPT bot on Cloudflare Workers with ease.

Home Page: https://t.me/ChatGPT_Telegram_Workers

License: MIT License

JavaScript 98.99% Makefile 0.71% Dockerfile 0.30%
chatgpt cloudflare-workers telegram telegram-bot bot gpt vercel serverless

chatgpt-telegram-workers's Introduction

ChatGPT-Telegram-Workers


English | 中文

Deploy your own Telegram ChatGPT bot on Cloudflare Workers with ease.

About

The simplest and fastest way to deploy your own ChatGPT Telegram bot. Use Cloudflare Workers, single file, copy and paste directly, no dependencies required, no need to configure local development environment, no domain name required, serverless.

You can customize the system initialization information so that your debugged personality never disappears.

example image

Features

  • Serverless deployment
  • Support for multiple Telegram bots
  • Support for multiple OpenAI keys
  • Support for Azure OpenAI Service
  • Support for Cloudflare AI (free)
  • Support for streaming output
  • Support for custom roles
  • Support for multiple platforms deployment

Documentation

Special thanks

https://www.jetbrains.com/?from=tbxark

Thanks for the open-source development license provided by JetBrains.

Contributors

This project exists thanks to all the people who contribute. Contribute.

License

ChatGPT-Telegram-Workers is released under the MIT license. See LICENSE for details.

chatgpt-telegram-workers's People

Contributors

anotiawang avatar cheivin avatar ffffourwood avatar linking123 avatar miraclexyz avatar panmax avatar silentely avatar tbxark avatar xin053 avatar

Stargazers

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

Watchers

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

chatgpt-telegram-workers's Issues

实时数据流传输

telegram机器人能否通过ChatGPT API SSE,实现实时数据流传输,就像网页版那样的效果。quora的poe这个软件就可以,而且响应速度极快

请教一下,为什么KV里会保存完整的聊天记录?

根据openai的官方POST示例,有chatid,应该没必要保存吧。
而且如果bot没有重新发送历史消息的功能,那么我认为甚至都不需要保存任何聊天记录,只需要保存chatid和userid的关系就行了。
难道chatGPT记忆上下文的智能是通过一次性提交全部聊天记录实现的?

/env 会不安全输出

if (pathname.startsWith(/env)) {
//return new Response(JSON.stringify(ENV), { status: 200 });
}

关于群组中的 `SYSTEM_INIT_MESSAGE`

现在在群组中使用 bot,SYSTEM_INIT_MESSAGE好像还是根据发送/new命令的人而定的,请问能否在 GROUP_CHAT_BOT_SHARE_MODE 选项开启时,将 SYSTEM_INIT_MESSAGE 的设置改为视群组而定。

是否考虑更换 GPT-3.5 model?

代码中目前定义的是 gpt-3.5-turbo,是否考虑更新为 gpt-3.5-turbo-0301,甚至开放用户通过 Variable 自定义?

新代码报错

拆分后的新代码报错
[{"ok":false,"error_code":404,"description":"Not Found"}]

换回旧版无问题
[{"ok":true,"result":true,"description":"Webhook was set"}]

变量值怎么写

GROUP_CHAT_BOT_ENABLE

这个变量怎么填啊? true还是enable? 请详细加进说明啊 感谢

消息过长, 建议拆分

比如 bot 回答一个超长回复, 由于 tg 的限制, 消息会被截断. 建议对消息进行拆分回复, 比如:

async function sendMessageToTelegram(message, token, context) {
  // 每1000字符进行拆分
  if (message.length > 1000) {
    let msgArray = message.match(/.{1,1000}/g);
    for (let msg of msgArray) {
      await sendMessageToTelegram(msg, token, context)
    }
    return;
  }
  return await fetch(`https://api.telegram.org/bot${token || TELEGRAM_TOKEN}/sendMessage`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      ...(context || CURRENR_CHAT_CONTEXT),
      text: message,
    }),
  });
}

上面仅是测试代码, 没有考虑到由于切分字符导致 markdown 样式变化.

OpenAI API 错误是哪里问题。。

一开始跑起来正常
后面在TG试了下OPENAI_API_EXTRA_PARAMS,结果就一直回
OpenAI API 错误

Unrecognized request arguments supplied: 0, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 3, 4, 5, 6, 7, 8, 9}
如何破。。。
重新部署也是一直这样
感谢

小白请教,怎么更新到新版?

首先感谢作者开发这么好的应用。
小白来部署也特别方便。
现在有两个疑问 请大佬指教
1.怎样更新到新版
我是在安卓手机上的谷歌浏览器里操作,更新的时候是需要把代码 在编辑框里复制 然后重新部署吗 我是这样操作的 但是发现不能全选删除旧的代码 多行代码只能一行一行删除 太麻烦了 所以我就重新建了一个服务 变量又重新填写了一遍

  1. 部署成功后可以正常使用 但是出现了如下的提示 请问怎么回事呢 再次感谢

Webhook: {"ok":true,"result":true,"description":"Webhook is already set"}

Command: {"ok":true,"result":true}

Delete this route after binding
if (pathname.startsWith(/init)) {
return bindWebHookAction(request);
}

`OPENAI_API_EXTRA_PARAMS` 设置有误

使用命令 SETENV OPENAI_API_EXTRA_PARAMS={"temperature": 0.5} 时,最终发给 chatgpt api 的请求中会多一段乱码,类似于

{"0":"{","1":"\"","2":"t","3":"e","4":"m","5":"p","6":"e","7":"r","8":"a","9":"t","10":"u","11":"r","12":"e","13":"\"","14":":","15":" ","16":"0","17":".","18":"5","19":"}"

导致 chatgpt api 报错。

没有授权怎么解决

"webhook":{"ok":false,"error_code":401,"description":"Unauthorized"},"command":{"ok":false,"error_code":401,"description":"Unauthorized"}

当消息中包含图片或 sticker 时持续报错

当消息中包含图片或 sticker 时持续报错,报错内容:

我不知道该怎么回答
>Cannot read properties of undefined (reading '0')}

该报错会持续到用命令 /new 重置对话。

群内怎样配置 /setenv SYSTEM_INIT_MESSAGE

/setenv SYSTEM_INIT_MESSAGE="现在开始是喵娘,每句话已喵结尾。"
群里我用了这个 出现下边的,该怎么办?

说了更新成功。 但是仍然没有变化?是不是群设置有什么特别?

绑定 Telegram 404 错误

按照第六步操作最后提示了 [{"ok":false,"error_code":404,"description":"Not Found"}] 错误。

已经检查过 Variables 的各种配置,确认 Https:// 的域名。相关截图如下,感谢。

image

image

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.