Skip to content
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
# Recommended: save sensitive data as environment variables
voyageai_key = os.getenv("VOYAGEAI_APIKEY")
# END VoyageAIInstantiation
# START XaiInstantiation
# Recommended: save sensitive data as environment variables
xai_key = os.getenv("XAI_APIKEY")
# END XaiInstantiation


# START-ANY
Expand Down Expand Up @@ -135,6 +139,9 @@
# START VoyageAIInstantiation
"X-VoyageAI-Api-Key": voyageai_key,
# END VoyageAIInstantiation
# START XaiInstantiation
"X-Xai-Api-Key": xai_key,
# END XaiInstantiation

# START-ANY
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ const azureApiKey = process.env.AZURE_APIKEY || ''; // Replace with your infere
// START VoyageAIInstantiation
const voyageaiApiKey = process.env.VOYAGEAI_APIKEY || ''; // Replace with your inference API key
// END VoyageAIInstantiation
// START Xainstantiation
const xaiApiKey = process.env.XAI_APIKEY || ''; // Replace with your inference API key
// END XaiInstantiation

// START-ANY

Expand Down Expand Up @@ -113,6 +116,9 @@ const client = await weaviate.connectToWeaviateCloud(
// START VoyageAIInstantiation
'X-VoyageAI-Api-Key': voyageaiApiKey,
// END VoyageAIInstantiation
// START XaiInstantiation
'X-Xai-Api-Key': xaiApiKey,
// END XaiInstantiation
// START-ANY
}
// highlight-end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def import_data():

jeopardy = client.collections.get("DemoCollection")
response = jeopardy.generate.near_text(
query="Movies",
limit=5,
query="Movies",
limit=5,
# highlight-start
grouped_task=prompt,
# highlight-end
Expand Down Expand Up @@ -316,8 +316,8 @@ def import_data():

jeopardy = client.collections.get("DemoCollection")
response = jeopardy.generate.near_text(
query="Movies",
limit=5,
query="Movies",
limit=5,
# highlight-start
grouped_task=prompt,
# highlight-end
Expand Down Expand Up @@ -676,8 +676,8 @@ def import_data():

jeopardy = client.collections.get("DemoCollection")
response = jeopardy.generate.near_text(
query="Movies",
limit=5,
query="Movies",
limit=5,
# highlight-start
grouped_task=prompt,
# highlight-end
Expand Down Expand Up @@ -994,8 +994,8 @@ def import_data():

jeopardy = client.collections.get("DemoCollection")
response = jeopardy.generate.near_text(
query="Movies",
limit=5,
query="Movies",
limit=5,
# highlight-start
grouped_task=prompt,
# highlight-end
Expand Down Expand Up @@ -1028,9 +1028,73 @@ def import_data():
)
# END BasicGenerativeAzureOpenAI

# START BasicGenerativexAI
from weaviate.classes.config import Configure

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

# START GenerativexAICustomModel
from weaviate.classes.config import Configure

client.collections.create(
"DemoCollection",
generative_config=Configure.Generative.xai(
model="grok-2-latest"
)
# Additional parameters not shown
)
# END GenerativexAICustomModel

# START FullGenerativexAI
from weaviate.classes.config import Configure

client.collections.create(
"DemoCollection",
# highlight-start
generative_config=Configure.Generative.xai(
# # These parameters are optional
# base_url="https://api.x.ai/v1"
# model="grok-2-latest",
# max_tokens=500,
# temperature=0.7,
)
# highlight-end
# Additional parameters not shown
)
# END FullGenerativexAI

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

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

collection = client.collections.get("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.xai(
# # These parameters are optional
# base_url="https://api.x.ai/v1"
# model="grok-2-latest",
# max_tokens=500,
# temperature=0.7,
),
# Additional parameters not shown
# highlight-end
)
# END RuntimeModelSelectionxAI

# START FullGenerativeKubeAI
from weaviate.classes.config import Configure

Expand Down Expand Up @@ -1212,8 +1276,8 @@ def import_data():

jeopardy = client.collections.get("DemoCollection")
response = jeopardy.generate.near_text(
query="Movies",
limit=5,
query="Movies",
limit=5,
# highlight-start
grouped_task=prompt,
# highlight-end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,9 @@ await client.collections.create({
});
// END FullGenerativeAzureOpenAI

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

// START BasicGenerativeOllama
await client.collections.create({
name: 'DemoCollection',
Expand Down Expand Up @@ -595,6 +598,53 @@ await client.collections.create({
// Clean up
await client.collections.delete('DemoCollection');

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

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

// START GenerativexAICustomModel
await client.collections.create({
name: 'DemoCollection',
// highlight-start
generative: weaviate.configure.generative.xai({
model: 'grok-2-latest'
}),
// highlight-end
// Additional parameters not shown
});
// END GenerativexAICustomModel

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

// START FullGenerativexAI
await client.collections.create({
name: 'DemoCollection',
// highlight-start
generative: weaviate.configure.generative.xai({
// // These parameters are optional
// baseUrlProperty: 'https://api.x.ai/v1',
// model: 'grok-2-latest',
// maxTokensProperty: 512,
// temperatureProperty: 0.7,
}),
// highlight-end
// Additional parameters not shown
});
// END FullGenerativexAI

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

// START SinglePromptExample // START GroupedTaskExample
let myCollection = client.collections.get('DemoCollection');
// START SinglePromptExample // END GroupedTaskExample
Expand Down
1 change: 1 addition & 0 deletions developers/weaviate/model-providers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ This enables an enhanced developed experience, such as the ability to:
| [Azure OpenAI](./openai-azure/index.md) | [Text](./openai-azure/embeddings.md) | [Text](./openai-azure/generative.md) | - |
| [Voyage AI](./voyageai/index.md) | [Text](./voyageai/embeddings.md), [Multimodal](./voyageai/embeddings-multimodal.md) | - | [Reranker](./voyageai/reranker.md) |
| [Weaviate](./weaviate/index.md) | [Text](./weaviate/embeddings.md) | - | - |
| [xAI](./xai/index.md) | - | [Text](./xai/generative.md) | - |

#### Enable all API-based modules

Expand Down
4 changes: 4 additions & 0 deletions developers/weaviate/model-providers/xai/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "xAI",
"position": 281
}
Loading