I'm trying to make my Alexa/Echo dot 3 powered by ChatGPT.... - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: I'm trying to make my Alexa/Echo dot 3 powered by ChatGPT.... (/thread-39757.html) |
I'm trying to make my Alexa/Echo dot 3 powered by ChatGPT.... - mariozio - Apr-09-2023 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 2. 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 [email protected]:/mnt/zroot2/zroot2 /mnt/fisso b) python server.py When I open that link using Firefox,I see the error : and on the Terminal : 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 : And on the terminal I see : 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 : server.pyfrom 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) RE: I'm trying to make my Alexa/Echo dot 3 powered by ChatGPT.... - farshid - Apr-20-2023 It seems like the Flask app is not able to find the URL you are requesting, which leads to a 404 error. There could be several reasons why this is happening. Here are a few things you can try to debug the issue: 1. Check if the server is running: First, make sure that the server is running by running the command python server.py and checking the output. If you see the message "Running on http://127.0.0.1:8080", it means that the server is up and running.2. Check if the cookies are correct: Double-check the contents of the cookies.json file and make sure that it contains the correct cookies for your Bing chat session. One way to do this is to open the chat in your browser and check the cookies manually. 3. Check if the URL is correct: Make sure that you are requesting the correct URL. In the tutorial, the URL is http://localhost:8080 , but you mentioned that you are using 127.0.0.1:8080 and 192.168.1.2 . Try using the original URL mentioned in the tutorial and see if that works.4. Try a different browser: If the above steps don't work, try accessing the URL in a different browser. Some browsers may have security settings that prevent the cookies from being passed to the Flask app. 5. Check if the ports are open: Make sure that the ports used by the server are open and accessible from your machine. You can use a tool like nmap to check if the port is open. For example, if you are using port 8080, run the command nmap -p 8080 localhost to check if the port is open.6. Check if the Flask app is serving on the correct port: Make sure that the Flask app is serving on the correct port. You can specify the port number by adding the port parameter to the app.run() method. For example, to serve on port 8080, use app.run(port=8080) .Hope these steps help you debug the issue. |