Skip to content

Commit

Permalink
Merge pull request #2933 from weaviate/docs/01-20-ts-examples-updates
Browse files Browse the repository at this point in the history
Update generative reconfigure examples
  • Loading branch information
malgamves authored Jan 20, 2025
2 parents e56b7f2 + 8ca0e8b commit dc0424e
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 15 deletions.
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

0 comments on commit dc0424e

Please sign in to comment.