GithubHelp home page GithubHelp logo

scmanjarrez / edgegpt-telegram-bot Goto Github PK

View Code? Open in Web Editor NEW
62.0 6.0 22.0 194 KB

Telegram bot using EdgeGPT unofficial API

License: MIT License

Python 99.70% Dockerfile 0.30%
bing bing-chat chatgpt edgegpt microsoft openai python-telegram-bot python3 telegram-bot

edgegpt-telegram-bot's Introduction

Project archived to due so many errors on EdgeGPT (archived) that won't be fixed

Description

Telegram bot using EdgeGPT unofficial API

What can I do?

  • Access to Bing Chat without leaving your lovely messaging app!
  • Change Bing Chat conversation styles

    Do you want an original and imaginative response? (Creative style powered by gpt4) Or more informative and friendly? What about a more concise and straightforward answer?

  • Start multiple conversations and switch between them
  • Generate Images using Bing (powered by Dall-E)
  • Text-to-speech responses (powered by edge-tts)
  • Accept voice messages instead of text messages

    Automatic-Speech-Recognition powered by AssemblyAI or Whisper (OpenAI)

  • Configuration/cookie file download and update from the bot
  • Restart the bot from your chat
  • Inline queries to ask for questions or generate images

    You can continue conversations from your private chat

  • Enqueue queries. The bot will process each question in order
  • Multi cookie management, stop hitting the daily limit!
  • Permanent chat history (Recent activity in Bing)
  • Export conversations

Content:

Requirements

  • python
  • git
  • ffmpeg (only if you are using whisper)

Bot commands

Commands available to every user are set automatically. However, there are some commands that are hidden:

/unlock <passwd> - Unlock bot functionalities with a password

Be careful with /history_update. History will be recreated, removing ownership and moving the ownsership to admin1 (if multiple admins are present, to the first one)

In order to use inline queries, you need to enable them in @BotFather. For ease of use, use the placeholder

type text

Type can be query or image.

Run

  • Install python dependencies.

    $ pip install -r requirements.txt

    If you want to contribute, install development dependencies as well.

    $ pip install -r dev_requirements.txt
  • Create a self-signed certificate in order to communicate with telegram server using SSL.

    $ openssl req -newkey rsa:2048 -sha256 -nodes -keyout config/nginx.key -x509 -days 3650 -out config/nginx.pem
  • Create a directory named config to store bot configuration files. Copy templates/config.json to config directory. Change values according to your configuration.

    $ mkdir config
    $ cp templates/config.json config/config.json

    config.json:

    • settings:

      • token - Telegram bot token, obtained from @BotFather.

      • webhook: true to run the bot using webhooks. false to use polling.

      • log_level: set level of the logging module.

      • ip: Your server/home IP. Must be accessible from internet.

      • port: Port to receive telegram updates. Allowed ports: 443, 80, 88 and 8443

        Nginx can be used as a reverse proxy in order to use other ports. Copy templates/nginx.conf to config and change values according to your configuration.

        • <docker-host-ip> is the gateway of the container. Similar to 172.17.0.1
        • <portX> Can be any port in the user range.
        $ cp templates/nginx.conf config/nginx.con
        $ docker run --rm --name nginx --net host -v ./config/nginx.conf:/etc/nginx/nginx.conf:ro -v ./config/nginx.key:/etc/nginx/nginx.key:ro -v ./config/nginx.pem:/etc/nginx/nginx.pem:ro nginx
      • cert: Path to your server certificate (can be self-signed).

        Warning: If you're using a verified certificate, you may receive "certificate verify failed" error. Leave cert path empty in your config.json

    • apis:

      • openai: OpenAI token to use with whisper (ASR), chatgpt/chatgpt4 and Dall-E (image generation).
      • assemblyai: AssemblyAI token (ASR).
    • chats:

      • password: Password to use with /unlock and gain access to the bot (only required for the first time).

        "password": "supersecurepassword123"
      • id: List of telegram IDs allowed in the bot, without password. Obtain if from bots like @getmyid_bot.

        "id": [
            123123123,
            132322322
        ]
      • admin: List of telegram IDs allowed retrieve and update configuration files, i.e. config.json, cookies.json.

        "admin": [
            123123123
        ]
      • 🆕 remove_chats_on_stop: true/false delete/keep chats after bot stop/restart (⚠️ WARNING ⚠️: chats retrieved from Bing with /history_update will be deleted as well if you enable this feature).

      • 🆕 history: true/false to enable/disable chat history.

    • cookies: List of file paths to cookies

      "cookies": [
          "config/cookies.json",
          "config/cookies2.json"
      ]
  • Run the bot.

    $ chmod +x src/edge.py
    $ src/edge.py

    Note: If you run the bot in port 80, it may be needed to run the bot as superuser (sudo)

