generative-ai
generative-ai copied to clipboard
base nodejs,Need to be able to pass in the agent, thx
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 Can you provide more context on this issue?
Is this part of a Notebook from this repository, or some other kind of code sample?
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.