-
Notifications
You must be signed in to change notification settings - Fork 109
Open
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- Programming language: Typescript
- OS: MacOS
- Package version: 1.10.0
Steps to reproduce
- upload a JSON file from an in memory JSON object
- Try and use it
example:
import dotenv from "dotenv";
dotenv.config();
import { createPartFromUri, GoogleGenAI } from "@google/genai";
const gemini = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
export async function main() {
let someJson = await gemini.files.upload({
file: new Blob([Buffer.from(JSON.stringify({ hey: "yo" }))]),
config: {
mimeType: "application/json",
},
});
let filesProcessed = false;
while (!filesProcessed) {
if (someJson.state === "PROCESSING") {
console.log(`[INFO] Files processing, waiting 2s`);
await new Promise((resolve) => {
setTimeout(resolve, 2000);
});
} else {
filesProcessed = true;
someJson = await gemini.files.get({
name: someJson.name as string,
});
console.log(`[INFO] Markdown file processed, state: ${someJson.state}`);
}
}
const response = await gemini.models.generateContent({
model: "gemini-2.5-flash",
contents: [
createPartFromUri(someJson.uri as string, someJson.mimeType as string),
`I have provided you with a JSON, tell me something about it`,
],
});
console.log(response.text);
}
main()
.then(() => process.exit(0))
.catch((e) => {
console.error(e);
process.exit(1);
});
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.