Docker

Manual build

Build the image and bind config directory in the container.

$ docker build . -t edgegpt-telegram-bot --rm
$ docker run -d -it --name edgegpt -v ./config:/edgegpt/config edgegpt-telegram-bot

Dockerhub image

$ docker run -d -it --name edgegpt -v ./config:/edgegpt/config scmanjarrez/edgegpt-telegram-bot

docker-compose.yml file provided.

$ docker compose up -d

Contributing

Happy to see you willing to make the project better. In order to make a contribution, please respect the following format:

  • Sort imports with usort.

    $ usort format *py
  • Format your code using black (line length 79).

    $ black -l 79 *py

    If you are using flake8, add E203 to .flake8 ignore list

    [flake8]
    extend-ignore = E203
    

Pre-commit hooks

Installation

$ pre-commit install

Manual execution

$ pre-commit run --all-files

VSCode project settings

VSCode should have the following settings in settings.json:

{
    "python.analysis.fixAll": [],
    "python.formatting.blackArgs": [
        "-l 79"
    ],
    "python.formatting.provider": "black",
    "isort.path": [
        "usort format"
    ],
}

If you use flake8, add:

"python.linting.flake8Args": [
    "--ignore=E203",
],

Contributors

Support me

You find this bot helpful and want to support me?

Ko-fi link to support me

License

Copyright (c) 2023 scmanjarrez. All rights reserved.
This work is licensed under the terms of the MIT license.

For a copy, see LICENSE.

edgegpt-telegram-bot's People

Contributors

dependabot[bot] avatar eikosa avatar github-actions[bot] avatar hdcola avatar peterdavehello avatar scmanjarrez avatar shrirajhegde avatar soyelmismo 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

edgegpt-telegram-bot's Issues

can't answer

edgebot_1 | Traceback (most recent call last):
edgebot_1 | File "/usr/local/lib/python3.10/site-packages/telegram/ext/_application.py", line 1104, in process_update
edgebot_1 | await coroutine
edgebot_1 | File "/usr/local/lib/python3.10/site-packages/telegram/ext/_handler.py", line 141, in handle_update
edgebot_1 | return await self.callback(update, context)
edgebot_1 | File "/edgebot/edge.py", line 70, in message
edgebot_1 | await query.run()
edgebot_1 | File "/edgebot/utils.py", line 189, in run
edgebot_1 | self._response = await CONV[cid(self.update)].ask(self.text)
edgebot_1 | File "/usr/local/lib/python3.10/site-packages/EdgeGPT.py", line 241, in ask
edgebot_1 | async for final, response in self.chat_hub.ask_stream(prompt=prompt):
edgebot_1 | File "/usr/local/lib/python3.10/site-packages/EdgeGPT.py", line 208, in ask_stream
edgebot_1 | yield False, response["arguments"][0]["messages"][0][
edgebot_1 | KeyError: 'messages'

[Request] Enabling infinite context window for bot conversations

Is your feature request related to a problem? Please describe.

It is frustrating when the bot doesn't remember old conversation thread, because we are in a new thread.

Describe the solution you'd like

Essentially the answer to that is embedding.

  • We need to embed every Q&A pair as a vector
  • Store the vector in a free pinecone DB
  • When a new question is asked, embed the question and query pinecone for similar questions
  • Pass the previous conversation as a context to the prompt
  • when the answer is received, embed it and store it in pinecone again

Describe alternatives you've considered

  • pinecone alternative is supabase which also has a generous free tier
  • but still feels like everyone else is using pinecone nowadays, so why not!

Additional context

I see a lot of good development is happening in this project and I have some experience in doing embedding, so thought it would be a good suggestion for a new feature. I am sure everyone will love to have longer context windows automatically, with option for incognito mode if required.

Now obviously, every model has their defined max input length, so the context needs to be checked and only anything which can fit into the context can be added.

OpenAI ada-embedding-02 is pretty cheap so I see no issues in using it for personal scale projects with free tier pinecone.

Continuously creating new conversation

The problem

image

Sometimes it generates conversation continuously

Version of python

.

Version of EdgeGPT-Telegram-Bot

latest

Operating system running EdgeGPT-Telegram-Bot

.

Running on your machine? Running on docker?

.

Additional information & file uploads

No response

[Request] Support more than one cookie

Is your feature request related to a problem? Please describe.

I would like to add multiple cookies to prevent reaching the quota, it would be great if this feature was available.

Describe the solution you'd like

Ability to add cookies for multiple accounts

Describe alternatives you've considered

No response

Additional context

No response

Unable to figure out how and where cookies.json needs to be stored

The problem

python src/edge.py --debug
2023-03-19 15:05:07,094 - apscheduler.scheduler - INFO - Scheduler started
2023-03-19 15:05:07,095 - telegram.ext._application - INFO - Application started

and nothing there after. I am presuming I did not set up cookies.json correctly as there was no instruction about it.

Version of Edge-GPT-Telegram-Bot

edge-gpt-telegram-bot v0.1.0

Operating system running Edge-GPT-Telegram-Bot

Linux

Running on your machine? Running on docker?

VM in GCP

Additional information & file uploads

No response

"SSL error {error:0A000086:SSL routines::certificate verify failed}" when I used a verified certificate with a trusted root CA

The problem

  1. When I used a verified certificate with a trusted root CA, the bot can not verified, open "https://api.telegram.org/bot/getWebhookinfo" showed that
    "ok":true,"result":{"url":"https://url/","has_custom_certificate":true,"pending_update_count":2,"last_error_date":1680013752,"last_error_message":"SSL error {error:0A000086:SSL routines::certificate verify failed}","max_connections":40,"ip_address":"VPS_ip"}}
    This problem occurs regardless of whether I use nginx reverse proxy.
  2. When I visit https://url:port/:, the web page shows <title>405: Method Not Allowed</title>405: Method Not Allowed,the same error was showed on terminal :

