MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    ChatGpt intergration

    Scheduled Pinned Locked Moved Unsolved Requests
    59 Posts 7 Posters 35.9k Views 8 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Do not disturb
      sdetweil @SILLEN 0
      last edited by sdetweil

      @SILLEN-0 what is the data format of the response?, text, json, ???

      you said

      ‘say banana’

      did it return a wav file?

      if u add the MMM-Logging module, then u can see all the logs in one place (output of npm start)

      socket-io requires a serializable object

      says error is in getResponse() function,

      so, did your module get multiple requests concurrently and send them on?

      I would make the notification string more specific. ‘gpt question’

      there are hundreds of notifications going on, possible there was another module sending that same string…

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      1 Reply Last reply Reply Quote 0
      • S Do not disturb
        sdetweil @SILLEN 0
        last edited by sdetweil

        @SILLEN-0 also that is the error part of the pm2 logs --lines output

        when I am developing

        I don’t use pm2,
        I just do

        npm start  >somefile.txt 2>&1
        

        in the MagicMirror folder

        then all the console output is in one file.
        adding the logging module will reflect all the modulename.js log statements too

        AND you can debug on the mm UI , ctrl-shift-i,
        select the sources tab, find your module name.js in the left nav,

        and you can put stops on lines of code and step thru it

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        S 1 Reply Last reply Reply Quote 0
        • S Offline
          SILLEN 0 @sdetweil
          last edited by

          @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.

          S 1 Reply Last reply Reply Quote 0
          • S Do not disturb
            sdetweil @SILLEN 0
            last edited by

            @SILLEN-0 the data back from the api looks like this

                status: 200,
                statusText: 'OK',
                headers: {
                  date: 'Sun, 29 Jan 2023 23:56:49 GMT',
                  'content-type': 'application/json',
                  'content-length': '343',
                  connection: 'close',
                  'access-control-allow-origin': '*',
                  'cache-control': 'no-cache, must-revalidate',
                  'openai-model': 'text-davinci-003',
                  'openai-organization': 'user-ieyrbalt3azhd9sd82splktg',
                  'openai-processing-ms': '2790',
                  'openai-version': '2020-10-01',
                  'strict-transport-security': 'max-age=15724800; includeSubDomains',
                  'x-request-id': 'd341b29147db89ee20886107e22b41a4'
                },
                config: {
                  transitional: [Object],
                  adapter: [Function: httpAdapter],
                  transformRequest: [Array],
                  transformResponse: [Array],
                  timeout: 0,
                  xsrfCookieName: 'XSRF-TOKEN',
                  xsrfHeaderName: 'X-XSRF-TOKEN',
                  maxContentLength: -1,
                  maxBodyLength: -1,
                  validateStatus: [Function: validateStatus],
                  headers: [Object],
                  method: 'post',
                  data: '{"model":"text-davinci-003","prompt":"What is the weather like today?","temperature":0.7}',
                  url: 'https://api.openai.com/v1/completions'
                },
                request: ClientRequest {
                  _events: [Object: null prototype],
                  _eventsCount: 7,
                  _maxListeners: undefined,
                  outputData: [],
                  outputSize: 0,
                  writable: true,
                  destroyed: false,
                  _last: true,
                  chunkedEncoding: false,
                  shouldKeepAlive: false,
                  maxRequestsOnConnectionReached: false,
                  _defaultKeepAlive: true,
                  useChunkedEncodingByDefault: true,
                  sendDate: false,
                  _removedConnection: false,
                  _removedContLen: false,
                  _removedTE: false,
                  _contentLength: null,
                  _hasBody: true,
                  _trailer: '',
                  finished: true,
                  _headerSent: true,
                  _closed: false,
                  socket: [TLSSocket],
                  _header: 'POST /v1/completions HTTP/1.1\r\n' +
                    'Accept: application/json, text/plain, */*\r\n' +
                    'Content-Type: application/json\r\n' +
                    'User-Agent: OpenAI/NodeJS/3.1.0\r\n' +
                    'Authorization: Bearer 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\r\n' +
                    'Content-Length: 89\r\n' +
                    'Host: api.openai.com\r\n' +
                    'Connection: close\r\n' +
                    '\r\n',
                  _keepAliveTimeout: 0,
                  _onPendingData: [Function: nop],
                  agent: [Agent],
                  socketPath: undefined,
                  method: 'POST',
                  maxHeaderSize: undefined,
                  insecureHTTPParser: undefined,
                  path: '/v1/completions',
                  _ended: true,
                  res: [IncomingMessage],
                  aborted: false,
                  timeoutCb: null,
                  upgradeOrConnect: false,
                  parser: null,
                  maxHeadersCount: null,
                  reusedSocket: false,
                  host: 'api.openai.com',
                  protocol: 'https:',
                  _redirectable: [Writable],
                  [Symbol(kCapture)]: false,
                  [Symbol(kNeedDrain)]: false,
                  [Symbol(corked)]: 0,
                  [Symbol(kOutHeaders)]: [Object: null prototype],
                  [Symbol(kUniqueHeaders)]: null
                },
                data: {
                  id: 'cmpl-6eBpQkPEmW4z1PoxRTTprs8Lhoqn4',
                  object: 'text_completion',
                  created: 1675036608,
                  model: 'text-davinci-003',
                  choices: [Array],
                  usage: [Object]
                }
              }
            
              answer: {
                status: 200,
                statusText: 'OK',
                headers: {
                  date: 'Sun, 29 Jan 2023 23:56:49 GMT',
                  'content-type': 'application/json',
                  'content-length': '343',
                  connection: 'close',
                  'access-control-allow-origin': '*',
                  'cache-control': 'no-cache, must-revalidate',
                  'openai-model': 'text-davinci-003',
                  'openai-organization': 'user-ieyrbalt3azhd9sd82splktg',
                  'openai-processing-ms': '2790',
                  'openai-version': '2020-10-01',
                  'strict-transport-security': 'max-age=15724800; includeSubDomains',
                  'x-request-id': 'd341b29147db89ee20886107e22b41a4'
                },
                config: {
                  transitional: [Object],
                  adapter: [Function: httpAdapter],
                  transformRequest: [Array],
                  transformResponse: [Array],
                  timeout: 0,
                  xsrfCookieName: 'XSRF-TOKEN',
                  xsrfHeaderName: 'X-XSRF-TOKEN',
                  maxContentLength: -1,
                  maxBodyLength: -1,
                  validateStatus: [Function: validateStatus],
                  headers: [Object],
                  method: 'post',
                  data: '{"model":"text-davinci-003","prompt":"What is the weather like today?","temperature":0.7}',
                  url: 'https://api.openai.com/v1/completions'
                },
                request: ClientRequest {
                  _events: [Object: null prototype],
                  _eventsCount: 7,
                  _maxListeners: undefined,
                  outputData: [],
                  outputSize: 0,
                  writable: true,
                  destroyed: false,
                  _last: true,
                  chunkedEncoding: false,
                  shouldKeepAlive: false,
                  maxRequestsOnConnectionReached: false,
                  _defaultKeepAlive: true,
                  useChunkedEncodingByDefault: true,
                  sendDate: false,
                  _removedConnection: false,
                  _removedContLen: false,
                  _removedTE: false,
                  _contentLength: null,
                  _hasBody: true,
                  _trailer: '',
                  finished: true,
                  _headerSent: true,
                  _closed: false,
                  socket: [TLSSocket],
                  _header: 'POST /v1/completions HTTP/1.1\r\n' +
                    'Accept: application/json, text/plain, */*\r\n' +
                    'Content-Type: application/json\r\n' +
                    'User-Agent: OpenAI/NodeJS/3.1.0\r\n' +
                    'Authorization: Bearer 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\r\n' +
                    'Content-Length: 89\r\n' +
                    'Host: api.openai.com\r\n' +
                    'Connection: close\r\n' +
                    '\r\n',
                  _keepAliveTimeout: 0,
                  _onPendingData: [Function: nop],
                  agent: [Agent],
                  socketPath: undefined,
                  method: 'POST',
                  maxHeaderSize: undefined,
                  insecureHTTPParser: undefined,
                  path: '/v1/completions',
                  _ended: true,
                  res: [IncomingMessage],
                  aborted: false,
                  timeoutCb: null,
                  upgradeOrConnect: false,
                  parser: null,
                  maxHeadersCount: null,
                  reusedSocket: false,
                  host: 'api.openai.com',
                  protocol: 'https:',
                  _redirectable: [Writable],
                  [Symbol(kCapture)]: false,
                  [Symbol(kNeedDrain)]: false,
                  [Symbol(corked)]: 0,
                  [Symbol(kOutHeaders)]: [Object: null prototype],
                  [Symbol(kUniqueHeaders)]: null
                },
                data: {
                  id: 'cmpl-6eBpQkPEmW4z1PoxRTTprs8Lhoqn4',
                  object: 'text_completion',
                  created: 1675036608,
                  model: 'text-davinci-003',
                  choices: [Array],
                  usage: [Object]
                }
              }
            

            i don’t see the text of the answer

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            P S 3 Replies Last reply Reply Quote 0
            • P Offline
              PraiseU Module Developer @sdetweil
              last edited by

              @sdetweil Hey any updates on this?

              1 Reply Last reply Reply Quote 0
              • P Offline
                PraiseU Module Developer @sdetweil
                last edited by

                @sdetweil Do you have any updates regarding the speech capture process?

                S 1 Reply Last reply Reply Quote 0
                • S Do not disturb
                  sdetweil @PraiseU
                  last edited by

                  @PraiseU I wasn’t working on any speech capture integration.

                  I outlined the possibilities

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  P 1 Reply Last reply Reply Quote 0
                  • P Offline
                    PraiseU Module Developer @sdetweil
                    last edited by

                    @sdetweil Oh okay! I found this Module https://github.com/TheStigh/MMM-VoiceCommander. Do you think it can be useful? or does it still have the problem with accuracy?

                    S 1 Reply Last reply Reply Quote 0
                    • S Do not disturb
                      sdetweil @PraiseU
                      last edited by

                      @PraiseU said in ChatGpt intergration:

                      @sdetweil Oh okay! I found this Module https://github.com/TheStigh/MMM-VoiceCommander. Do you think it can be useful? or does it still have the problem with accuracy?

                      yes, it is built on mmm-voice

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      1 Reply Last reply Reply Quote 0
                      • P Offline
                        PraiseU Module Developer @sdetweil
                        last edited by

                        @sdetweil Can you shed some light on what you mean by this “this is why the MMM-GoogleAssistant provides mechanisms (recipe) to use the captured text for non- google uses” And how can i approach this? Thanks a lot

                        S 1 Reply Last reply Reply Quote 0
                        • S Do not disturb
                          sdetweil @PraiseU
                          last edited by

                          @PraiseU it’s exactly what it says.

                          GoogleAssistant collects text from voice.
                          but many voice commands are not directed at Google itself. ($search, play, turn on/off lights…)

                          so, if you write a recipe you can direct the text to other purposes

                          Sam

                          How to add modules

                          learning how to use browser developers window for css changes

                          P 1 Reply Last reply Reply Quote 0
                          • P Offline
                            PraiseU Module Developer @sdetweil
                            last edited by

                            @sdetweil Oh Okay so If I was to say “GPT Explain software engineering” It will get the text and I can forward it to the module it needs to go to? Do you ahave an examples that can help?

                            S 1 Reply Last reply Reply Quote 0
                            • S Do not disturb
                              sdetweil @PraiseU
                              last edited by sdetweil

                              @PraiseU i mentioned how to do that before

                              Sam

                              How to add modules

                              learning how to use browser developers window for css changes

                              P 1 Reply Last reply Reply Quote 0
                              • P Offline
                                PraiseU Module Developer @sdetweil
                                last edited by

                                @sdetweil I think you mis-understood my question? I meant to ask how does the recipes work? Like whats the logic behind it?

                                S 1 Reply Last reply Reply Quote 0
                                • S Do not disturb
                                  sdetweil @PraiseU
                                  last edited by

                                  @PraiseU come on… think

                                  and investigate, look at the files. maybe his wiki

                                  if you wanted to take arbitrary text that means nothing to YOUR app, and let others do something, how would you do it?

                                  then make it general purpose.

                                  Sam

                                  How to add modules

                                  learning how to use browser developers window for css changes

                                  1 Reply Last reply Reply Quote 0
                                  • S Offline
                                    SILLEN 0 @sdetweil
                                    last edited by

                                    @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.

                                    S 2 Replies Last reply Reply Quote 0
                                    • S Do not disturb
                                      sdetweil @SILLEN 0
                                      last edited by

                                      @SILLEN-0 the node_helper cannot send that big structure to the module.

                                      sendSocketNotification uses socketio, which uses json stringify on send and parse on the receive.

                                      both are shallow copy functions anyhow

                                      Sam

                                      How to add modules

                                      learning how to use browser developers window for css changes

                                      1 Reply Last reply Reply Quote 0
                                      • S Do not disturb
                                        sdetweil @SILLEN 0
                                        last edited by

                                        @SILLEN-0 u might want to see this
                                        https://forum.magicmirror.builders/topic/17637/mmm-openai

                                        Sam

                                        How to add modules

                                        learning how to use browser developers window for css changes

                                        S 2 Replies Last reply Reply Quote 0
                                        • S Offline
                                          SILLEN 0 @sdetweil
                                          last edited by

                                          @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

                                          1 Reply Last reply Reply Quote 0
                                          • S Offline
                                            SILLEN 0 @sdetweil
                                            last edited by

                                            @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?

                                            M D 2 Replies Last reply Reply Quote 0

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better 💗

                                            Register Login
                                            • 1
                                            • 2
                                            • 3
                                            • 3 / 3
                                            • First post
                                              Last post
                                            Enjoying MagicMirror? Please consider a donation!
                                            MagicMirror created by Michael Teeuw.
                                            Forum managed by Sam, technical setup by Karsten.
                                            This forum is using NodeBB as its core | Contributors
                                            Contact | Privacy Policy