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

docs: update code samples #1508

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ See the following code samples for a concrete idea of how to use these capabilit
- {Chat}

```javascript
import { genkit, z } from 'genkit';
import { genkit } from 'genkit';
import { googleAI, gemini15Flash } from '@genkit-ai/googleai';

const ai = genkit({
Expand Down Expand Up @@ -214,12 +214,13 @@ See the following code samples for a concrete idea of how to use these capabilit

```javascript
import { genkit } from 'genkit';
import { googleAI, gemini15Flash, textEmbedding004 } from '@genkit-ai/googleai';
import { devLocalRetrieverRef } from '@genkit-ai/dev-local-vectorstore';
import { googleAI, gemini15Flash } from '@genkit-ai/googleai';
import { textEmbedding004 } from '@genkit-ai/vertexai';
import { devLocalRetrieverRef, devLocalVectorstore } from '@genkit-ai/dev-local-vectorstore';

const ai = genkit({
plugins: [
googleAI()
googleAI(),
devLocalVectorstore([
{
indexName: 'BobFacts',
Expand All @@ -233,15 +234,17 @@ See the following code samples for a concrete idea of how to use these capabilit
// Reference to a local vector database storing Genkit documentation
const retriever = devLocalRetrieverRef('BobFacts');

const query = 'How old is Bob?';

// Consistent API to retrieve most relevant documents based on semantic similarity to query
const docs = await ai.retrieve(
const docs = await ai.retrieve({
retriever: retriever,
query: 'How old is bob?',
);
query: query,
});

const result = await ai.generate({
prompt: `Use the provided context from the Genkit documentation to answer this query: ${query}`,
docs // Pass retrieved documents to the model
docs: docs // Pass retrieved documents to the model
});
```

Expand Down