2023-03-28 14:45:20,844 - telegram.ext._utils.webhookhandler - DEBUG - 127.0.0.1 - Exception in TelegramHandler
Traceback (most recent call last):
File "/home/ubuntu/miniconda3/envs/edge/lib/python3.10/site-packages/tornado/web.py", line 1672, in _execute
raise HTTPError(405)
tornado.web.HTTPError: HTTP 405: Method Not Allowed

Version of python

Python 3.10.9

Version of EdgeGPT-Telegram-Bot

edge-gpt-telegram-bot v0.1.3

Operating system running EdgeGPT-Telegram-Bot

Ubuntu 22.04

Running on your machine? Running on docker?

machine

Additional information & file uploads

2023-03-28 14:30:12,117 - hpack.hpack - DEBUG - Decoded 28, consumed 1 bytes
2023-03-28 14:30:12,117 - hpack.hpack - DEBUG - Decoded 2, consumed 1 bytes
2023-03-28 14:30:12,118 - hpack.hpack - DEBUG - Decoded (b'content-length', <memory at 0x7f03c6a64e80>), total consumed 4 bytes, indexed True
2023-03-28 14:30:12,118 - hpack.hpack - DEBUG - Decoded 17, consumed 1 bytes
2023-03-28 14:30:12,118 - hpack.hpack - DEBUG - Decoded 32, consumed 1 bytes
2023-03-28 14:30:12,118 - hpack.hpack - DEBUG - Decoded (b'strict-transport-security', b'max-age=31536000; includeSubDomains; preload'), total consumed 52 bytes, indexed False
2023-03-28 14:30:12,118 - hpack.hpack - DEBUG - Decoded 19, consumed 1 bytes
2023-03-28 14:30:12,118 - hpack.hpack - DEBUG - Decoded 1, consumed 1 bytes
2023-03-28 14:30:12,118 - hpack.hpack - DEBUG - Decoded (b'access-control-allow-origin', <memory at 0x7f03c6a64c40>), total consumed 23 bytes, indexed False
2023-03-28 14:30:12,118 - hpack.hpack - DEBUG - Decoded 20, consumed 1 bytes
2023-03-28 14:30:12,119 - hpack.hpack - DEBUG - Decoded 16, consumed 1 bytes
2023-03-28 14:30:12,119 - hpack.hpack - DEBUG - Decoded (b'access-control-allow-methods', b'GET, POST, OPTIONS'), total consumed 39 bytes, indexed False
2023-03-28 14:30:12,119 - hpack.hpack - DEBUG - Decoded 20, consumed 1 bytes
2023-03-28 14:30:12,119 - hpack.hpack - DEBUG - Decoded 37, consumed 1 bytes
2023-03-28 14:30:12,119 - hpack.hpack - DEBUG - Decoded (b'access-control-expose-headers', b'Content-Length,Content-Type,Date,Server,Connection'), total consumed 60 bytes, indexed False
2023-03-28 14:30:12,120 - httpx._client - DEBUG - HTTP Request: POST https://api.telegram.org/bot/setWebhook "HTTP/2 200 OK"
2023-03-28 14:30:12,121 - telegram._bot - DEBUG - True
2023-03-28 14:30:12,121 - telegram._bot - DEBUG - Exiting: set_webhook
2023-03-28 14:30:12,130 - telegram.ext._utils.webhookhandler - DEBUG - Webhook Server started.
2023-03-28 14:30:12,130 - telegram.ext._updater - DEBUG - Waiting for webhook server to start
2023-03-28 14:30:12,130 - telegram.ext._updater - DEBUG - Webhook server started
2023-03-28 14:30:12,131 - apscheduler.scheduler - INFO - Scheduler started
2023-03-28 14:30:12,131 - telegram.ext._application - DEBUG - JobQueue started
2023-03-28 14:30:12,131 - telegram.ext._application - INFO - Application started
2023-03-28 14:30:12,131 - apscheduler.scheduler - DEBUG - Looking for jobs to run
2023-03-28 14:30:12,131 - apscheduler.scheduler - DEBUG - No jobs; waiting until a job is added

