Giter Club home page Giter Club logo

ediziks / binggpt-discord-bot Goto Github PK

View Code? Open in Web Editor NEW
119.0 119.0 14.0 64 KB

BingGPT Discord Bot that can handle /ask & /imagine prompts using reverse engineered API of Microsoft's Bing Chat under the hood

License: The Unlicense

Python 93.61% Shell 0.47% Dockerfile 1.43% Makefile 4.50%
bing bing-api bing-chat bingapi bingchat chat chatbot chatbots chatgpt chatgpt-api chatgpt-bot chatgpt4 discord discord-bot edge edgegpt gpt gpt-4 gpt4 openai

binggpt-discord-bot's People

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

binggpt-discord-bot's Issues

Option to change modes/conversation style.

Bing AI provides 3 modes: Creative, Balanced, Precise
firefox_vicELu5Oot
All three are useful in their own regard so I was wondering if it is possible to implement the modes via slash command so you can change on the fly?

error using /imagine

Error: [Errno 5] I/O error
Try again or check if your prompt is appropriate.

any fix for this?

How to fix this error, discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized ?

While deploying bot i am facing error during bot launching as mentioned below, pls guide me how to resolve it.

[2023-07-05 14:11:37] [INFO ] discord.client: logging in using static token
Traceback (most recent call last):
File "/home/mint/.local/lib/python3.10/site-packages/discord/http.py", line 803, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "/home/mint/.local/lib/python3.10/site-packages/discord/http.py", line 745, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/mint/BingGPT-Discord-Bot/src/bot.py", line 175, in
client.run(TOKEN)
File "/home/mint/.local/lib/python3.10/site-packages/discord/client.py", line 860, in run
asyncio.run(runner())
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
return future.result()
File "/home/mint/.local/lib/python3.10/site-packages/discord/client.py", line 849, in runner
await self.start(token, reconnect=reconnect)
File "/home/mint/.local/lib/python3.10/site-packages/discord/client.py", line 777, in start
await self.login(token)
File "/home/mint/.local/lib/python3.10/site-packages/discord/client.py", line 612, in login
data = await self.http.static_login(token)
File "/home/mint/.local/lib/python3.10/site-packages/discord/http.py", line 807, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.

Replit Bing, I have beta access though is there a fix to this

