Hello.
I’m trying to make my Alexa/Echo dot 3 powered by ChatGPT. I would like to integrate ChatGPT into my Alexa / Echo dot 3. I want to have more engaging and natural conversations with my smart speaker. To achieve the goal I found a Step-By-Step guide. The relevant steps to do are :
https://pastebin.ubuntu.com/p/dMsfQzj33g/
Unfortunately I haven’t been able to understand what to do to make my Alexa Echo dot 3 reply to my questions using the chat gpt style because I found some problems before reaching the end of the tutorial. This is what I did :
- on Debian x64 bit : (IP number = 192.168.1.2)
a) Opened bing chat on Edge and copied my cookies to cookies.json using the extension cookie-editor
b) mounted the zpool zroot2 with the following command :
zpool import -f -R /mnt/zroot2 zroot2
the project files are stored under the path : /mnt/zroot2/zroot2/ChatGPT/BingChatGPT
- on the jetson nano (where I have installed ubuntu 20.04 for arm64) :
a) mounted the zpool with the following command :
sshfs -o allow_other,default_permissions marietto@192.168.1.2:/mnt/zroot2/zroot2 /mnt/fisso
b) python server.py
* Serving Flask app 'server'
* Debug mode: off WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:8080 Press CTRL+C to quit
When I open that link using Firefox,I see the error :
“The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again”
and on the Terminal :
127.0.0.1 - - [08/Apr/2023 16:18:59] "GET / HTTP/1.1" 404 -
127.0.0.1 - - [08/Apr/2023 16:19:01] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [08/Apr/2023 16:19:28] "GET / HTTP/1.1" 404
As a further experiment I’ve re-configured everything to make it work on my X64 Debian 11 workstation. I’ve opened the address : 127.0.0.1:8080 with Edge but I’ve got the same error as before :
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again. And on the terminal I see :
marietto@marietto:/mnt/zroot2/zroot2/ChatGPT/BingChatGPT/amd64$ python server.py
* Serving Flask app 'server'
* Debug mode: off WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:8080 Press CTRL+C to quit
127.0.0.1 - - [08/Apr/2023 21:32:08] "GET / HTTP/1.1" 404 -
127.0.0.1 - - [08/Apr/2023 21:32:09] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [08/Apr/2023 22:16:21] "GET / HTTP/1.1" 404 -
127.0.0.1 - - [08/Apr/2023 22:16:21] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [08/Apr/2023 22:16:28] "GET / HTTP/1.1" 404
But why ? Maybe there is some mistake with the cookies.json file ? Can you give a look ? You can find the json file here :
https://pastebin.ubuntu.com/p/ZfQQDqPqcb/
To be honest I haven’t understood why I should save the cookies inside the json file,so probably the error is inside that file.
As a final consideration : I don’t see errors between the python libraries installed by the project :
marietto@marietto:/mnt/zroot2/zroot2/ChatGPT/BingChatGPT/amd64$ pip install -r requirements.txt
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: EdgeGPT==0.0.60 in /home/marietto/.local/lib/python3.10/site-packages (from -r requirements.txt (line 1)) (0.0.60)
Requirement already satisfied: Flask==2.2.3 in /home/marietto/.local/lib/python3.10/site-packages (from -r requirements.txt (line 2)) (2.2.3)
Requirement already satisfied: rich in /home/marietto/.local/lib/python3.10/site-packages (from EdgeGPT==0.0.60->-r requirements.txt (line 1)) (13.3.3)
Requirement already satisfied: websockets in /home/marietto/.local/lib/python3.10/site-packages (from EdgeGPT==0.0.60->-r requirements.txt (line 1)) (11.0.1)
Requirement already satisfied: prompt-toolkit in /home/marietto/.local/lib/python3.10/site-packages (from EdgeGPT==0.0.60->-r requirements.txt (line 1)) (3.0.38)
Requirement already satisfied: httpx in /home/marietto/.local/lib/python3.10/site-packages (from EdgeGPT==0.0.60->-r requirements.txt (line 1)) (0.23.3)
Requirement already satisfied: certifi in /home/marietto/.local/lib/python3.10/site-packages (from EdgeGPT==0.0.60->-r requirements.txt (line 1)) (2022.12.7)
Requirement already satisfied: asyncio in /home/marietto/.local/lib/python3.10/site-packages (from EdgeGPT==0.0.60->-r requirements.txt (line 1)) (3.4.3)
Requirement already satisfied: itsdangerous>=2.0 in /home/marietto/.local/lib/python3.10/site-packages (from Flask==2.2.3->-r requirements.txt (line 2)) (2.1.2)
Requirement already satisfied: Jinja2>=3.0 in /home/marietto/.local/lib/python3.10/site-packages (from Flask==2.2.3->-r requirements.txt (line 2)) (3.1.2)
Requirement already satisfied: Werkzeug>=2.2.2 in /home/marietto/.local/lib/python3.10/site-packages (from Flask==2.2.3->-r requirements.txt (line 2)) (2.2.3)
Requirement already satisfied: click>=8.0 in /home/marietto/.local/lib/python3.10/site-packages (from Flask==2.2.3->-r requirements.txt (line 2)) (8.1.3)
Requirement already satisfied: MarkupSafe>=2.0 in /home/marietto/.local/lib/python3.10/site-packages (from Jinja2>=3.0->Flask==2.2.3->-r requirements.txt (line 2)) (2.1.2)
Requirement already satisfied: sniffio in /home/marietto/.local/lib/python3.10/site-packages (from httpx->EdgeGPT==0.0.60->-r requirements.txt (line 1)) (1.3.0)
Requirement already satisfied: rfc3986[idna2008]<2,>=1.3 in /home/marietto/.local/lib/python3.10/site-packages (from httpx->EdgeGPT==0.0.60->-r requirements.txt (line 1)) (1.5.0)
Requirement already satisfied: httpcore<0.17.0,>=0.15.0 in /home/marietto/.local/lib/python3.10/site-packages (from httpx->EdgeGPT==0.0.60->-r requirements.txt (line 1)) (0.16.3)
Requirement already satisfied: wcwidth in /home/marietto/.local/lib/python3.10/site-packages (from prompt-toolkit->EdgeGPT==0.0.60->-r requirements.txt (line 1)) (0.2.6)
Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /home/marietto/.local/lib/python3.10/site-packages (from rich->EdgeGPT==0.0.60->-r requirements.txt (line 1)) (2.14.0)
Requirement already satisfied: markdown-it-py<3.0.0,>=2.2.0 in /home/marietto/.local/lib/python3.10/site-packages (from rich->EdgeGPT==0.0.60->-r requirements.txt (line 1)) (2.2.0)
Requirement already satisfied: h11<0.15,>=0.13 in /home/marietto/.local/lib/python3.10/site-packages (from httpcore<0.17.0,>=0.15.0->httpx->EdgeGPT==0.0.60->-r requirements.txt (line 1)) (0.14.0)
Requirement already satisfied: anyio<5.0,>=3.0 in /home/marietto/.local/lib/python3.10/site-packages (from httpcore<0.17.0,>=0.15.0->httpx->EdgeGPT==0.0.60->-r requirements.txt (line 1)) (3.6.2)
Requirement already satisfied: mdurl~=0.1 in /home/marietto/.local/lib/python3.10/site-packages (from markdown-it-py<3.0.0,>=2.2.0->rich->EdgeGPT==0.0.60->-r requirements.txt (line 1)) (0.1.2)
Requirement already satisfied: idna in /home/marietto/.local/lib/python3.10/site-packages (from rfc3986[idna2008]<2,>=1.3->httpx->EdgeGPT==0.0.60->-r requirements.txt (line 1)) (3.4)
from flask import Flask, request, jsonify
import json
import sys
import asyncio
import random
from EdgeGPT import Chatbot, ConversationStyle
import threading
cookies = None
import time
with open('./cookies.json', 'r') as f:
cookies = json.load(f)
app = Flask(__name__)
responses_final_list = {}
def generate_code():
code = ""
for i in range(2):
code += str(random.randint(0, 9))
return str(code)
@app.route('/res/<codes>', methods=['GET'])
def lidar_com_resposta(codes):
codes = codes.replace("%20","").replace(" ", "")
print("Password: " + str(codes))
if codes in responses_final_list:
return responses_final_list[codes]
else:
time.sleep(6)
if codes in responses_final_list:
return responses_final_list[codes]
else:
return "Invalid code, try again in 1 minute."
async def ask_stream_task(question, codes):
wrote = 0
finished = False
bot = Chatbot(cookies=cookies)
response_list = []
while not finished:
async for final, response in bot.ask_stream(prompt=question, conversation_style=ConversationStyle.creative):
if not final:
response_list.append(response[wrote:])
wrote = len(response)
sys.stdout.flush()
else:
response_list.clear()
response_list.append(response["item"]["messages"][-1]["text"])
responses_final_list[str(codes)] = response["item"]["messages"][-1]["text"]
finished = True
print("Finished: " + str(codes))
def between_callback(prompt, codes):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(ask_stream_task(prompt, codes))
loop.close()
@app.route("/api")
async def api():
prompt = request.args.get("prompt")
timeout = 6
codes = generate_code()
asyncio.create_task(ask_stream_task(prompt, codes))
_thread = threading.Thread(target=between_callback, args=(prompt, codes))
_thread.start()
return codes
if __name__ == "__main__":
app.run(port=8080)