Skip to content

Commit

Permalink
Fix notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Dec 4, 2024
1 parent 4d88f0a commit a4ebc16
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,8 @@
"const cachedContent = await cacheManager.create({\n",
" model: \"models/gemini-1.5-flash-001\",\n",
" displayName: displayName,\n",
" systemInstruction,\n",
" systemInstruction: \"You are an expert video analyzer, and your job is to answer \" +\n",
" \"the user's query based on the video file you have access to.\",\n",
" contents: [\n",
" {\n",
" role: \"user\",\n",
Expand Down
18 changes: 12 additions & 6 deletions libs/langchain-google-genai/src/tests/context_caching.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ const model = new ChatGoogleGenerativeAI({});
let fileResult: UploadFileResponse;

beforeAll(async () => {
const displayName = "Gettysburg audio";
// Download video file and save in src/tests/data
// curl -O https://storage.googleapis.com/generativeai-downloads/data/Sherlock_Jr_FullMovie.mp4
const displayName = "Sherlock Jr. video";

const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
const pathToVideoFile = path.join(dirname, "/data/gettysburg10.wav");
const pathToVideoFile = path.join(dirname, "/data/Sherlock_Jr_FullMovie.mp4");

const contextCache = new GoogleAICacheManager(
process.env.GOOGLE_API_KEY || ""
);
const fileCache = new GoogleAIFileManager(process.env.GOOGLE_API_KEY || "");
fileResult = await fileCache.uploadFile(pathToVideoFile, {
displayName,
mimeType: "audio/wav",
mimeType: "video/mp4",
});

const { name } = fileResult.file;
Expand All @@ -45,8 +47,8 @@ beforeAll(async () => {
}

const systemInstruction =
"You are an expert audio analyzer, and your job is to answer " +
"the user's query based on the audio file you have access to.";
"You are an expert video analyzer, and your job is to answer " +
"the user's query based on the video file you have access to.";
const cachedContent = await contextCache.create({
model: "models/gemini-1.5-flash-001",
displayName: "gettysburg audio",
Expand All @@ -71,7 +73,11 @@ beforeAll(async () => {
}, 10 * 60 * 1000); // Set timeout to 10 minutes to upload file

test("Test Google AI", async () => {
const res = await model.invoke("Transcribe the provided audio clip");
const res = await model.invoke(
"Introduce different characters in the movie by describing " +
"their personality, looks, and names. Also list the " +
"timestamps they were introduced for the first time."
);

console.log(res);
expect(res).toBeTruthy();
Expand Down

0 comments on commit a4ebc16

Please sign in to comment.