GithubHelp home page GithubHelp logo

Comments (3)

ferrannp avatar ferrannp commented on July 3, 2024 1

Hey @encima! So strange. Your code also errors for me locally:

Using supabase-edge-runtime-1.53.3 (compatible with Deno v1.40.3)
serving the request with /home/deno/functions/generate-workout
runtime has escaped from the event loop unexpectedly: event loop error: ReferenceError: _computedKey is not defined
    at https://deno.land/x/[email protected]/lib/ChatCompletionStream.ts:4:14
user worker failed to respond: user worker not available
TypeError: request body receiver not connected (channel closed)
    at Object.write (ext:deno_web/06_streams.js:1155:20)
    at Module.invokeCallbackFunction (ext:deno_webidl/00_webidl.js:944:16)
    at WritableStreamDefaultController.writeAlgorithm (ext:deno_web/06_streams.js:3915:14)
    at writableStreamDefaultControllerProcessWrite (ext:deno_web/06_streams.js:4485:55)
    at writableStreamDefaultControllerAdvanceQueueIfNeeded (ext:deno_web/06_streams.js:4388:5)
    at writableStreamDefaultControllerWrite (ext:deno_web/06_streams.js:4532:3)
    at writableStreamDefaultWriterWrite (ext:deno_web/06_streams.js:4679:3)
    at Object.chunkSteps (ext:deno_web/06_streams.js:2743:17)
    at readableStreamFulfillReadRequest (ext:deno_web/06_streams.js:2585:17)
    at readableByteStreamControllerCommitPullIntoDescriptor (ext:deno_web/06_streams.js:2276:5)

I have:

macOS: Sonoma 14.5
supabase-cli: 1.172.2
node: v18.16.0

from supabase.

encima avatar encima commented on July 3, 2024

Hey there,

Thanks for opening!
Is this on hosted or running locally?
I cannot reproduce this when running locally and the example in the docs works when using the Deno package you outlined:

import OpenAI from 'https://deno.land/x/[email protected]/mod.ts'

Deno.serve(async (req) => {
  const { query } = await req.json()
  const apiKey = Deno.env.get('OPENAI_API_KEY')
  const openai = new OpenAI({
    apiKey: apiKey,
  })

  // Documentation here: https://github.com/openai/openai-node
  const chatCompletion = await openai.chat.completions.create({
    messages: [{ role: 'user', content: query }],
    // Choose model from here: https://platform.openai.com/docs/models
    model: 'gpt-3.5-turbo',
    stream: false,
  })

  const reply = chatCompletion.choices[0].message.content

  return new Response(reply, {
    headers: { 'Content-Type': 'text/plain' },
  })
})

Are you making sure that you create the client inside the serve function? If yes, can you provide a full reproducible code sample, please?

from supabase.

msgerbush avatar msgerbush commented on July 3, 2024

Running into this same issue locally, if I downgrade the Supabase CLI to 1.166.3 it resolves the issue (it's broken starting at 1.167.0).

Looks related to an issue in the Deno runtime: denoland/deno#22109

from supabase.

Related Issues (20)

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.