[Request] Edit with markdown as it type

Is your feature request related to a problem? Please describe.

I think it would be nice if bing used the current markdowns it writes at the same time it writes

Describe the solution you'd like

.

Describe alternatives you've considered

No response

Additional context

No response

[Request] Option for chat history

Is your feature request related to a problem? Please describe.

Sometimes I don't want my conversations to be saved in the history, maybe a feature can be added to the settings for this, so that you can talk without saving like in older versions.

Describe the solution you'd like

.

Describe alternatives you've considered

No response

Additional context

No response

Bot responds to the reaction to a reply (from another user) in Groups

The problem

Identical to #23, But with reactions.

Reacting instead of the reply triggers the bot.


Version of python

Python 3.10.9

Version of EdgeGPT-Telegram-Bot

edge-gpt-telegram-bot v0.1.3

Operating system running EdgeGPT-Telegram-Bot

Linux

Running on your machine? Running on docker?

No

Additional information & file uploads

No response

Does not finish the message. No markup markdown

The problem

  1. Sent a big request to write code
  2. The bot started writing and eventually stopped, apparently on limiting the size of the telegram messages

Version of python

3.10

Version of EdgeGPT-Telegram-Bot

latest from docker hub

Operating system running EdgeGPT-Telegram-Bot

ubuntu

Running on your machine? Running on docker?

Docker

Additional information & file uploads

image

The bot refused to finish typing the message on a long request, and the markdown markup is not observed

send /new /voice command response EdgeGPT API not available. Try again later.

The problem

image

2023-03-16 23:19:23,854 - EdgeGPT - ERROR - Authentication failed. You have not been accepted into the beta.

Version of Edge-GPT-Telegram-Bot

edge-gpt-telegram-bot v0.1.0

Operating system running Edge-GPT-Telegram-Bot

MacOS Linux

Running on your machine? Running on docker?

machine and docker

Additional information & file uploads

No response

[Request] Stream messages

Is your feature request related to a problem? Please describe.

I think it would be very nice if the bot edits the message as it streams the message

Describe the solution you'd like

For example:
Hel...
Hello w...
Hello world

Describe alternatives you've considered

No response

Additional context

No response

[Request] Buttons disappear when pressed

Is your feature request related to a problem? Please describe.

I think it would be nice if the suggestion buttons don't disappear when you press them, because sometimes there are a few buttons that interest me and I have to type them manually

Describe the solution you'd like

.

Describe alternatives you've considered

No response

Additional context

No response

[Request] Split message

Is your feature request related to a problem? Please describe.

