generative-ai icon indicating copy to clipboard operation
generative-ai copied to clipboard

base nodejs,Need to be able to pass in the agent, thx

Open lbjfish opened this issue 2 years ago • 1 comments

base nodejs,Need to be able to pass in the agent, thx The current interface uses fetch, and I hope to provide agent proxy parameters.

async function makeRequest(url, body) {
    let response;
    try {
        response = await fetch(url, {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
                "x-goog-api-client": getClientHeaders(),
            },
            body,
        });
        if (!response.ok) {
            let message = "";
            try {
                const json = await response.json();
                message = json.error.message;
                if (json.error.details) {
                    message += ` ${JSON.stringify(json.error.details)}`;
                }
            }
            catch (e) {
                // ignored
            }
            throw new Error(`[${response.status} ${response.statusText}] ${message}`);
        }
    }
    catch (e) {
        const err = new GoogleGenerativeAIError(`Error fetching from ${url}: ${e.message}`);
        err.stack = e.stack;
        throw err;
    }
    return response;
}

lbjfish avatar Dec 17 '23 07:12 lbjfish

@lbjfish Can you provide more context on this issue?

Is this part of a Notebook from this repository, or some other kind of code sample?

holtskinner avatar Dec 18 '23 19:12 holtskinner

This repository is for Generative AI with Vertex AI on Google Cloud, not the Google AI Gemini/PaLM APIs.

This looks like it could be the JavaScript client library, so you can try filing an issue in this repository:

https://github.com/google/generative-ai-js

or ask in the Google Developers Community Discord #gemini-api channel.

holtskinner avatar Feb 22 '24 17:02 holtskinner