Coder Social home page Coder Social logo

klich3 / firebase-gpt-chat-completion-stream Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 1.0 94 KB

Example of ChatGPT Stream implementation in Firebase with functions. For this method you have to use `fetch`.

License: MIT License

JavaScript 100.00%
chatgpt chatgpt-api firebase firebase-function firebase-functions gpt openai openai-api

firebase-gpt-chat-completion-stream's Introduction

firebase-gpt-chat-completion-stream's People

Contributors

klich3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

dingdalton

firebase-gpt-chat-completion-stream's Issues

Is it working in 2024?

Used the same code and got this error.

This is my log:

2024-02-29T21:56:50.449242Z ? gptPromptStream:     at processTicksAndRejections (node:internal/process/task_queues:78:11)
2024-02-29T21:56:50.461221900Z D gptPromptStream: Function execution took 64 ms, finished with status: 'crash'
2024-02-29T21:57:31.220523375Z D gptPromptStream: Function execution started
2024-02-29T21:57:31.294477Z E gptPromptStream: SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
2024-02-29T21:57:31.294489Z ? gptPromptStream:     at /workspace/index.js:21:26
2024-02-29T21:57:31.294497Z ? gptPromptStream:     at cloudFunction (/workspace/node_modules/firebase-functions/lib/v1/providers/https.js:51:16)
2024-02-29T21:57:31.294504Z ? gptPromptStream:     at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:98:17
2024-02-29T21:57:31.294510Z ? gptPromptStream:     at processTicksAndRejections (node:internal/process/task_queues:78:11)
2024-02-29T21:57:31.295781815Z D gptPromptStream: Function execution took 75 ms, finished with status: 'crash'
2024-02-29T21:57:35.357779095Z D gptPromptStream: Function execution started
2024-02-29T21:57:35.361857Z E gptPromptStream: SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
2024-02-29T21:57:35.361868Z ? gptPromptStream:     at /workspace/index.js:21:26
2024-02-29T21:57:35.361875Z ? gptPromptStream:     at cloudFunction (/workspace/node_modules/firebase-functions/lib/v1/providers/https.js:51:16)
2024-02-29T21:57:35.361882Z ? gptPromptStream:     at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:98:17
2024-02-29T21:57:35.361887Z ? gptPromptStream:     at processTicksAndRejections (node:internal/process/task_queues:78:11)
2024-02-29T21:57:35.363138113Z D gptPromptStream: Function execution took 5 ms, finished with status: 'crash'
2024-02-29T21:57:37.293975747Z D gptPromptStream: Function execution started
2024-02-29T21:57:37.297647Z E gptPromptStream: SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
2024-02-29T21:57:37.297659Z ? gptPromptStream:     at /workspace/index.js:21:26
2024-02-29T21:57:37.297667Z ? gptPromptStream:     at cloudFunction (/workspace/node_modules/firebase-functions/lib/v1/providers/https.js:51:16)
2024-02-29T21:57:37.297673Z ? gptPromptStream:     at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:98:17
2024-02-29T21:57:37.297678Z ? gptPromptStream:     at processTicksAndRejections (node:internal/process/task_queues:78:11)
2024-02-29T21:57:37.298594712Z D gptPromptStream: Function execution took 4 ms, finished with status: 'crash'
2024-02-29T21:58:19.483189427Z D gptPromptStream: Function execution started
2024-02-29T21:58:19.488550Z E gptPromptStream: SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
2024-02-29T21:58:19.488573Z ? gptPromptStream:     at /workspace/index.js:21:26
2024-02-29T21:58:19.488581Z ? gptPromptStream:     at cloudFunction (/workspace/node_modules/firebase-functions/lib/v1/providers/https.js:51:16)
2024-02-29T21:58:19.488587Z ? gptPromptStream:     at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:98:17
2024-02-29T21:58:19.488592Z ? gptPromptStream:     at processTicksAndRejections (node:internal/process/task_queues:78:11)
2024-02-29T21:58:19.489984676Z D gptPromptStream: Function execution took 6 ms, finished with status: 'crash'
2024-02-29T22:00:21.119884905Z D gptPromptStream: Function execution started
2024-02-29T22:00:22.547396Z E gptPromptStream: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:387:5)
    at ServerResponse.setHeader (node:_http_outgoing:644:11)
    at ServerResponse.header (/layers/google.nodejs.functions-framework/functions-framework/node_modules/express/lib/response.js:794:10)
    at ServerResponse.json (/layers/google.nodejs.functions-framework/functions-framework/node_modules/express/lib/response.js:275:10)
    at ServerResponse.send (/layers/google.nodejs.functions-framework/functions-framework/node_modules/express/lib/response.js:162:21)
    at /workspace/index.js:85:19
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
2024-02-29T22:01:04.201310994Z D gptPromptStream: Function execution started
2024-02-29T22:01:05.719887Z E gptPromptStream: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:387:5)
    at ServerResponse.setHeader (node:_http_outgoing:644:11)
    at ServerResponse.header (/layers/google.nodejs.functions-framework/functions-framework/node_modules/express/lib/response.js:794:10)
    at ServerResponse.json (/layers/google.nodejs.functions-framework/functions-framework/node_modules/express/lib/response.js:275:10)
    at ServerResponse.send (/layers/google.nodejs.functions-framework/functions-framework/node_modules/express/lib/response.js:162:21)
    at /workspace/index.js:85:19
    at processTicksAndRejections (node:internal/process/task_queues:96:5)```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.