If a message is longer than 4096 characters (I don't know if this is the case), split it into two messages

Describe the solution you'd like

.

Describe alternatives you've considered

No response

Additional context

No response

[Request]Upgrade EdgeGPT to support image generation

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

The new version of EdgeGPT already supports bing image generation, and I hope to support this feature by updating EdgeGPT. At the same time, if the program fails to reply to the message after updating EdgeGPT to the latest version

Describe alternatives you've considered

No response

Additional context

No response

[Request] Permenant Message history feature

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

Having a message history like in chat gpt so that I can continue from where I left off in the past chat, I have observed that when i reset the bot, all history disappears. see also this group, when you quote bot messages, it responds with the next dialog (https://t.me/LLMchat) such a feature can be added.

Describe alternatives you've considered

No response

Additional context

No response

Bot responds to the reply to a reply (from another user) in Groups

The problem

  1. Add the bot to a group
  2. Start a conversation, "When is the sunset in Stockholm"
  3. Reply to "When is the sunset in Stockholm" (Maybe a different user)
    (Telegram sends message to the bot even if the group messages are not accessible to it)
  4. Bot responds to a reply to a message not from the bot.

Possible fix: Make sure that message.reply_to_message.from_user is the bot

Version of Edge-GPT-Telegram-Bot

b6acab4 (version string not upto date -

"--version", action="version", version="%(prog)s v0.1.0"
)

Operating system running Edge-GPT-Telegram-Bot

Linux

Running on your machine? Running on docker?

On Machine

Additional information & file uploads

Not relevant

Whisper issue

The problem

If i try to use whisper for voice recognition i got this error

2023-04-28 21:50:46,605 - telegram.ext._application - ERROR - No error handlers are registered, logging exception. Traceback (most recent call last): File "C:\Users\feuer\AppData\Roaming\Python\Python311\site-packages\telegram\ext\_application.py", line 1104, in process_update await coroutine File "C:\Users\feuer\AppData\Roaming\Python\Python311\site-packages\telegram\ext\_handler.py", line 141, in handle_update return await self.callback(update, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\AIStuff\EdgeGPT-Telegram-Bot\src\cmds.py", line 433, in voice transcription = await backend.automatic_speech_recognition( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\AIStuff\EdgeGPT-Telegram-Bot\src\backend.py", line 268, in automatic_speech_recognition return await asr_whisper(fid, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\AIStuff\EdgeGPT-Telegram-Bot\src\backend.py", line 318, in asr_whisper with inp.open("wb") as f: ^^^^^^^^^^^^^^ File "C:\Python311\Lib\pathlib.py", line 1044, in open return io.open(self, mode, buffering, encoding, errors, newline) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '\\tmp\\AwACAgIAAxkBAAPJZEwVhj8r2A_D6StRBc90KJvEV7cAAlQrAAL68GFKdaiIir4MpzQvBA.oga'

Version of python

3.11.2

Version of EdgeGPT-Telegram-Bot

edge-gpt-telegram-bot v1.0.0 - 00006c5 (git)

Operating system running EdgeGPT-Telegram-Bot

Windows

Running on your machine? Running on docker?

Local machine

Additional information & file uploads

No response

Captcha Error, how to solve?

The problem

2023-05-18 18:31:33,817 - EdgeGPT - ERROR - User needs to solve CAPTCHA to continue.

Version of python

Python 3.11.3

Version of EdgeGPT-Telegram-Bot

edge-gpt-telegram-bot v1.0.2 - d90e118

Operating system running EdgeGPT-Telegram-Bot

ubuntu

Running on your machine? Running on docker?

machine

Additional information & file uploads

No response

The bot ignores Python error messages.

The problem

send message to bot

Traceback (most recent call last):
  File "/home/user/Загрузки/./2.py", line 5, in <module>
    from edge_tts import SpeechSynthesizer
ImportError: cannot import name 'SpeechSynthesizer' from 'edge_tts' (/home/user/.local/lib/python3.11/site-packages/edge_tts/__init__.py)

got ignore and logs

Can't parse entities: unsupported start tag "module" at byte offset 103

мая 26 02:04:58 oracle1 python3[2746556]: 2023-05-26 02:04:58,773 - asyncio - ERROR - Task exception was never retrieved
мая 26 02:04:58 oracle1 python3[2746556]: future: <Task finished name='Task-432' coro=<BingAI.run() done, defined at /home/ubuntu/tb_edge/EdgeGPT-Telegram-Bot/src/backend.py:64> exception=BadRequest('Can't parse entities: unsupported start tag "module" at byte offset 103')>
мая 26 02:04:58 oracle1 python3[2746556]: Traceback (most recent call last):
мая 26 02:04:58 oracle1 python3[2746556]:   File "/home/ubuntu/tb_edge/EdgeGPT-Telegram-Bot/src/backend.py", line 68, in run
мая 26 02:04:58 oracle1 python3[2746556]:     self.edit = await ut.send(self.update, f"<b>You</b>: {self.text}")
мая 26 02:04:58 oracle1 python3[2746556]:   File "/home/ubuntu/tb_edge/EdgeGPT-Telegram-Bot/src/utils.py", line 208, in send
мая 26 02:04:58 oracle1 python3[2746556]:     return await message.reply_html(
мая 26 02:04:58 oracle1 python3[2746556]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/telegram/_message.py", line 1225, in reply_html
мая 26 02:04:58 oracle1 python3[2746556]:     return await self.get_bot().send_message(
мая 26 02:04:58 oracle1 python3[2746556]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/telegram/ext/_extbot.py", line 2598, in send_message
мая 26 02:04:58 oracle1 python3[2746556]:     return await super().send_message(
мая 26 02:04:58 oracle1 python3[2746556]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/telegram/_bot.py", line 331, in decorator
мая 26 02:04:58 oracle1 python3[2746556]:     result = await func(*args, **kwargs)  # skipcq: PYL-E1102
мая 26 02:04:58 oracle1 python3[2746556]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/telegram/_bot.py", line 760, in send_message
мая 26 02:04:58 oracle1 python3[2746556]:     return await self._send_message(
мая 26 02:04:58 oracle1 python3[2746556]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/telegram/ext/_extbot.py", line 488, in _send_message
мая 26 02:04:58 oracle1 python3[2746556]:     result = await super()._send_message(
мая 26 02:04:58 oracle1 python3[2746556]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/telegram/_bot.py", line 512, in _send_message
мая 26 02:04:58 oracle1 python3[2746556]:     result = await self._post(
мая 26 02:04:58 oracle1 python3[2746556]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/telegram/_bot.py", line 419, in _post
мая 26 02:04:58 oracle1 python3[2746556]:     return await self._do_post(
мая 26 02:04:58 oracle1 python3[2746556]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/telegram/ext/_extbot.py", line 306, in _do_post
мая 26 02:04:58 oracle1 python3[2746556]:     return await super()._do_post(
мая 26 02:04:58 oracle1 python3[2746556]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/telegram/_bot.py", line 450, in _do_post
мая 26 02:04:58 oracle1 python3[2746556]:     return await request.post(
мая 26 02:04:58 oracle1 python3[2746556]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 165, in post
мая 26 02:04:58 oracle1 python3[2746556]:     result = await self._request_wrapper(
мая 26 02:04:58 oracle1 python3[2746556]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 328, in _request_wrapper
мая 26 02:04:58 oracle1 python3[2746556]:     raise BadRequest(message)
мая 26 02:04:58 oracle1 python3[2746556]: telegram.error.BadRequest: Can't parse entities: unsupported start tag "module" at byte offset 103

Version of python

Python 3.10.6

Version of EdgeGPT-Telegram-Bot

edge-gpt-telegram-bot v1.1.0 - e66ab87 (git)

Operating system running EdgeGPT-Telegram-Bot

Ubuntu 22.04.2 LTS

Running on your machine? Running on docker?

running on vps

Additional information & file uploads

No response

I got a error message

2023-03-02 11:24:53,294 - telegram.ext._application - ERROR - No error handlers are registered, logging exception.
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniconda/base/envs/hddev/lib/python3.10/site-packages/telegram/ext/_application.py", line 1104, in process_update
await coroutine
File "/opt/homebrew/Caskroom/miniconda/base/envs/hddev/lib/python3.10/site-packages/telegram/ext/_handler.py", line 141, in handle_update
return await self.callback(update, context)
File "/Users/hd/work/Edge-GPT-Telegram-Bot/edge.py", line 39, in message
await query.run()
File "/Users/hd/work/Edge-GPT-Telegram-Bot/utils.py", line 163, in run
await self.parse_message(message)
File "/Users/hd/work/Edge-GPT-Telegram-Bot/utils.py", line 205, in parse_message
text = REF.sub(
File "/Users/hd/work/Edge-GPT-Telegram-Bot/utils.py", line 206, in
lambda x: (f""
KeyError: '1'

[Request] console utility for single requests

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

I'm trying to create a utility for making single queries to Bing from the command line. It works, but it's very slow. It takes 40 seconds to get a middle size response. Maybe there's a better way to do this, can you suggest something?"

time ./bingai.py 'list 10 japanese dishes'
There are many delicious Japanese dishes to choose from, but here are 10 examples that you might enjoy:

- **Sushi**: Vinegared rice topped or rolled with raw fish or other ingredients[^4^] [^5^].
- **Tempura**: Battered and fried fish, seafood, or vegetables[^5^].
- **Yakisoba**: Stir-fried noodles with meat and vegetables in a savory sauce[^2^].
- **Yakitori**: Grilled chicken skewers seasoned with salt or sauce[^5^].
- **Tsukemono**: Pickled vegetables or fruits that add color and flavor to a meal[^5^].
- **Ramen**: Noodle soup with various toppings such as sliced pork, boiled egg, seaweed, and green onion[^4^] [^6^].
- **Okonomiyaki**: Savory pancake with cabbage, meat, seafood, cheese, and other ingredients[^4^] [^6^].
- **Gyudon**: Rice bowl topped with thinly sliced beef and onion simmered in a sweet and salty broth[^4^] [^6^].
- **Miso soup**: Soup made with dashi stock and miso paste, usually containing tofu, seaweed, and other ingredients[^4^] [^6^].
- **Kaiseki**: A traditional multi-course meal that showcases seasonal ingredients and culinary techniques[^4^] [^5^].

I hope this list makes you hungry for some Japanese food!😋

________________________________________________________
Executed in   39,69 secs    fish           external
   usr time    1,04 secs  184,00 micros    1,04 secs
   sys time    0,13 secs  155,00 micros    0,13 secs

./bingai.py

#!/usr/bin/env python3


import json
import asyncio
from EdgeGPT import Chatbot, ConversationStyle
import sys


async def main(prompt):
    cookies = json.loads(open("cookies.json", encoding="utf-8").read())
    bot = await Chatbot.create(cookies=cookies)
    r = await bot.ask(prompt=prompt, conversation_style=ConversationStyle.creative)
    await bot.close()
    return r['item']['messages'][1]['text']

if __name__ == "__main__":
    """Usage ./bingai.py 'list 10 japanese dishes'"""
    prompt = sys.argv[1]
    print(asyncio.run(main(prompt)))

Describe alternatives you've considered

No response

Additional context

No response

Drawing Image on Chat

The problem

Prompt: Draw a cat like Louis Wain
If this prompt is typed, bing generates an image so the bot goes into a bug and appears to be typing forever.

Version of python

latest

Version of EdgeGPT-Telegram-Bot

latest

Operating system running EdgeGPT-Telegram-Bot

latest

Running on your machine? Running on docker?

latest

Additional information & file uploads

No response

Error when trying to run

2023-03-06 22:23:15,442 - root - ERROR - .config.json or .cookies.json file missing.

Running on ubuntu with Python 3.7.3
.config.json file already have but not .cookies.json

[Request] Automatically create new converastion

Is your feature request related to a problem? Please describe.

Bing: Thanks for this conversation! I've reached my limit, will you hit “New topic,” please?

Message: 31/30
Conversation ID: E2983D05DD

It would be nice if it automatically opens a new conversation when it say that.

Describe the solution you'd like

.

Describe alternatives you've considered

No response

Additional context

No response

it suddenly stopped typing the message

The problem

image

root@kelime:~/EdgeGPT-Telegram-Bot# sudo python3 src/edge.py 
2023-06-11 21:37:21,985 - apscheduler.scheduler - INFO - Scheduler started
2023-06-11 21:37:21,985 - telegram.ext._application - INFO - Application started
2023-06-11 21:37:27,197 - apscheduler.scheduler - INFO - Scheduler started
2023-06-11 21:37:27,197 - telegram.ext._application - INFO - Application started
2023-06-11 21:38:34,768 - asyncio - ERROR - Task exception was never retrieved
future: <Task finished name='Task-16' coro=<BingAI.run() done, defined at /root/EdgeGPT-Telegram-Bot/src/backend.py:70> exception=KeyError('adaptiveCards')>
Traceback (most recent call last):
  File "/root/EdgeGPT-Telegram-Bot/src/backend.py", line 87, in run
    async for final, resp in ut.CONV["all"][self.cid][cur_conv][
  File "/usr/local/lib/python3.10/dist-packages/EdgeGPT/EdgeGPT.py", line 155, in ask_stream
    async for response in self.chat_hub.ask_stream(
  File "/usr/local/lib/python3.10/dist-packages/EdgeGPT/chathub.py", line 156, in ask_stream
    resp_txt = result_text + response["arguments"][0][
KeyError: 'adaptiveCards'

Version of python

3.10.7

Version of EdgeGPT-Telegram-Bot

latest

Operating system running EdgeGPT-Telegram-Bot

ubuntu

Running on your machine? Running on docker?

.

Additional information & file uploads

No response

Flood control exceeded

The problem

"Flood control exceeded"
To avoid this problem, the editing frequency can be increased or it can be made to wait automatically when this error occurs. Another solution could be to automatically adjust the editing time for long messages. For example, for every first 4 edits, the editing time can increase by 0.4 seconds. 0.4 → 0.8 → 1.2.

Full log:

future: <Task finished name='Task-32' coro=<BingAI.run() done, defined at /root/EdgeGPT-Telegram-Bot/src/backend.py:70> exception=RetryAfter('Flood control exceeded. Retry in 222 seconds')>
Traceback (most recent call last):
  File "/root/EdgeGPT-Telegram-Bot/src/backend.py", line 109, in run
    await ut.edit(self.edit, text)
  File "/root/EdgeGPT-Telegram-Bot/src/utils.py", line 346, in edit
    await update_message.edit_text(
  File "/usr/local/lib/python3.10/dist-packages/telegram/_message.py", line 2526, in edit_text
    return await self.get_bot().edit_message_text(
  File "/usr/local/lib/python3.10/dist-packages/telegram/ext/_extbot.py", line 1482, in edit_message_text
    return await super().edit_message_text(
  File "/usr/local/lib/python3.10/dist-packages/telegram/_bot.py", line 381, in decorator
    result = await func(self, *args, **kwargs)  # skipcq: PYL-E1102
  File "/usr/local/lib/python3.10/dist-packages/telegram/_bot.py", line 3381, in edit_message_text
    return await self._send_message(
  File "/usr/local/lib/python3.10/dist-packages/telegram/ext/_extbot.py", line 507, in _send_message
    result = await super()._send_message(
  File "/usr/local/lib/python3.10/dist-packages/telegram/_bot.py", line 559, in _send_message
    result = await self._post(
  File "/usr/local/lib/python3.10/dist-packages/telegram/_bot.py", line 469, in _post
    return await self._do_post(
  File "/usr/local/lib/python3.10/dist-packages/telegram/ext/_extbot.py", line 325, in _do_post
    return await super()._do_post(
  File "/usr/local/lib/python3.10/dist-packages/telegram/_bot.py", line 497, in _do_post
    return await request.post(
  File "/usr/local/lib/python3.10/dist-packages/telegram/request/_baserequest.py", line 168, in post
    result = await self._request_wrapper(
  File "/usr/local/lib/python3.10/dist-packages/telegram/request/_baserequest.py", line 314, in _request_wrapper
    raise RetryAfter(retry_after)
telegram.error.RetryAfter: Flood control exceeded. Retry in 222 seconds

does not work in telegram topics

The problem

i unlocked the bot in one topic, and it keeps responding in General (the main topic) for a telegram group

i cant use it in other topics

Version of python

i use docker

Version of EdgeGPT-Telegram-Bot

cloned today

Operating system running EdgeGPT-Telegram-Bot

linux

Running on your machine? Running on docker?

docker

Additional information & file uploads

No response

Did not start conteiner with latest docker image

The problem

docker stop edgegpt
docker rm edgegpt
docker pull scmanjarrez/edgegpt-telegram-bot
docker run -d -it --name edgegpt -p 34545:34545 --restart unless-stopped -v /root/EdgeGPT-Telegram-Bot/config:/edgegpt/config scmanjarrez/edgegpt-telegram-bot

Version of python

latest

Version of EdgeGPT-Telegram-Bot

latest

Operating system running EdgeGPT-Telegram-Bot

debian 11

Running on your machine? Running on docker?

docker

Additional information & file uploads

image

[Request] Best way to deploy to the cloud

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

I noticed this approach uses SQLite as database and in general is designed to be run in a full VM (if run in the cloud).

What could be a better approach running in the cloud?

I run a Telegram bot using GCP (I know, I should change..) and it's all running using Firestore (I know, bad DB..) and a Cloud Function that handles webhooks. The setup costs a few cents to run at scale in the cloud.

Hence why I'm wondering what would be the best way to port this to a cloud-friendly fork.

Feel free to let me know if this is OT and where to post it. Thanks!

Describe alternatives you've considered

No response

Additional context

No response

Can't start bot

The problem

root@kelime:~/EdgeGPT-Telegram-Bot# sudo python3 src/edge.py
Traceback (most recent call last):
  File "/root/EdgeGPT-Telegram-Bot/src/edge.py", line 308, in <module>
    ut.setup()
  File "/root/EdgeGPT-Telegram-Bot/src/utils.py", line 188, in setup
    if chats("history"):
  File "/root/EdgeGPT-Telegram-Bot/src/utils.py", line 222, in chats
    return DATA["config"]["chats"][key]
KeyError: 'history'
root@kelime:~/EdgeGPT-Telegram-Bot#

Version of python

latest

Version of EdgeGPT-Telegram-Bot

latest

Operating system running EdgeGPT-Telegram-Bot

latest

Running on your machine? Running on docker?

no

Additional information & file uploads

No response

Typing with No answer

The problem

I don't know how it happened, but it doesn't answer any of my questions. And it keeps saying typing. Here is the logs:
image

Version of python

3.10.7

Version of EdgeGPT-Telegram-Bot

v1.0.2 - d90e118 (git)

Operating system running EdgeGPT-Telegram-Bot

Linux

Running on your machine? Running on docker?

with nohup command

Additional information & file uploads

No response

[Request] Ability to queue messages

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

When I send more than one request, it only answers the last question I wrote, I think what should be done is to queue up each message and reply in order.
When something comes to my mind, sometimes I want to be able to ask my new question without waiting for an answer.

Describe alternatives you've considered

No response

Additional context

No response

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.