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

Update generative reconfigure examples #2933

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
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
74 changes: 69 additions & 5 deletions _includes/code/howto/manage-data.collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ let result


/*
// START UpdateCollection
// START UpdateCollection // START UpdateReranker // START UpdateGenerative
import { reconfigure } from 'weaviate-client';

// END UpdateCollection
// END UpdateCollection // END UpdateReranker // END UpdateGenerative
*/

// START UpdateCollection // START ReadOneCollection // START ModifyParam
Expand Down Expand Up @@ -451,12 +451,12 @@ await client.collections.delete(collectionName)
// ===============================================
// ===== CREATE A COLLECTION WITH A RERANKER MODULE =====
// ===============================================

/*
// START SetReranker
// import { vectorizer, reranker } from 'weaviate-client';
import { vectorizer, reranker } from 'weaviate-client';

// END SetReranker

/*
// START SetReranker
await client.collections.create({
name: 'Article',
Expand Down Expand Up @@ -707,3 +707,67 @@ await articles.config.update({
})
// highlight-end
// END UpdateCollection

// ===============================================
// ===== UPDATE A COLLECTION'S RERANKER MODULE =====
// ===============================================

client.collections.delete("Article")


await client.collections.create({
name: "Article",
vectorizers: vectorizer.text2VecOpenAI(),
// highlight-start
reranker: configure.reranker.voyageAI()
// highlight-end
})

// START UpdateReranker
const collection = client.collections.get('Article')

await collection.config.update({
// highlight-start
reranker: reconfigure.reranker.cohere() // Update the reranker module
// highlight-end
})
// END UpdateReranker

// Test
let config = await collection.config.get()
assert.equal(config.reranker?.name,"reranker-cohere")

// Delete the collection to recreate it
client.collections.delete("Article")


// ===============================================
// ===== UPDATE A COLLECTION'S GENERATIVE MODULE =====
// ===============================================

client.collections.delete("Article")

client.collections.create({
name: "Article",
vectorizers: configure.vectorizer.text2VecOpenAI(),
// highlight-start
generative: configure.generative.openAI()
// highlight-end
})

// START UpdateGenerative
const collection = client.collections.get("Article")

await collection.config.update({
// highlight-start
generative: weaviate.reconfigure.generative.cohere() // Update the generative module
// highlight-end
})
// END UpdateGenerative

// Test
let config = await collection.config.get()
assert.equal(config.generative?.name, "generative-cohere")

// Delete the collection to recreate it
client.collections.delete('Article')
22 changes: 12 additions & 10 deletions developers/weaviate/manage-data/collections.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,12 @@ Update the [`reranker`](../concepts/search/index.md#rerank) model integration fo
</TabItem>

<TabItem value="js" label="JS/TS Client v3">

```js
// Coming soon
```

<FilteredTextBlock
text={TSCode}
startMarker="// START UpdateReranker"
endMarker="// END UpdateReranker"
language="ts"
/>
</TabItem>

<TabItem value="js2" label="JS/TS Client v2">
Expand Down Expand Up @@ -815,11 +816,12 @@ Update a [`reranker`](../concepts/search/index.md#rerank) model integration for
</TabItem>

<TabItem value="js" label="JS/TS Client v3">

```js
// Coming soon
```

<FilteredTextBlock
text={TSCode}
startMarker="// START UpdateGenerative"
endMarker="// END UpdateGenerative"
language="ts"
/>
</TabItem>

<TabItem value="js2" label="JS/TS Client v2">
Expand Down
Loading