Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add Context Cache support for ChatSessionPreview class #433

Conversation

oleksii-oleniuk-star
Copy link
Contributor

@oleksii-oleniuk-star oleksii-oleniuk-star commented Oct 2, 2024

Related issue

#395

How to reproduce a problem:

const vertexAi = new VertexAI({ project: projectId, location });
const options: ModelParams = {
    model,
    generationConfig,
    safetySettings,
};
const generativeModel = await vertexAi.preview.getGenerativeModelFromCachedContent(
    {
        name,
        model: "projects/${projectId}/locations/${location}/publishers/google/models/${modelId}",
    },
    options,
);

const chat = generativeModel.startChat({ history }); // here we receive an instance of ChatSessionPreview class

const streamGeneratedContentResult = await chat.sendMessageStream(lastMessageContent);
return streamGeneratedContentResult.stream;

Before this PR

Gemini Context Cache was ignored by ChatSessionPreview

After this PR

Gemini Context Cache works properly with ChatSessionPreview

Copy link

google-cla bot commented Oct 2, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@product-auto-label product-auto-label bot added the api: aiplatform Issues related to the googleapis/nodejs-vertexai API. label Oct 2, 2024
@oleksii-oleniuk-star oleksii-oleniuk-star changed the title Add Context Cache support for ChatSessionPreview class fix: Add Context Cache support for ChatSessionPreview class Oct 2, 2024
@yyyu-google yyyu-google requested a review from happy-qiao October 3, 2024 17:47
@yyyu-google yyyu-google added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 3, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 3, 2024
@happy-qiao happy-qiao changed the title fix: Add Context Cache support for ChatSessionPreview class feat: Add Context Cache support for ChatSessionPreview class Oct 4, 2024
@happy-qiao happy-qiao changed the title feat: Add Context Cache support for ChatSessionPreview class fix: Add Context Cache support for ChatSessionPreview class Oct 4, 2024
@happy-qiao happy-qiao added the ready to pull copybara github pr import label label Oct 4, 2024
@yyyu-google yyyu-google merged commit f8a3bdf into googleapis:main Oct 8, 2024
4 checks passed
copybara-service bot pushed a commit that referenced this pull request Oct 12, 2024
FUTURE_COPYBARA_INTEGRATE_REVIEW=#433 from oleksii-oleniuk-star:feature/gemini-context-cache-3 0b1251c
PiperOrigin-RevId: 685017723
copybara-service bot pushed a commit that referenced this pull request Oct 12, 2024
FUTURE_COPYBARA_INTEGRATE_REVIEW=#433 from oleksii-oleniuk-star:feature/gemini-context-cache-3 0b1251c
PiperOrigin-RevId: 685017723
copybara-service bot pushed a commit that referenced this pull request Oct 12, 2024
FUTURE_COPYBARA_INTEGRATE_REVIEW=#433 from oleksii-oleniuk-star:feature/gemini-context-cache-3 0b1251c
PiperOrigin-RevId: 685017723
copybara-service bot pushed a commit that referenced this pull request Oct 12, 2024
--
4807338 by release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>:

chore(main): release 1.8.1 (#429)

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
--
bef61c1 by Oleksii Oleniuk <[email protected]>:

add content cache to chat session

--
0313b2e by Oleksii Oleniuk <[email protected]>:

remove logs, add gitignore

COPYBARA_INTEGRATE_REVIEW=#433 from oleksii-oleniuk-star:feature/gemini-context-cache-3 0b1251c
PiperOrigin-RevId: 683762410
copybara-service bot pushed a commit that referenced this pull request Oct 16, 2024
--
f8a3bdf by Oleksii Oleniuk <[email protected]>:

fix: Add Context Cache support for ChatSessionPreview class (#433)

* add content cache to chat session

* remove logs, add gitignore

---------

Co-authored-by: Oleksii Oleniuk <[email protected]>
Co-authored-by: Yvonne Yu <[email protected]>
--
64ac1a8 by Wenhao <[email protected]>:

Fixed link in Part JSDoc

COPYBARA_INTEGRATE_REVIEW=#440 from WenHaozhan:fix/part-jsdoc 16bb232
PiperOrigin-RevId: 686218863
copybara-service bot pushed a commit that referenced this pull request Oct 16, 2024
--
f8a3bdf by Oleksii Oleniuk <[email protected]>:

fix: Add Context Cache support for ChatSessionPreview class (#433)

* add content cache to chat session

* remove logs, add gitignore

---------

Co-authored-by: Oleksii Oleniuk <[email protected]>
Co-authored-by: Yvonne Yu <[email protected]>
--
2c92ef3 by Oleksii Oleniuk <[email protected]>:

extend UsageMetadata interface

COPYBARA_INTEGRATE_REVIEW=#439 from oleksii-oleniuk-star:feature/gemini-context-cache-4 3ab1693
PiperOrigin-RevId: 686671597
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: aiplatform Issues related to the googleapis/nodejs-vertexai API. ready to pull copybara github pr import label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants