Skip to content
Open
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions docs/weaviate/model-providers/_includes/provider.connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
# Recommended: save sensitive data as environment variables
cohere_key = os.getenv("COHERE_APIKEY")
# END CohereInstantiation
# START ContextualAIInstantiation
# Recommended: save sensitive data as environment variables
contextualai_key = os.getenv("CONTEXTUAL_API_KEY")
# END ContextualAIInstantiation
# START DatabricksInstantiation
# Recommended: save sensitive data as environment variables
databricks_token = os.getenv("DATABRICKS_TOKEN")
Expand Down Expand Up @@ -143,6 +147,10 @@
"X-Xai-Api-Key": xai_key,
# END XaiInstantiation

# START ContextualAIInstantiation
"X-Contextual-Api-Key": contextualai_key,
# END ContextualAIInstantiation

# START-ANY
}
# highlight-end
Expand Down
6 changes: 6 additions & 0 deletions docs/weaviate/model-providers/_includes/provider.connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const aws_secret_key = process.env.AWS_SECRET_KEY || ''; // Replace with your A
// START CohereInstantiation
const cohereApiKey = process.env.COHERE_APIKEY || ''; // Replace with your inference API key
// END CohereInstantiation
// START ContextualAIInstantiation
const contextualApiKey = process.env.CONTEXTUAL_API_KEY || '';
// END ContextualAIInstantiation
// START DatabricksInstantiation
const databricksToken = process.env.DATABRICKS_TOKEN || ''; // Replace with your inference API key
// END DatabricksInstantiation
Expand Down Expand Up @@ -119,6 +122,9 @@ const client = await weaviate.connectToWeaviateCloud(
// START XaiInstantiation
'X-Xai-Api-Key': xaiApiKey,
// END XaiInstantiation
// START ContextualAIInstantiation
'X-Contextual-Api-Key': contextualApiKey,
// END ContextualAIInstantiation
// START-ANY
}
// highlight-end
Expand Down
80 changes: 80 additions & 0 deletions docs/weaviate/model-providers/_includes/provider.generative.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,86 @@ def import_data():
# clean up
client.collections.delete("DemoCollection")

# START BasicGenerativeContextualAI
from weaviate.classes.config import Configure

client.collections.create(
"DemoCollection",
# highlight-start
generative_config=Configure.Generative.contextualai()
# highlight-end
# Additional parameters not shown
)
# END BasicGenerativeContextualAI

# clean up
client.collections.delete("DemoCollection")

# START GenerativeContextualAICustomModel
from weaviate.classes.config import Configure

client.collections.create(
"DemoCollection",
# highlight-start
generative_config=Configure.Generative.contextualai(
model="v2"
)
# highlight-end
# Additional parameters not shown
)
# END GenerativeContextualAICustomModel

# clean up
client.collections.delete("DemoCollection")

# START FullGenerativeContextualAI
from weaviate.classes.config import Configure

client.collections.create(
"DemoCollection",
# highlight-start
generative_config=Configure.Generative.contextualai(
# # These parameters are optional
# model="v2",
# max_tokens=1024,
# temperature=0.7,
# top_p=0.9,
# system_prompt="You are a helpful assistant",
# avoid_commentary=True,
)
# highlight-end
# Additional parameters not shown
)
# END FullGenerativeContextualAI

# clean up
client.collections.delete("DemoCollection")
import_data()

# START RuntimeModelSelectionContextualAI
from weaviate.classes.config import Configure
from weaviate.classes.generate import GenerativeConfig

collection = client.collections.use("DemoCollection")
response = collection.generate.near_text(
query="A holiday film",
limit=2,
grouped_task="Write a tweet promoting these two movies",
# highlight-start
generative_provider=GenerativeConfig.contextualai(
# # These parameters are optional
# model="v2",
# max_tokens=1024,
# temperature=0.7,
# top_p=0.9,
# system_prompt="You are a helpful assistant",
# avoid_commentary=True,
),
# Additional parameters not shown
# highlight-end
)
# END RuntimeModelSelectionContextualAI

# START BasicGenerativeAnthropic
from weaviate.classes.config import Configure

Expand Down
70 changes: 70 additions & 0 deletions docs/weaviate/model-providers/_includes/provider.generative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,55 @@ async function main() {
// Clean up
await client.collections.delete('DemoCollection');

// START BasicGenerativeContextualAI
await client.collections.create({
name: 'DemoCollection',
// highlight-start
generative: weaviate.configure.generative.contextualai(),
// highlight-end
// Additional parameters not shown
});
// END BasicGenerativeContextualAI

// Clean up
await client.collections.delete('DemoCollection');

// START GenerativeContextualAICustomModel
await client.collections.create({
name: 'DemoCollection',
// highlight-start
generative: weaviate.configure.generative.contextualai({
model: 'v2'
}),
// highlight-end
// Additional parameters not shown
});
// END GenerativeContextualAICustomModel

// Clean up
await client.collections.delete('DemoCollection');

// START FullGenerativeContextualAI
await client.collections.create({
name: 'DemoCollection',
// highlight-start
generative: weaviate.configure.generative.contextualai({
// These parameters are optional
// model: 'v2',
// maxTokens: 1024,
// temperature: 0.7,
// topP: 0.9,
// systemPrompt: 'You are a helpful assistant',
// avoidCommentary: true,
}),
// highlight-end
// Additional parameters not shown
});
// END FullGenerativeContextualAI

// Clean up
await client.collections.delete('DemoCollection');

// START BasicGenerativeAnthropic
await client.collections.create({
name: 'DemoCollection',
Expand Down Expand Up @@ -117,6 +166,27 @@ response = await myCollection.generate.nearText("A holiday film", {
// Additional parameters not shown
);
// END RuntimeModelSelectionAnthropic

// START RuntimeModelSelectionContextualAI
response = await myCollection.generate.nearText('A holiday film', {
// highlight-start
groupedTask: 'Write a tweet promoting these two movies',
config: generativeParameters.contextualai({
// These parameters are optional
// model: 'v2',
// maxTokens: 1024,
// temperature: 0.7,
// topP: 0.9,
// systemPrompt: 'You are a helpful assistant',
// avoidCommentary: true,
}),
// highlight-end
}, {
limit: 2,
}
// Additional parameters not shown
);
// END RuntimeModelSelectionContextualAI
(async () => {
// START WorkingWithImagesAnthropic
const srcImgPath = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Winter_forest_silver.jpg/960px-Winter_forest_silver.jpg"
Expand Down
34 changes: 34 additions & 0 deletions docs/weaviate/model-providers/_includes/provider.reranker.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,40 @@
# Clean up
client.collections.delete("DemoCollection")

# START RerankerContextualAIBasic
from weaviate.classes.config import Configure

client.collections.create(
"DemoCollection",
# highlight-start
reranker_config=Configure.Reranker.contextualai()
# highlight-end
# Additional parameters not shown
)
# END RerankerContextualAIBasic

# Clean up
client.collections.delete("DemoCollection")

# START RerankerContextualAICustomModel
from weaviate.classes.config import Configure

client.collections.create(
"DemoCollection",
# highlight-start
reranker_config=Configure.Reranker.contextualai(
model="ctxl-rerank-v2-instruct-multilingual",
instruction="Prioritize internal sales documents over market analysis reports. More recent documents should be weighted higher.",
top_n=5
)
# highlight-end
# Additional parameters not shown
)
# END RerankerContextualAICustomModel

# Clean up
client.collections.delete("DemoCollection")

# START RerankerCohereBasic
from weaviate.classes.config import Configure

Expand Down
22 changes: 22 additions & 0 deletions docs/weaviate/model-providers/_includes/provider.reranker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,28 @@ await client.collections.create({
});
// END RerankerCohereCustomModel

// START RerankerContextualAIBasic
await client.collections.create({
name: 'DemoCollection',
// highlight-start
reranker: weaviate.configure.reranker.contextualai(),
// highlight-end
});
// END RerankerContextualAIBasic

// START RerankerContextualAICustomModel
await client.collections.create({
name: 'DemoCollection',
// highlight-start
reranker: weaviate.configure.reranker.contextualai({
model: 'ctxl-rerank-v2-instruct-multilingual',
instruction: 'Prioritize internal sales documents over market analysis reports. More recent documents should be weighted higher.',
topN: 5,
}),
// highlight-end
});
// END RerankerContextualAICustomModel

// START RerankerJinaAIBasic
await client.collections.create({
name: 'DemoCollection',
Expand Down
5 changes: 5 additions & 0 deletions docs/weaviate/model-providers/contextualai/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"label": "Contextual AI",
"position": 140
}

Loading