Git Product home page Git Product logo

Comments (6)

babaohuang avatar babaohuang commented on July 4, 2024

I have tried it , but i didn't work , maybe the Astro 2 doesn't support this feature ?

from geminiprochat.

lwd-temp avatar lwd-temp commented on July 4, 2024

I'm afraid not. Next.js is by Vercel, so there's an official support.

We could have rewritten the request function using the following method:

import type { VercelRequest, VercelResponse } from '@vercel/node';
 
export const config = {
  runtime: 'edge', // this is a pre-requisite
  // execute this function on iad1 or hnd1, based on the connecting client location
  regions: ['iad1', 'hnd1'],
};
 
export default function handler(
  request: VercelRequest,
  response: VercelResponse,
) {
  return response.status(200).json({
    text: `I am an Edge Function! (executed on ${process.env.VERCEL_REGION})`,
  });
}

But because it is actually wrapped in @google/generative-ai, we cannot modify it.

from geminiprochat.

babaohuang avatar babaohuang commented on July 4, 2024

I'm afraid not. Next.js is by Vercel, so there's an official support.

We could have rewritten the request function using the following method:

import type { VercelRequest, VercelResponse } from '@vercel/node';
 
export const config = {
  runtime: 'edge', // this is a pre-requisite
  // execute this function on iad1 or hnd1, based on the connecting client location
  regions: ['iad1', 'hnd1'],
};
 
export default function handler(
  request: VercelRequest,
  response: VercelResponse,
) {
  return response.status(200).json({
    text: `I am an Edge Function! (executed on ${process.env.VERCEL_REGION})`,
  });
}

But because it is actually wrapped in @google/generative-ai, we cannot modify it.

but this project is not base on Next.js framework

from geminiprochat.

lwd-temp avatar lwd-temp commented on July 4, 2024

Yes, so we may try the "Other frameworks" example, but we have to refrain from using @google/generative-ai and must rewrite the functionalities it provides on our own.

The docs require using VercelRequest, VercelResponse from @vercel/node, but @google/generative-ai (actually sends the request) won't follow it.

It is also possible that Google will eventually notice this issue and modify @google/generative-ai. Perhaps we should provide feedback to both Google and Vercel first?

I'm not familiar with modern front-end frameworks, so sorry for any confusion.

from geminiprochat.

babaohuang avatar babaohuang commented on July 4, 2024

this issue has a perfect solution now , see here

from geminiprochat.

lwd-temp avatar lwd-temp commented on July 4, 2024

Thank you for your efforts.

Just a kindly reminder, proxies are not allowed in Vercel Fair Use Policy, though Vercel seldom intervenes in these matters.

from geminiprochat.

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.