MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. SILLEN 0
    3. Posts
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    S
    Offline
    • Profile
    • Following 0
    • Followers 1
    • Topics 4
    • Posts 26
    • Groups 0

    Posts

    Recent Best Controversial
    • RE: Wifi connection drops and doesn't get restablished

      @karsten13 i thought that as well but it didn’t change anything

      posted in Troubleshooting
      S
      SILLEN 0
    • Wifi connection drops and doesn't get restablished

      If I boot my pi 4 4gb and just let it sit in the home screen. No Magic Mirror. It works fine. And network connection is stable. When I start Magic Mirror and look at the logs everything seems fine. Except some DNS name resolve issue from MMM-GoogleAssistant by bugsonet. But I am pretty sure thats unrelated. Anyways after a couple minutes my ssh connection drops and I get a notification on the top of the display saying that the internet connection was lost. Everything continues to run normally but no information gets updated. (Weather, rainmap, etc) I don’t have any relevant logs because I do not know what too log or how.

      I am using networkManager over the default system dhcpcd because I had a whole bunch of different wifi issues with that system. I am asking for help on where too start too trouble shoot this issue. Any help is greatly appreciated. Could it be some kind of overheating. But if that’s the case, why haven’t other people had the same issue.

      posted in Troubleshooting network connection wifi
      S
      SILLEN 0
    • RE: ChatGpt intergration

      @sdetweil ok i tried with that module and all i changed was in the googleassistant module it should have sent the payload of everything after “chatgpt” but when i say somthing like chatgpt say banana it does send the notification and the notification gets recieved and the module displays an answer but this is what it looks like: 3436554f-9a42-4db7-813c-e6a616eee989-image.png
      as you see it says undefined and just answer a random question. this is my recipe:

      var recipe = {
        transcriptionHooks: {
          "ASK_QUESTION": {
            pattern: "chatgpt (.*)",
            command: "ASK_QUESTION"
          }
        },
      
        commands: {
          "ASK_QUESTION": {
            notificationExec: {
              notification: "OPENAI_REQUEST",
              payload: (params) => {
                console.log("Debug: params received", params);
                return {
                  question: params[1]
                }
              }
            }
          }
      
      

      the weird thing is is that if im not mistaken in the logs of magicmirror it should say params recieved and then params after but it doesnt. why do you think the module says undefined now but in my module the notification gets recieved and the params after “chatgpt” get sent over with it? but in this module it shows up as undefined?

      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      @sdetweil yes i just saw that i will try too use that module and from there send a notifications with the payload of the googleassistant recipie

      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      @sdetweil so sorry for not being active. i have been on vacation and working on another project. you are right it doesnt seem too give any answer but it does use the “tokens” and that would mean it DOES somhow make an answer but it doesnt get displayed or somthing. i have added some debug logs and now i dont get the maximum callstack error anymore but with the added debug code i get this error when asking “chatgpt say banana”

      
      0|MagicMirror  | [05.03.2023 21:17.49.185] [LOG]   Received ASK_QUESTION notification with payload:  say banana
      0|MagicMirror  | [05.03.2023 21:17.49.259] [LOG]   [GATEWAY] [192.168.1.223][GET] /getEXTStatus
      0|MagicMirror  | [05.03.2023 21:17.50.205] [LOG]   [GATEWAY] [192.168.1.223][GET] /getEXTStatus
      0|MagicMirror  | [05.03.2023 21:17.50.502] [LOG]   Received response from API:  {
      0|MagicMirror  |   status: 200,
      0|MagicMirror  |   statusText: 'OK',
      0|MagicMirror  |   headers: {
      0|MagicMirror  |     date: 'Sun, 05 Mar 2023 20:17:50 GMT',
      0|MagicMirror  |     'content-type': 'application/json',
      0|MagicMirror  |     'content-length': '274',
      0|MagicMirror  |     connection: 'close',
      0|MagicMirror  |     'access-control-allow-origin': '*',
      0|MagicMirror  |     'cache-control': 'no-cache, must-revalidate',
      0|MagicMirror  |     'openai-model': 'text-davinci-003',
      0|MagicMirror  |     'openai-organization': 'user-pya0hjyay0pss3nexvnux3ro',
      0|MagicMirror  |     'openai-processing-ms': '688',
      0|MagicMirror  |     'openai-version': '2020-10-01',
      0|MagicMirror  |     'strict-transport-security': 'max-age=15724800; includeSubDomains',
      0|MagicMirror  |     'x-request-id': 'a3e862a0ca38b3ec23197aa8ece458b9'
      0|MagicMirror  |   },
      0|MagicMirror  |   config: {
      0|MagicMirror  |     transitional: {
      0|MagicMirror  |       silentJSONParsing: true,
      0|MagicMirror  |       forcedJSONParsing: true,
      0|MagicMirror  |       clarifyTimeoutError: false
      0|MagicMirror  |     },
      0|MagicMirror  |     adapter: [Function: httpAdapter],
      0|MagicMirror  |     transformRequest: [ [Function: transformRequest] ],
      0|MagicMirror  |     transformResponse: [ [Function: transformResponse] ],
      0|MagicMirror  |     timeout: 0,
      0|MagicMirror  |     xsrfCookieName: 'XSRF-TOKEN',
      0|MagicMirror  |     xsrfHeaderName: 'X-XSRF-TOKEN',
      0|MagicMirror  |     maxContentLength: -1,
      0|MagicMirror  |     maxBodyLength: -1,
      0|MagicMirror  |     validateStatus: [Function: validateStatus],
      0|MagicMirror  |     headers: {
      0|MagicMirror  |       Accept: 'application/json, text/plain, */*',
      0|MagicMirror  |       'Content-Type': 'application/json',
      0|MagicMirror  |       'User-Agent': 'OpenAI/NodeJS/3.1.0',
      0|MagicMirror  |       Authorization: 'Bearer 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',
      0|MagicMirror  |       'Content-Length': 68
      0|MagicMirror  |     },
      0|MagicMirror  |     method: 'post',
      0|MagicMirror  |     data: '{"model":"text-davinci-003","prompt":"say banana","temperature":0.7}',
      0|MagicMirror  |     url: 'https://api.openai.com/v1/completions'
      0|MagicMirror  |   },
      0|MagicMirror  |   request: <ref *1> ClientRequest {
      0|MagicMirror  |     _events: [Object: null prototype] {
      0|MagicMirror  |       abort: [Function (anonymous)],
      0|MagicMirror  |       aborted: [Function (anonymous)],
      0|MagicMirror  |       connect: [Function (anonymous)],
      0|MagicMirror  |       error: [Function (anonymous)],
      0|MagicMirror  |       socket: [Function (anonymous)],
      0|MagicMirror  |       timeout: [Function (anonymous)],
      0|MagicMirror  |       prefinish: [Function: requestOnPrefinish]
      0|MagicMirror  |     },
      0|MagicMirror  |     _eventsCount: 7,
      0|MagicMirror  |     _maxListeners: undefined,
      0|MagicMirror  |     outputData: [],
      0|MagicMirror  |     outputSize: 0,
      0|MagicMirror  |     writable: true,
      0|MagicMirror  |     destroyed: false,
      0|MagicMirror  |     _last: true,
      0|MagicMirror  |     chunkedEncoding: false,
      0|MagicMirror  |     shouldKeepAlive: false,
      0|MagicMirror  |     maxRequestsOnConnectionReached: false,
      0|MagicMirror  |     _defaultKeepAlive: true,
      0|MagicMirror  |     useChunkedEncodingByDefault: true,
      0|MagicMirror  |     sendDate: false,
      0|MagicMirror  |     _removedConnection: false,
      0|MagicMirror  |     _removedContLen: false,
      0|MagicMirror  |     _removedTE: false,
      0|MagicMirror  |     _contentLength: null,
      0|MagicMirror  |     _hasBody: true,
      0|MagicMirror  |     _trailer: '',
      0|MagicMirror  |     finished: true,
      0|MagicMirror  |     _headerSent: true,
      0|MagicMirror  |     _closed: false,
      0|MagicMirror  |     socket: TLSSocket {
      0|MagicMirror  |       _tlsOptions: [Object],
      0|MagicMirror  |       _secureEstablished: true,
      0|MagicMirror  |       _securePending: false,
      0|MagicMirror  |       _newSessionPending: false,
      0|MagicMirror  |       _controlReleased: true,
      0|MagicMirror  |       secureConnecting: false,
      0|MagicMirror  |       _SNICallback: null,
      0|MagicMirror  |       servername: 'api.openai.com',
      0|MagicMirror  |       alpnProtocol: false,
      0|MagicMirror  |       authorized: true,
      0|MagicMirror  |       authorizationError: null,
      0|MagicMirror  |       encrypted: true,
      0|MagicMirror  |       _events: [Object: null prototype],
      0|MagicMirror  |       _eventsCount: 10,
      0|MagicMirror  |       connecting: false,
      0|MagicMirror  |       _hadError: false,
      0|MagicMirror  |       _parent: null,
      0|MagicMirror  |       _host: 'api.openai.com',
      0|MagicMirror  |       _readableState: [ReadableState],
      0|MagicMirror  |       _maxListeners: undefined,
      0|MagicMirror  |       _writableState: [WritableState],
      0|MagicMirror  |       allowHalfOpen: false,
      0|MagicMirror  |       _sockname: null,
      0|MagicMirror  |       _pendingData: null,
      0|MagicMirror  |       _pendingEncoding: '',
      0|MagicMirror  |       server: undefined,
      0|MagicMirror  |       _server: null,
      0|MagicMirror  |       ssl: [TLSWrap],
      0|MagicMirror  |       _requestCert: true,
      0|MagicMirror  |       _rejectUnauthorized: true,
      0|MagicMirror  |       parser: null,
      0|MagicMirror  |       _httpMessage: [Circular *1],
      0|MagicMirror  |       [Symbol(res)]: [TLSWrap],
      0|MagicMirror  |       [Symbol(verified)]: true,
      0|MagicMirror  |       [Symbol(pendingSession)]: null,
      0|MagicMirror  |       [Symbol(async_id_symbol)]: 31736,
      0|MagicMirror  |       [Symbol(kHandle)]: [TLSWrap],
      0|MagicMirror  |       [Symbol(lastWriteQueueSize)]: 0,
      0|MagicMirror  |       [Symbol(timeout)]: null,
      0|MagicMirror  |       [Symbol(kBuffer)]: null,
      0|MagicMirror  |       [Symbol(kBufferCb)]: null,
      0|MagicMirror  |       [Symbol(kBufferGen)]: null,
      0|MagicMirror  |       [Symbol(kCapture)]: false,
      0|MagicMirror  |       [Symbol(kSetNoDelay)]: false,
      0|MagicMirror  |       [Symbol(kSetKeepAlive)]: true,
      0|MagicMirror  |       [Symbol(kSetKeepAliveInitialDelay)]: 60,
      0|MagicMirror  |       [Symbol(kBytesRead)]: 0,
      0|MagicMirror  |       [Symbol(kBytesWritten)]: 0,
      0|MagicMirror  |       [Symbol(connect-options)]: [Object],
      0|MagicMirror  |       [Symbol(RequestTimeout)]: undefined
      0|MagicMirror  |     },
      0|MagicMirror  |     _header: 'POST /v1/completions HTTP/1.1\r\n' +
      0|MagicMirror  |       'Accept: application/json, text/plain, */*\r\n' +
      0|MagicMirror  |       'Content-Type: application/json\r\n' +
      0|MagicMirror  |       'User-Agent: OpenAI/NodeJS/3.1.0\r\n' +
      0|MagicMirror  |       'Authorization: Bearer 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\r\n' +
      0|MagicMirror  |       'Content-Length: 68\r\n' +
      0|MagicMirror  |       'Host: api.openai.com\r\n' +
      0|MagicMirror  |       'Connection: close\r\n' +
      0|MagicMirror  |       '\r\n',
      0|MagicMirror  |     _keepAliveTimeout: 0,
      0|MagicMirror  |     _onPendingData: [Function: nop],
      0|MagicMirror  |     agent: Agent {
      0|MagicMirror  |       _events: [Object: null prototype],
      0|MagicMirror  |       _eventsCount: 2,
      0|MagicMirror  |       _maxListeners: undefined,
      0|MagicMirror  |       defaultPort: 443,
      0|MagicMirror  |       protocol: 'https:',
      0|MagicMirror  |       options: [Object: null prototype],
      0|MagicMirror  |       requests: [Object: null prototype] {},
      0|MagicMirror  |       sockets: [Object: null prototype],
      0|MagicMirror  |       freeSockets: [Object: null prototype] {},
      0|MagicMirror  |       keepAliveMsecs: 1000,
      0|MagicMirror  |       keepAlive: false,
      0|MagicMirror  |       maxSockets: Infinity,
      0|MagicMirror  |       maxFreeSockets: 256,
      0|MagicMirror  |       scheduling: 'lifo',
      0|MagicMirror  |       maxTotalSockets: Infinity,
      0|MagicMirror  |       totalSocketCount: 1,
      0|MagicMirror  |       maxCachedSessions: 100,
      0|MagicMirror  |       _sessionCache: [Object],
      0|MagicMirror  |       [Symbol(kCapture)]: false
      0|MagicMirror  |     },
      0|MagicMirror  |     socketPath: undefined,
      0|MagicMirror  |     method: 'POST',
      0|MagicMirror  |     maxHeaderSize: undefined,
      0|MagicMirror  |     insecureHTTPParser: undefined,
      0|MagicMirror  |     path: '/v1/completions',
      0|MagicMirror  |     _ended: true,
      0|MagicMirror  |     res: IncomingMessage {
      0|MagicMirror  |       _readableState: [ReadableState],
      0|MagicMirror  |       _events: [Object: null prototype],
      0|MagicMirror  |       _eventsCount: 4,
      0|MagicMirror  |       _maxListeners: undefined,
      0|MagicMirror  |       socket: [TLSSocket],
      0|MagicMirror  |       httpVersionMajor: 1,
      0|MagicMirror  |       httpVersionMinor: 1,
      0|MagicMirror  |       httpVersion: '1.1',
      0|MagicMirror  |       complete: true,
      0|MagicMirror  |       rawHeaders: [Array],
      0|MagicMirror  |       rawTrailers: [],
      0|MagicMirror  |       aborted: false,
      0|MagicMirror  |       upgrade: false,
      0|MagicMirror  |       url: '',
      0|MagicMirror  |       method: null,
      0|MagicMirror  |       statusCode: 200,
      0|MagicMirror  |       statusMessage: 'OK',
      0|MagicMirror  |       client: [TLSSocket],
      0|MagicMirror  |       _consuming: false,
      0|MagicMirror  |       _dumped: false,
      0|MagicMirror  |       req: [Circular *1],
      0|MagicMirror  |       responseUrl: 'https://api.openai.com/v1/completions',
      0|MagicMirror  |       redirects: [],
      0|MagicMirror  |       [Symbol(kCapture)]: false,
      0|MagicMirror  |       [Symbol(kHeaders)]: [Object],
      0|MagicMirror  |       [Symbol(kHeadersCount)]: 24,
      0|MagicMirror  |       [Symbol(kTrailers)]: null,
      0|MagicMirror  |       [Symbol(kTrailersCount)]: 0,
      0|MagicMirror  |       [Symbol(RequestTimeout)]: undefined
      0|MagicMirror  |     },
      0|MagicMirror  |     aborted: false,
      0|MagicMirror  |     timeoutCb: null,
      0|MagicMirror  |     upgradeOrConnect: false,
      0|MagicMirror  |     parser: null,
      0|MagicMirror  |     maxHeadersCount: null,
      0|MagicMirror  |     reusedSocket: false,
      0|MagicMirror  |     host: 'api.openai.com',
      0|MagicMirror  |     protocol: 'https:',
      0|MagicMirror  |     _redirectable: Writable {
      0|MagicMirror  |       _writableState: [WritableState],
      0|MagicMirror  |       _events: [Object: null prototype],
      0|MagicMirror  |       _eventsCount: 3,
      0|MagicMirror  |       _maxListeners: undefined,
      0|MagicMirror  |       _options: [Object],
      0|MagicMirror  |       _ended: true,
      0|MagicMirror  |       _ending: true,
      0|MagicMirror  |       _redirectCount: 0,
      0|MagicMirror  |       _redirects: [],
      0|MagicMirror  |       _requestBodyLength: 68,
      0|MagicMirror  |       _requestBodyBuffers: [],
      0|MagicMirror  |       _onNativeResponse: [Function (anonymous)],
      0|MagicMirror  |       _currentRequest: [Circular *1],
      0|MagicMirror  |       _currentUrl: 'https://api.openai.com/v1/completions',
      0|MagicMirror  |       [Symbol(kCapture)]: false
      0|MagicMirror  |     },
      0|MagicMirror  |     [Symbol(kCapture)]: false,
      0|MagicMirror  |     [Symbol(kNeedDrain)]: false,
      0|MagicMirror  |     [Symbol(corked)]: 0,
      0|MagicMirror  |     [Symbol(kOutHeaders)]: [Object: null prototype] {
      0|MagicMirror  |       accept: [Array],
      0|MagicMirror  |       'content-type': [Array],
      0|MagicMirror  |       'user-agent': [Array],
      0|MagicMirror  |       authorization: [Array],
      0|MagicMirror  |       'content-length': [Array],
      0|MagicMirror  |       host: [Array]
      0|MagicMirror  |     },
      0|MagicMirror  |     [Symbol(kUniqueHeaders)]: null
      0|MagicMirror  |   },
      0|MagicMirror  |   data: {
      0|MagicMirror  |     id: 'cmpl-6qp5h4r3TvsNZRhmVk1dwPWCmIyiX',
      0|MagicMirror  |     object: 'text_completion',
      0|MagicMirror  |     created: 1678047469,
      0|MagicMirror  |     model: 'text-davinci-003',
      0|MagicMirror  |     choices: [ [Object] ],
      0|MagicMirror  |     usage: { prompt_tokens: 2, completion_tokens: 6, total_tokens: 8 }
      0|MagicMirror  |   }
      0|MagicMirror  | }
      0|MagicMirror  | [05.03.2023 21:17.50.503] [LOG]   Error in getResponse:  Empty response from GPT-3 API
      
      

      i get error in getresponse because the response from the api is empty my updated code is as follows:

      chatgpt.js:

      Module.register("chatgpt", {
        defaults: {
          question: "What is the weather like today?",
        },
      
        start: function () {
          console.log("Starting module: " + this.name);
          this.question = this.config.question;
        },
      
        notificationReceived: function (notification, payload) {
          if (notification === "ASK_QUESTION") {
            this.question = payload.question;
            console.log("Received question: " + this.question);
            this.sendSocketNotification("ASK_QUESTION", this.question);
          }
        },
      
        socketNotificationReceived: function (notification, payload) {
        console.log("Payload received: ", payload);
        if(notification === "RESPONSE") {
          this.answer = payload.answer;
          console.log("Received answer: " + this.answer);
          console.log("Calling updateDom");
          this.updateDom();
        } else {
          console.log("Unhandled notification: " + notification);
          console.log("Payload: " + payload);
        }
      },
      
        getDom: function () {
          var wrapper = document.createElement("div");
          var question = document.createElement("div");
          var answer = document.createElement("div");
      
          if (this.answer) {
            answer.innerHTML = this.answer;
          } else {
            answer.innerHTML = "Ask me something";
          }
      
          question.innerHTML = this.question;
          wrapper.appendChild(question);
          wrapper.appendChild(answer);
      
          return wrapper;
        },
      });
      
      
      

      And here is my node_helper.js file:

      const NodeHelper = require("node_helper");
      const { Configuration, OpenAIApi } = require("openai");
      
      module.exports = NodeHelper.create({
        start: function () {
          console.log("Starting node helper for: " + this.name);
          this.configuration = new Configuration({
            apiKey: "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",
          });
          this.openai = new OpenAIApi(this.configuration);
        },
      
        // Send a message to the chatGPT API and receive a response
        getResponse: function (prompt) {
          return new Promise(async (resolve, reject) => {
            try {
              const response = await this.openai.createCompletion({
                model: "text-davinci-003",
                prompt: prompt,
                temperature: 0.7,
              });
              console.log("Received response from API: ", response);
              if (response.choices && response.choices.length > 0) {
                var text = response.choices[0].text;
                resolve(text);
              } else {
                reject("Empty response from GPT-3 API");
              }
            } catch (error) {
              console.log("Error in getResponse: ", error);
              reject(error);
            }
          });
        },
      
        // Handle socket notifications
        socketNotificationReceived: function (notification, payload) {
          if (notification === "ASK_QUESTION") {
            console.log("Received ASK_QUESTION notification with payload: ", payload);
            this.getResponse(payload)
              .then((response) => {
                // create a new object and update the answer property
                var responsePayload = { answer: response };
                console.log("Sending RESPONSE notification with payload: ", responsePayload);
                this.sendSocketNotification("RESPONSE", responsePayload);
              })
              .catch((error) => {
                console.log("Error in getResponse: ", error);
              });
          }
        },
      });
      
      
      

      note in the node_helper where the error log empty api response is coming from. as i have said multiple times i would love some help if anyone knows how you could fix this issue as i am a beginner in coding. i am trying my best but some help on why this is happening would be great.

      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      @sdetweil hey. I’m sorry for not being able too answer but i have other stuff going on and a math test coming up. The text is sent over as a string and the module does recieved the string and gets a response from the API it is after that the issue is caused. I Google the error and people say that there is probably a loop in the code somewhere. I will try with the debug module when i have time. I really want too get this too work.

      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      @sdetweil ok hello. alot of things have happend in the last week. i have got somthing that should be working but i had too fix abunch of errors in the code. but for the last couple of days i have been stuck on this perticular error in my code:

      0|MagicMirror  | [25.01.2023 21:05.25.175] [LOG]   Error in getResponse:  RangeError: Maximum call stack size exceeded
      0|MagicMirror  |     at isBinary (/home/pi/MagicMirror/node_modules/socket.io-parser/build/cjs/is-binary.js:22:18)
      0|MagicMirror  |     at hasBinary (/home/pi/MagicMirror/node_modules/socket.io-parser/build/cjs/is-binary.js:40:9)
      0|MagicMirror  |     at hasBinary (/home/pi/MagicMirror/node_modules/socket.io-parser/build/cjs/is-binary.js:49:63)
      0|MagicMirror  |     at hasBinary (/home/pi/MagicMirror/node_modules/socket.io-parser/build/cjs/is-binary.js:49:63)
      0|MagicMirror  |     at hasBinary (/home/pi/MagicMirror/node_modules/socket.io-parser/build/cjs/is-binary.js:49:63)
      0|MagicMirror  |     at hasBinary (/home/pi/MagicMirror/node_modules/socket.io-parser/build/cjs/is-binary.js:49:63)
      0|MagicMirror  |     at hasBinary (/home/pi/MagicMirror/node_modules/socket.io-parser/build/cjs/is-binary.js:49:63)
      0|MagicMirror  |     at hasBinary (/home/pi/MagicMirror/node_modules/socket.io-parser/build/cjs/is-binary.js:49:63)
      0|MagicMirror  |     at hasBinary (/home/pi/MagicMirror/node_modules/socket.io-parser/build/cjs/is-binary.js:49:63)
      0|MagicMirror  |     at hasBinary (/home/pi/MagicMirror/node_modules/socket.io-parser/build/cjs/is-binary.js:49:63)
      
      

      the internet says that it is probobally a part of the code calling itself but i just cant seem too find anything. it may be super clear what the issue is here but i really cant seem too find the cause of the error. help would be greatly apprecieted. here is my code:

      chatgpt.js:

      Module.register("chatgpt",{
          defaults: {
              question: "What is the weather like today?",
          },
      
          start: function() {
              console.log("Starting module: " + this.name);
              this.question = this.config.question;
          },
      
          notificationReceived: function(notification, payload) {
              if(notification === "ASK_QUESTION") {
                  this.question = payload.question;
                  console.log("Received question: " + this.question);
                  this.sendSocketNotification("ASK_QUESTION", this.question);
              }
          },
      
          socketNotificationReceived: function(notification, payload) {
              if(notification === "RESPONSE") {
                  this.answer = payload.answer;
                  console.log("Received answer: " + this.answer);
                  console.log("Calling updateDom");
                  this.updateDom();
              } else {
                  console.log("Unhandled notification: " + notification);
                  console.log("Payload: " + payload);
              }
          },
      
          getDom: function() {
              var wrapper = document.createElement("div");
              var question = document.createElement("div");
              var answer = document.createElement("div");
      
              if (this.answer) {
                  answer.innerHTML = this.answer;
              } else {
                  answer.innerHTML = "Ask me something";
              }
      
              question.innerHTML = this.question;
              wrapper.appendChild(question);
              wrapper.appendChild(answer);
      
              return wrapper;
          },
      });
      

      node_helper.js:

      const NodeHelper = require("node_helper");
      const { Configuration, OpenAIApi } = require("openai");
      
      module.exports = NodeHelper.create({
          start: function() {
              console.log("Starting node helper for: " + this.name);
              this.configuration = new Configuration({
                  apiKey: "XXXXXXXXXXXXXXXXXXXXXXXXXX",
              });
              this.openai = new OpenAIApi(this.configuration);
          },
      
          // Send a message to the chatGPT API and receive a response
          getResponse: function(prompt) {
              return new Promise(async (resolve, reject) => {
                  try {
                      const response = await this.openai.createCompletion({
                          model: "text-davinci-003",
                          prompt: prompt,
                          temperature: 0.7,
                      });
                      console.log("Received response from API: ", response);
                      resolve(response);
                  } catch (error) {
                      console.log("Error in getResponse: ", error);
                      reject(error);
                  }
              });
          },
      
      
        // Handle socket notifications
          socketNotificationReceived: function(notification, payload) {
              if (notification === "ASK_QUESTION") {
                  console.log("Received ASK_QUESTION notification with payload: ", payload);
                  this.getResponse(payload)
                      .then((response) => {
                          // create a new object and update the answer property
                          var responsePayload = {answer: response};
                          console.log("Sending RESPONSE notification with payload: ", responsePayload);
                          this.sendSocketNotification("RESPONSE", responsePayload);
                      })
                      .catch((error) => {
                          console.log("Error in getResponse: ", error);
                      });
              }
          },
      
      });
      
      
      

      the api call is being made and everything else is working but as soon as i say “jarvis chatgpt say banana” or any other input i get the error

      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      @sdetweil maybe i formulated it bad. i know how the recipie structure should look like and i can make simple recipies but having the notification only send everything after “chatgpt” that i have no idea how too do. as i said i am a beginner in coding and trying my best

      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      @sdetweil yea i guess but how in the world would you make it send just the phrase after chatgpt is said. in other words i have no idea how the recipie file should be coded

      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      @sdetweil how would you make the recipie part and what to have as a command like how would you tell the recipie too send all text after the phrase chatgpt in the notification as question. and recieving that in the chatgpt.js

      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      @sdetweil any idea on how to do that? Also i fixed it i was just stupid i changed the default question if I had nothing else in the config.js but in there i had the question still set too what’s the weather like and when i changed that everything worked

      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      i have MMM-googleassistant and i have used the recipes for some other stuff but could you get that too work with chatgpt. saying somthing like "ok-google chatgpt followed by the question you want too ask and then it takes the question makes it a variable or somthing that the prompt can read and then refresh the answer on the magicmirror. also what do you mean by (none free) MMM-google assistant is free. but i think it wouldnt be a big issue having too pay for chat gpt as in all of my testing and making api calls i have only paid 0.09 usd

      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      HOLY SHIT I GOT IT TOO WORK!. ok i need to calm down i am so happy right now. so turn out i was just trying too call the everything with openai.apiKey instead of just apiKey and then i had too do somthing else i dont even remember what i did but now i got it too work and it displays on the magicmirror. but now comes the hard part. if you look in the code there is a variabele named question that the prompt uses and send too the api. and i am no expert but can you have the variable question be defined with some kind of speech too text thing?

      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      @sdetweil if im honest i have no idea what you mean by that. as i said i am very bad at any sort of coding this whole thing is held up with ducktape could you try to explain more what you mean by that?

      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      yea i just did that and i get this error in the console:

      0|MagicMirror  | [14.01.2023 13:01.03.714] [LOG]   Received QUESTION notification with payload:  What is the weather like today?
      0|MagicMirror  | [14.01.2023 13:01.03.724] [LOG]   Error in getResponse:  TypeError: Cannot set properties of undefined (setting 'apiKey')
      0|MagicMirror  |     at /home/pi/MagicMirror/modules/chatgpt/node_helper.js:12:27
      0|MagicMirror  |     at new Promise (<anonymous>)
      0|MagicMirror  |     at Class.getResponse (/home/pi/MagicMirror/modules/chatgpt/node_helper.js:11:16)
      0|MagicMirror  |     at Class.socketNotificationReceived (/home/pi/MagicMirror/modules/chatgpt/node_helper.js:31:18)
      0|MagicMirror  |     at Socket.<anonymous> (/home/pi/MagicMirror/js/node_helper.js:108:11)
      0|MagicMirror  |     at Socket.emit (node:events:513:28)
      0|MagicMirror  |     at Socket.emitUntyped (/home/pi/MagicMirror/node_modules/socket.io/dist/typed-events.js:69:22)
      0|MagicMirror  |     at /home/pi/MagicMirror/node_modules/socket.io/dist/socket.js:614:39
      0|MagicMirror  |     at process.processTicksAndRejections (node:internal/process/task_queues:78:11)
      
      

      and this is my node_helper file:

      
      const NodeHelper = require("node_helper");
      const openai = require("openai").default;
      console.log(openai);
      module.exports = NodeHelper.create({
          start: function() {
              console.log("Starting node helper for: " + this.name);
          },
      
          // Send a message to the chatGPT API and receive a response
          getResponse: function(question) {
              return new Promise((resolve, reject) => {
                  openai.apiKey = "XXXXXXXXXXXXXX";
                  openai.Completion.create({
                      prompt: question,
                      temperature: 0.7
                  }, (error, response) => {
                      if (error) {
                          reject(error);
                      } else {
                          console.log("Received response from API: ", response);
                          resolve(response.choices[0].text);
                      }
                  });
              });
          },
      
          // Handle socket notifications
          socketNotificationReceived: function(notification, payload) {
              if (notification === "QUESTION") {
                  console.log("Received QUESTION notification with payload: ", payload);
                  this.getResponse(payload)
                  .then((response) => {
                      console.log("Sending RESPONSE notification with payload: ", response);
                      this.sendSocketNotification("RESPONSE", response);
                  })
                  .catch((error) => {
                      console.log("Error in getResponse: ", error);
                  });
              }
          },
      });
      
      
      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      i think the problem is with node helper not actually sending a api request because if i look in usage tab on the openai api page it should show activity but it says that it has not recieved any api requests:
      4ecfdd7e-4946-42c7-ac6c-c4acdf48d673-image.png
      but it should work! im going too look into it now and see if i can fix it.

      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      yea i fixed that problem but now with the same script it is just stuck at loading response

      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      as i have said before i am very bad at making custom code i have been stuggling for the past 2 days and i have a code that i thought would work but when i restart the magicmirror it just shows this:
      c5aee40c-b0bc-4c8d-a2db-04da5dbc8511-image.png
      its just stuck on “loading response…”
      this is all my code:

      chatgpt.js:

      Module.register("chatgpt", {
          // Default module config.
          defaults: {
              question: "What is the weather like today?"
          },
      
          // Define start sequence.
          start: function() {
              Log.info("Starting module: " + this.name);
              this.sendSocketNotification("QUESTION", this.config.question);
          },
      
          // Override socket notification handler.
          socketNotificationReceived: function(notification, payload) {
              if (notification === "RESPONSE") {
                  this.response = payload;
                  this.updateDom();
              }
          },
      
          // Override dom generator.
          getDom: function() {
              var wrapper = document.createElement("div");
              if (this.response) {
                  wrapper.innerHTML = this.response;
              } else {
                  wrapper.innerHTML = "Loading response...";
              }
              return wrapper;
          }
      });
      
      

      and here is my node_helper.js script:

      const NodeHelper = require("node_helper");
      const openai = require("openai");
      
      module.exports = NodeHelper.create({
          start: function() {
              console.log("Starting node helper for: " + this.name);
          },
      
          // Send a message to the chatGPT API and receive a response
          getResponse: function(question) {
              openai.apiKey = "XXXXXXXXXXXXXXXXXXXXXXX";
              openai.Completion.create({
                  prompt: question,
                  temperature: 0.7
              }, (error, response) => {
                  if (error) {
                      console.log(error);
                  } else {
                      return response.choices[0].text;
                  }
              });
          },
      
          // Handle socket notifications
          socketNotificationReceived: function(notification, payload) {
              if (notification === "CONNECT") {
                  var response = this.getResponse(payload.question);
                  this.sendSocketNotification("ANSWER", response);
              }
          },
      });
      
      

      and finally this is the config file code:

      {
          module: "chatgpt",
          position: "bottom_bar",
      classes: "always",
          config: {
              question: "What is the weather like today?",
          },
          node_helper: "node_helper.js",
      },
      
      

      i dont understand why it doesnt show up if anyone has any idea why it would be appreciated.

      this is my logs:

      
      [13.01.2023 15:44.15.423] [LOG]   Initializing new module helper ...
      [13.01.2023 15:44.15.424] [LOG]   Module helper loaded: Gateway
      [13.01.2023 15:44.15.820] [LOG]   Initializing new module helper ...
      [13.01.2023 15:44.15.820] [LOG]   Module helper loaded: MMM-GoogleAssistant
      [13.01.2023 15:44.15.824] [LOG]   Initializing new module helper ...
      [13.01.2023 15:44.15.824] [LOG]   Module helper loaded: EXT-Detector
      [13.01.2023 15:44.16.275] [LOG]   Initializing new module helper ...
      [13.01.2023 15:44.16.276] [LOG]   Module helper loaded: EXT-Spotify
      [13.01.2023 15:44.16.519] [LOG]   Initializing new module helper ...
      [13.01.2023 15:44.16.520] [LOG]   Module helper loaded: EXT-YouTubeCast
      [13.01.2023 15:44.16.773] [LOG]   Initializing new module helper ...
      [13.01.2023 15:44.16.773] [LOG]   Module helper loaded: EXT-Librespot
      [13.01.2023 15:44.16.776] [LOG]   Initializing new module helper ...
      [13.01.2023 15:44.16.777] [LOG]   Module helper loaded: EXT-Browser
      [13.01.2023 15:44.16.777] [LOG]   All module helpers loaded.
      [13.01.2023 15:44.16.790] [LOG]   Starting server on port 8080 ... 
      [13.01.2023 15:44.16.793] [WARN]  You're using a full whitelist configuration to allow for all IPs
      [13.01.2023 15:44.16.809] [LOG]   Server started ...
      [13.01.2023 15:44.16.810] [LOG]   Connecting socket for: chatgpt
      [13.01.2023 15:44.16.811] [LOG]   Starting node helper for: chatgpt
      [13.01.2023 15:44.16.826] [LOG]   Connecting socket for: MMM-Remote-Control
      [13.01.2023 15:44.16.827] [LOG]   Starting node helper for: MMM-Remote-Control
      [13.01.2023 15:44.16.833] [LOG]   Connecting socket for: MMM-PushBulletNotifications
      [13.01.2023 15:44.16.834] [LOG]   Connecting socket for: mmpm
      [13.01.2023 15:44.16.835] [LOG]   Starting module helper: mmpm
      [13.01.2023 15:44.16.835] [LOG]   Connecting socket for: MMM-Face-Reco-DNN
      [13.01.2023 15:44.16.836] [LOG]   Starting module helper: MMM-Face-Reco-DNN
      [13.01.2023 15:44.16.836] [LOG]   Connecting socket for: MMM-Skolmaten
      [13.01.2023 15:44.16.837] [LOG]   Connecting socket for: updatenotification
      [13.01.2023 15:44.16.838] [LOG]   Starting module helper: updatenotification
      [13.01.2023 15:44.16.839] [LOG]   Connecting socket for: Gateway
      [13.01.2023 15:44.16.841] [LOG]   Connecting socket for: MMM-GoogleAssistant
      [13.01.2023 15:44.16.842] [LOG]   [GA] Read config.js and check ConfigDeepMerge...
      [13.01.2023 15:44.16.843] [LOG]   [GA] Perfect ConfigDeepMerge activated!
      [13.01.2023 15:44.16.844] [LOG]   Connecting socket for: EXT-Detector
      [13.01.2023 15:44.16.845] [LOG]   [DETECTOR] EXT-Detector Version: 1.0.1 rev: 220315
      [13.01.2023 15:44.16.846] [LOG]   Connecting socket for: EXT-Spotify
      [13.01.2023 15:44.16.847] [LOG]   Connecting socket for: EXT-YouTubeCast
      [13.01.2023 15:44.16.848] [LOG]   Starting module helper: EXT-YouTubeCast
      [13.01.2023 15:44.16.848] [LOG]   Connecting socket for: EXT-Librespot
      [13.01.2023 15:44.16.850] [LOG]   Connecting socket for: EXT-Browser
      [13.01.2023 15:44.16.850] [LOG]   Starting module helper: EXT-Browser
      [13.01.2023 15:44.16.851] [LOG]   Sockets connected & modules started ...
      [13.01.2023 15:44.17.083] [LOG]   Launching application.
      [13.01.2023 15:44.19.211] [ERROR] ERROR! Could not validate main module js file.
      [13.01.2023 15:44.19.218] [ERROR] ReferenceError: Log is not defined
          at Object.<anonymous> (/home/pi/MagicMirror/modules/MMM-RAIN-MAP/MMM-RAIN-MAP.js:28:151853)
          at Module._compile (node:internal/modules/cjs/loader:1141:14)
          at Module._extensions..js (node:internal/modules/cjs/loader:1196:10)
          at Module.load (node:internal/modules/cjs/loader:1011:32)
          at Module._load (node:internal/modules/cjs/loader:846:12)
          at f._load (node:electron/js2c/asar_bundle:2:13328)
          at Module.require (node:internal/modules/cjs/loader:1035:19)
          at require (node:internal/modules/cjs/helpers:102:18)
          at Class.loadModuleDefaultConfig (/home/pi/MagicMirror/modules/MMM-Remote-Control/node_helper.js:313:30)
          at /home/pi/MagicMirror/modules/MMM-Remote-Control/node_helper.js:267:26
      [13.01.2023 15:44.25.545] [LOG]   [MMM-PushBulletNotifications][Info] 15:44:25.456 - START received
      [13.01.2023 15:44.25.712] [INFO]  Checking git for module: chatgpt
      [13.01.2023 15:44.25.724] [LOG]   [GATEWAY] Gateway Version: 2.2.4 rev: 230105
      [13.01.2023 15:44.25.750] [LOG]   [GA] MMM-GoogleAssistant Version: 4.0.8 rev: 221210
      [13.01.2023 15:44.25.756] [LOG]   [GA] Platform: 'raspberry-pi'; attempting to use 'arecord' to access microphone ...
      [13.01.2023 15:44.25.766] [LOG]   [GA] RECIPE_LOADED: ../../EXT-Spotify/recipe/EXT-Spotify.js
      [13.01.2023 15:44.25.770] [LOG]   [GA] RECIPE_LOADED: ../../MMM-NewsFeed/recipe/MMM-NewsFeed.js
      [13.01.2023 15:44.25.778] [LOG]   [GA] RECIPE_LOADED: grej.js
      [13.01.2023 15:44.25.782] [LOG]   [GA] RECIPE_LOADED: iss.js
      [13.01.2023 15:44.25.785] [LOG]   [GA] Google Assistant is initialized.
      [13.01.2023 15:44.25.789] [LOG]   [SPOTIFY] EXT-Spotify Version: 2.0.5 rev: 221127
      [13.01.2023 15:44.25.827] [LOG]   [CAST] EXT-YouTubeCast Version: 1.0.4 rev: 220805
      [13.01.2023 15:44.25.841] [LOG]   [CAST] {
        debug: true,
        fullscreen: true,
        alwaysDisplayed: false,
        width: '30vw',
        height: '30vh',
        castName: 'MagiskaSpegeln',
        port: 8569
      }
      [13.01.2023 15:44.25.847] [LOG]   [CAST] Starting Cast module...
      [13.01.2023 15:44.25.872] [LOG]   [LIBRESPOT] EXT-Librespot Version: 1.0.3 rev: 220815
      [13.01.2023 15:44.25.874] [LOG]   [LIBRESPOT] Launch Librespot...
      [13.01.2023 15:44.25.896] [LOG]   [LINKS] EXT-Browser Version: 1.0.0 rev: 220228
      [13.01.2023 15:44.25.908] [LOG]   [CAST] MagiskaSpegeln is listening on port 8569
      [13.01.2023 15:44.26.317] [INFO]  Checking git for module: MMM-Remote-Control
      [13.01.2023 15:44.26.420] [LOG]   [DETECTOR] All needed @bugsounet library loaded !
      [13.01.2023 15:44.26.424] [LOG]   [DETECTOR] Platform: 'raspberry-pi'; attempting to use 'arecord' to access microphone ...
      [13.01.2023 15:44.26.432] [LOG]   [DETECTOR] Snowboy is initialized with 1 Models: jarvis
      [13.01.2023 15:44.26.631] [LOG]   [GATEWAY] Loaded: node-pty
      [13.01.2023 15:44.27.247] [LOG]   [GATEWAY] Loaded: ./tools/tools.js
      [13.01.2023 15:44.27.364] [LOG]   [DETECTOR] Starts listening. 1 Models
      [13.01.2023 15:44.27.372] [LOG]   [GATEWAY] Start app...
      [13.01.2023 15:44.27.373] [LOG]   [GATEWAY] EXT plugins in database: 34
      [13.01.2023 15:44.27.373] [WARN]  [GATEWAY] WARN: You are using default username or default password
      [13.01.2023 15:44.27.374] [WARN]  [GATEWAY] WARN: Don't forget to change it!
      [13.01.2023 15:44.27.410] [LOG]   [GATEWAY] Find 10 installed plugins in MagicMirror
      [13.01.2023 15:44.27.411] [LOG]   [GATEWAY] Find 6 configured plugins in config file
      [13.01.2023 15:44.27.415] [LOG]   [GATEWAY] Find MMM-GoogleAssistant v4.0.8
      [13.01.2023 15:44.27.415] [LOG]   [GATEWAY] Find MMM-GoogleAssistant configured in MagicMirror
      [13.01.2023 15:44.27.416] [LOG]   [GATEWAY] webviewTag Configured: true
      [13.01.2023 15:44.27.417] [LOG]   [GATEWAY] Language set undefined
      [13.01.2023 15:44.27.443] [LOG]   [GATEWAY] Create all needed routes...
      [13.01.2023 15:44.28.541] [LOG]   [HyperWatch] Logger is enabled
      [13.01.2023 15:44.28.547] [LOG]   [GATEWAY] Start listening on http://192.168.1.126:8081
      [13.01.2023 15:44.28.825] [INFO]  Checking git for module: MMM-PushBulletNotifications
      [13.01.2023 15:44.29.174] [LOG]   [CAST] PONG YouTube {
        name: 'YouTube',
        state: 'stopped',
        allowStop: true,
        pid: null,
        launch: [Function: launch]
      }
      [13.01.2023 15:44.29.687] [INFO]  Checking git for module: MMM-Face-Multi-User-Recognition-SMAI
      [13.01.2023 15:44.29.820] [LOG]   [LIBRESPOT] Connected!
      [13.01.2023 15:44.30.069] [INFO]  Checking git for module: mmpm
      [13.01.2023 15:44.30.071] [INFO]  Checking git for module: MMM-Face-Reco-DNN
      [13.01.2023 15:44.30.258] [LOG]   [LIBRESPOT] Librespot already launched
      [13.01.2023 15:44.30.414] [INFO]  Checking git for module: MMM-RAIN-MAP
      [13.01.2023 15:44.30.548] [INFO]  Checking git for module: MMM-Weather-SMHI
      [13.01.2023 15:44.30.670] [INFO]  Checking git for module: MMM-Skolmaten
      [13.01.2023 15:44.30.806] [INFO]  Checking git for module: Gateway
      [13.01.2023 15:44.30.981] [INFO]  Checking git for module: MMM-GoogleAssistant
      [13.01.2023 15:44.31.077] [LOG]   [MMM-PushBulletNotifications][Info] 15:44:31.75 - PushBullet connected
      [13.01.2023 15:44.31.087] [INFO]  Checking git for module: EXT-Detector
      [13.01.2023 15:44.31.183] [INFO]  Checking git for module: EXT-Spotify
      [13.01.2023 15:44.31.297] [INFO]  Checking git for module: EXT-YouTubeCast
      [13.01.2023 15:44.31.407] [INFO]  Checking git for module: EXT-Librespot
      [13.01.2023 15:44.31.582] [INFO]  Checking git for module: EXT-Browser
      [13.01.2023 15:44.31.697] [INFO]  Checking git for module: default
      [13.01.2023 15:44.34.493] [LOG]   [MMM-Face-Reco-DNN] loading encodings + face detector...
      [13.01.2023 15:44.34.551] [LOG]   [MMM-Face-Reco-DNN] starting video stream...
      
      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      @sdetweil if for a start i use this super simple code:
      import openai

      openai.Completion.create(
      engine=“davinci”,
      prompt=“Make a list of astronomical observatories:”
      )

      how would i make the answer show up on the magicmirror

      posted in Requests
      S
      SILLEN 0
    • RE: ChatGpt intergration

      @sdetweil ok but if i wanted to start with just a preconfigured text without voice input. how would i do that the simplest way. i have little too no coding and i could probobally make a script for displaying an answer in a command line but i have no idea on how to display anything on the magicmirror.

      posted in Requests
      S
      SILLEN 0
    • 1
    • 2
    • 1 / 2