Traceback (most recent call last):
File "BingGPT-Discord-Bot/src/main.py", line 394, in create
self.struct = response.json()
File "/home/runner/ImpressionableHandmadePcboard/venv/lib/python3.10/site-packages/httpx/_models.py", line 756, in json
return jsonlib.loads(self.text, **kwargs)
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "BingGPT-Discord-Bot/src/main.py", line 880, in
main()
File "BingGPT-Discord-Bot/src/main.py", line 876, in main
asyncio.run(async_main(args))
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "BingGPT-Discord-Bot/src/main.py", line 741, in async_main
bot = await Chatbot.create(proxy=args.proxy, cookies=args.cookies)
File "BingGPT-Discord-Bot/src/main.py", line 626, in create
await _Conversation.create(self.cookies, self.proxy),
File "BingGPT-Discord-Bot/src/main.py", line 396, in create
raise Exception(
Exception: Authentication failed. You have not been accepted into the beta.
image

error -docker

dcbot | Traceback (most recent call last):
dcbot | File "src/bot.py", line 175, in
dcbot | client.run(TOKEN)
dcbot | File "/usr/local/lib/python3.8/site-packages/discord/client.py", line 860, in run
dcbot | asyncio.run(runner())
dcbot | File "/usr/local/lib/python3.8/asyncio/runners.py", line 44, in run
dcbot | return loop.run_until_complete(main)
dcbot | File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
dcbot | return future.result()
dcbot | File "/usr/local/lib/python3.8/site-packages/discord/client.py", line 849, in runner
dcbot | await self.start(token, reconnect=reconnect)
dcbot | File "/usr/local/lib/python3.8/site-packages/discord/client.py", line 777, in start
dcbot | await self.login(token)
dcbot | File "/usr/local/lib/python3.8/site-packages/discord/client.py", line 621, in login
dcbot | await self.setup_hook()
dcbot | File "src/bot.py", line 30, in setup_hook
dcbot | await self.tree.sync(guild=MY_GUILD)
dcbot | File "/usr/local/lib/python3.8/site-packages/discord/app_commands/tree.py", line 1069, in sync
dcbot | data = await self._http.bulk_upsert_guild_commands(self.client.application_id, guild.id, payload=payload)
dcbot | File "/usr/local/lib/python3.8/site-packages/discord/http.py", line 739, in request
dcbot | raise Forbidden(response, data)
dcbot | discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
dcbot exited with code 0

help asap! i did everything right

Bug using Docker

I'm using W10 and py 3.10.9, I used docker to build the project but when I try to run I get a error who says dcbot directory doesnt exists, then can't run bot.py.

Connects, but doesn't work

My bot connects, and tries to respond but... it blows on my cmd

image

[2023-04-25 13:00:04] [ERROR ] discord.app_commands.tree: Ignoring exception in command 'reset'
Traceback (most recent call last):
File "C:\Users\x\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\app_commands\commands.py", line 842, in _do_call
return await self.callback(interaction, **params) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\x\Downloads\New folder\BotDIscord\BingGPT-Discord-Bot\dcbot\bot.py", line 134, in reset
await interaction.response.send_message("Alfred conversation has been reset")
File "C:\Users\x\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\interactions.py", line 778, in send_message
await adapter.create_interaction_response(
File "C:\Users\x\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\webhook\async
.py", line 221, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 40060): Interaction has already been acknowledged.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\x\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\app_commands\tree.py", line 1248, in _call
await command._invoke_with_namespace(interaction, namespace)
File "C:\Users\x\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\app_commands\commands.py", line 867, in _invoke_with_namespace
return await self._do_call(interaction, transformed_values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\x\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\app_commands\commands.py", line 860, in _do_call
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'reset' raised an exception: HTTPException: 400 Bad Request (error code: 40060): Interaction has already been acknowledged.

python retard

Traceback (most recent call last):
File "C:\Users\404\Desktop\Neox\src\bot.py", line 19, in
MY_GUILD = discord.Object(id=SERVER_ID)
File "C:\Users\404\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\object.py", line 95, in init
id = int(id)
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

I understand what its saying. but my brain is numb

Error - TypeError: 'builtin_function_or_method' object is not subscriptable

@ediziks I was getting the below error. Windows 10.

PS D:\Downloads\Discord\bots\BingGPT-Discord-Bot-main> python src/bot.py
Traceback (most recent call last):
  File "D:\Downloads\Discord\bots\BingGPT-Discord-Bot-main\src\bot.py", line 44, in <module>
    gptbot = Chatbot(cookie_path='cookies.json')
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Downloads\Discord\bots\BingGPT-Discord-Bot-main\src\EdgeGPT.py", line 603, in __init__
    self.chat_hub: _ChatHub = _ChatHub(
                              ^^^^^^^^^
  File "D:\Downloads\Discord\bots\BingGPT-Discord-Bot-main\src\EdgeGPT.py", line 415, in __init__
    conversation_signature=conversation.struct.get["conversationSignature"],
                           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'builtin_function_or_method' object is not subscriptable

Had to change line 415 to the following to get it working:

conversation_signature=conversation.struct.get("conversationSignature")

Wheres the problem? how to fix it?

File "bot.py", line 108, in
client.run(TOKEN)
File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 860, in run
asyncio.run(runner())
File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 849, in runner
await self.start(token, reconnect=reconnect)
File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 777, in start
await self.login(token)
File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 621, in login
await self.setup_hook()
File "bot.py", line 29, in setup_hook
await self.tree.sync(guild=MY_GUILD)
File "/usr/local/lib/python3.8/dist-packages/discord/app_commands/tree.py", line 1069, in sync
data = await self._http.bulk_upsert_guild_commands(self.client.application_id, guild.id, payload=payload)
File "/usr/local/lib/python3.8/dist-packages/discord/http.py", line 738, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

i already checklist the permission too

Run chatbot on Cpanel

hello, i have a issue when run "python src/bot.py".
Please help me. Thank you.

Traceback (most recent call last):
  File "/home/axvktbno/pokav2/BingGPT-Discord-Bot/src/bot.py", line 44, in <module>
    gptbot = Chatbot(cookie_path='cookies.json')
  File "/home/axvktbno/pokav2/BingGPT-Discord-Bot/src/EdgeGPT.py", line 604, in __init__
    _Conversation(self.cookies, self.proxy),
  File "/home/axvktbno/pokav2/BingGPT-Discord-Bot/src/EdgeGPT.py", line 321, in __init__
    self.session.cookies.set(cookie["name"], cookie["value"])
TypeError: string indices must be integers

[BUG]

C:\Users\GUILHERME\Desktop\terraria\gta\Discord\DISCORD I.A\BingGPT-Discord-Bot>docker-compose up
[+] Building 0.2s (0/0)
[+] Running 1/1
โœ” Container dcbot Recreated 14.3s
Attaching to dcbot
dcbot | Traceback (most recent call last):
dcbot | File "/usr/local/lib/python3.8/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions
dcbot | yield
dcbot | File "/usr/local/lib/python3.8/site-packages/httpcore/backends/sync.py", line 100, in connect_tcp
dcbot | sock = socket.create_connection(
dcbot | File "/usr/local/lib/python3.8/socket.py", line 808, in create_connection
dcbot | raise err
dcbot | File "/usr/local/lib/python3.8/socket.py", line 796, in create_connection
dcbot | sock.connect(sa)
dcbot | OSError: [Errno 99] Cannot assign requested address
dcbot |
dcbot | The above exception was the direct cause of the following exception:
dcbot |
dcbot | Traceback (most recent call last):
dcbot | File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
dcbot | yield
dcbot | File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 218, in handle_request
dcbot | resp = self._pool.handle_request(req)
dcbot | File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/connection_pool.py", line 261, in handle_request
dcbot | raise exc
dcbot | File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/connection_pool.py", line 245, in handle_request
dcbot | response = connection.handle_request(request)
dcbot | File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/connection.py", line 92, in handle_request
dcbot | raise exc
dcbot | File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/connection.py", line 69, in handle_request
dcbot | stream = self._connect(request)
dcbot | File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/connection.py", line 117, in _connect
dcbot | stream = self._network_backend.connect_tcp(**kwargs)
dcbot | File "/usr/local/lib/python3.8/site-packages/httpcore/backends/sync.py", line 107, in connect_tcp
dcbot | sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
dcbot | File "/usr/local/lib/python3.8/contextlib.py", line 131, in exit
dcbot | self.gen.throw(type, value, traceback)
dcbot | File "/usr/local/lib/python3.8/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
dcbot | raise to_exc(exc) from exc
dcbot | httpcore.ConnectError: [Errno 99] Cannot assign requested address
dcbot |
dcbot | The above exception was the direct cause of the following exception:
dcbot |
dcbot | Traceback (most recent call last):
dcbot | File "src/bot.py", line 44, in
dcbot | gptbot = Chatbot(cookie_path='cookies.json')
dcbot | File "/app/src/EdgeGPT.py", line 604, in init
dcbot | _Conversation(self.cookies, self.proxy),
dcbot | File "/app/src/EdgeGPT.py", line 324, in init
dcbot | response = self.session.get(
dcbot | File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1041, in get
dcbot | return self.request(
dcbot | File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 814, in request
dcbot | return self.send(request, auth=auth, follow_redirects=follow_redirects)
dcbot | File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 901, in send
dcbot | response = self._send_handling_auth(
dcbot | File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 929, in _send_handling_auth
dcbot | response = self._send_handling_redirects(
dcbot | File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 966, in _send_handling_redirects
dcbot | response = self._send_single_request(request)
dcbot | File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1002, in _send_single_request
dcbot | response = transport.handle_request(request)
dcbot | File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 218, in handle_request
dcbot | resp = self._pool.handle_request(req)
dcbot | File "/usr/local/lib/python3.8/contextlib.py", line 131, in exit
dcbot | self.gen.throw(type, value, traceback)
dcbot | File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
dcbot | raise mapped_exc(message) from exc
dcbot | httpx.ConnectError: [Errno 99] Cannot assign requested address

not for windows users

the instructions need the chmod command, can you extend the instruction for windows users as well?

error

PS C:\Users\usuario\Downloads\BingGPT-Discord-Bot> python src/bot.py
Traceback (most recent call last):
File "C:\Users\usuario\Downloads\BingGPT-Discord-Bot\src\bot.py", line 44, in
gptbot = Chatbot(cookie_path='cookies.json')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\usuario\Downloads\BingGPT-Discord-Bot\src\EdgeGPT.py", line 603, in init
self.chat_hub: _ChatHub = _ChatHub(
^^^^^^^^^
File "C:\Users\usuario\Downloads\BingGPT-Discord-Bot\src\EdgeGPT.py", line 415, in init
conversation_signature=conversation.struct["conversationSignature"],
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'conversationSignature'

Server rejected WebSocket connection: HTTP 200

Hey there, getting this stacktrace:

2023-09-21 23:31:36 WARNING  discord.bot server rejected WebSocket connection: HTTP 200
2023-09-21 23:31:37 WARNING  discord.bot Command 'ask' raised an exception: UnboundLocalError: local variable 'res' referenced before assignment
Task exception was never retrieved
future: <Task finished name='CommandTree-invoker' coro=<CommandTree._from_interaction.<locals>.wrapper() done, defined at /usr/local/lib/python3.9/dist-packages/discord/app_commands/tree.py:1087> exception=InteractionResponded('This interaction has already been responded to before')>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/discord/app_commands/commands.py", line 828, in _do_call
    return await self._callback(interaction, **params)  # type: ignore
  File "/root/BingGPT-Discord-Bot/src/bot.py", line 75, in ask
    ans = res[0]
UnboundLocalError: local variable 'res' referenced before assignment

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/discord/app_commands/tree.py", line 1248, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "/usr/local/lib/python3.9/dist-packages/discord/app_commands/commands.py", line 853, in _invoke_with_namespace
    return await self._do_call(interaction, transformed_values)
  File "/usr/local/lib/python3.9/dist-packages/discord/app_commands/commands.py", line 846, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'ask' raised an exception: UnboundLocalError: local variable 'res' referenced before assignment

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/discord/app_commands/tree.py", line 1089, in wrapper
    await self._call(interaction)
  File "/usr/local/lib/python3.9/dist-packages/discord/app_commands/tree.py", line 1251, in _call
    await command._invoke_error_handlers(interaction, e)
  File "/usr/local/lib/python3.9/dist-packages/discord/app_commands/commands.py", line 772, in _invoke_error_handlers
    await self.on_error(interaction, error)  # type: ignore
  File "/root/BingGPT-Discord-Bot/src/bot.py", line 146, in ask_error
    await interaction.response.send_message(
  File "/usr/local/lib/python3.9/dist-packages/discord/interactions.py", line 774, in send_message
    raise InteractionResponded(self._parent)
discord.errors.InteractionResponded: This interaction has already been responded to before

Upon using the /ask feature. /imagine seems to work just fine without any issues.

These are the only logs I'm able to find as I'm currently unable to locate anything like bot.log under src/

Any suggestions appreciated :P

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.