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

Added ZhipuAI's API online interface description document #2886

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@
# Recommended: save sensitive data as environment variables
voyageai_key = os.getenv("VOYAGEAI_APIKEY")
# END VoyageAIInstantiation

# START ZhipuAIInstantiation
# Recommended: save sensitive data as environment variables
zhipuai_key = os.getenv("ZHIPUAI_APIKEY")
# END ZhipuAIInstantiation

# START-ANY
# highlight-start
Expand Down Expand Up @@ -128,6 +131,9 @@
# START VoyageAIInstantiation
"X-VoyageAI-Api-Key": voyageai_key,
# END VoyageAIInstantiation
# START ZhipuAIInstantiation
"X-ZhipuAI-Api-Key": zhipuai_key,
# END ZhipuAIInstantiation

# START-ANY
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,19 @@
)
# END BasicGenerativeOpenAI

# START BasicGenerativeZhipuAI
from weaviate.classes.config import Configure

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


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

Expand All @@ -500,6 +513,20 @@
)
# END GenerativeOpenAICustomModel

# START GenerativeZhipuAICustomModel
from weaviate.classes.config import Configure

client.collections.create(
"DemoCollection",
# highlight-start
generative_config=Configure.Generative.zhipuai(
model="glm-4"
)
# highlight-end
# Additional parameters not shown
)
# END GenerativeZhipuAICustomModel

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

Expand All @@ -524,6 +551,25 @@
)
# END FullGenerativeOpenAI

# START FullGenerativeZhipuAI
from weaviate.classes.config import Configure

client.collections.create(
"DemoCollection",
# highlight-start
generative_config=Configure.Generative.zhipuai(
# # These parameters are optional
# model="glm-4",
# max_tokens=500,
# temperature=0.7,
# top_p=0.7,
# base_url="<custom_zhipu_url>"
)
# highlight-end
# Additional parameters not shown
)
# END FullGenerativeZhipuAI

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

Expand Down
33 changes: 17 additions & 16 deletions developers/weaviate/model-providers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@ This enables an enhanced developed experience, such as the ability to:

### API-based

| Model provider | Embeddings | Generative AI | Others |
| --- | --- | --- | --- |
| [Anthropic](./anthropic/index.md) | - | [Text](./anthropic/generative.md) | - |
| [Anyscale](./anyscale/index.md) | - | [Text](./anyscale/generative.md) | - |
| [AWS](./aws/index.md) | [Text](./aws/embeddings.md) | [Text](./aws/generative.md) |
| [Cohere](./cohere/index.md) | [Text](./cohere/embeddings.md), [Multimodal](./cohere/embeddings-multimodal.md) | [Text](./cohere/generative.md) | [Reranker](./cohere/reranker.md) |
| [Databricks](./databricks/index.md) | [Text](./databricks/embeddings.md) | [Text](./databricks/generative.md) | - |
| [FriendliAI](./friendliai/index.md) | - | [Text](./friendliai/generative.md) | - |
| [Google](./google/index.md) | [Text](./google/embeddings.md), [Multimodal](./google/embeddings-multimodal.md) | [Text](./google/generative.md) | - |
| [Hugging Face](./huggingface/index.md) | [Text](./huggingface/embeddings.md) | - | - |
| [Jina AI](./jinaai/index.md) | [Text](./jinaai/embeddings.md), [Multimodal](./jinaai/embeddings-multimodal.md) | - | [Reranker](./jinaai/reranker.md) |
| [Mistral](./mistral/index.md) | [Text](./mistral/embeddings.md) | [Text](./mistral/generative.md) | - |
| Model provider | Embeddings | Generative AI | Others |
|------------------------------------------| -- | --- | --- |
| [Anthropic](./anthropic/index.md) | - | [Text](./anthropic/generative.md) | - |
| [Anyscale](./anyscale/index.md) | - | [Text](./anyscale/generative.md) | - |
| [AWS](./aws/index.md) | [Text](./aws/embeddings.md) | [Text](./aws/generative.md) |
| [Cohere](./cohere/index.md) | [Text](./cohere/embeddings.md), [Multimodal](./cohere/embeddings-multimodal.md) | [Text](./cohere/generative.md) | [Reranker](./cohere/reranker.md) |
| [Databricks](./databricks/index.md) | [Text](./databricks/embeddings.md) | [Text](./databricks/generative.md) | - |
| [FriendliAI](./friendliai/index.md) | - | [Text](./friendliai/generative.md) | - |
| [Google](./google/index.md) | [Text](./google/embeddings.md), [Multimodal](./google/embeddings-multimodal.md) | [Text](./google/generative.md) | - |
| [Hugging Face](./huggingface/index.md) | [Text](./huggingface/embeddings.md) | - | - |
| [Jina AI](./jinaai/index.md) | [Text](./jinaai/embeddings.md), [Multimodal](./jinaai/embeddings-multimodal.md) | - | [Reranker](./jinaai/reranker.md) |
| [Mistral](./mistral/index.md) | [Text](./mistral/embeddings.md) | [Text](./mistral/generative.md) | - |
| [OctoAI (Deprecated)](./octoai/index.md) | [Text](./octoai/embeddings.md) | [Text](./octoai/generative.md) | - |
| [OpenAI](./openai/index.md) | [Text](./openai/embeddings.md) | [Text](./openai/generative.md) | - |
| [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) | - | - |
| [OpenAI](./openai/index.md) | [Text](./openai/embeddings.md) | [Text](./openai/generative.md) | - |
| [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) |
| [Zhipu AI](./zhipuai/index.md) | - | - | - |
| [Weaviate](./weaviate/index.md) | [Text](./weaviate/embeddings.md) | - | - |

#### Enable all API-based modules

Expand Down
4 changes: 4 additions & 0 deletions developers/weaviate/model-providers/zhipuai/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "ZhipuAI",
"position": 250
}
133 changes: 133 additions & 0 deletions developers/weaviate/model-providers/zhipuai/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
title: Generative AI
description: ZhipuAI Generative Model Provider
sidebar_position: 50
---

# ZhipuAI Generative AI with Weaviate


import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock';
import PyConnect from '!!raw-loader!../_includes/provider.connect.py';
import TSConnect from '!!raw-loader!../_includes/provider.connect.ts';
import PyCode from '!!raw-loader!../_includes/provider.generative.py';
import TSCode from '!!raw-loader!../_includes/provider.generative.ts';

Weaviate's integration with ZhipuAI's APIs allows you to access their models' capabilities directly from Weaviate.

[Configure a Weaviate collection](#configure-collection) to use an ZhipuAI generative AI model

## Requirements

### Weaviate configuration

Your Weaviate instance must be configured with the ZhipuAI generative AI integration (`generative-zhipuai`) module.


<details>
<summary>For self-hosted users</summary>

- Check the [cluster metadata](../../config-refs/meta.md) to verify if the module is enabled.
- Follow the [how-to configure modules](../../configuration/modules.md) guide to enable the module in Weaviate.

</details>


### API credentials

You must provide a valid ZhipuAI API key to Weaviate for this integration. Go to [apikey](https://open.bigmodel.cn/usercenter/proj-mgmt/apikeys) to sign up and obtain an API key.

Provide the API key to Weaviate using one of the following methods:

- Set the `ZHIPUAI_APIKEY` environment variable that is available to Weaviate.
- Provide the API key at runtime, as shown in the examples below.

<Tabs groupId="languages">

<TabItem value="py" label="Python API v4">
<FilteredTextBlock
text={PyConnect}
startMarker="# START ZhipuAIInstantiation"
endMarker="# END ZhipuAIInstantiation"
language="py"
/>
</TabItem>

</Tabs>

## Configure collection

import MutableGenerativeConfig from '/_includes/mutable-generative-config.md';

<MutableGenerativeConfig />

[Configure a Weaviate index](#available-models) as follows to use an ZhipuAI generative AI model:

<Tabs groupId="languages">
<TabItem value="py" label="Python API v4">
<FilteredTextBlock
text={PyCode}
startMarker="# START BasicGenerativeZhipuAI"
endMarker="# END BasicGenerativeZhipuAI"
language="py"
/>
</TabItem>

</Tabs>

### Select a model

You can specify one of the [available models](#available-models) for Weaviate to use, as shown in the following configuration example:

<Tabs groupId="languages">
<TabItem value="py" label="Python API v4">
<FilteredTextBlock
text={PyCode}
startMarker="# START GenerativeZhipuAICustomModel"
endMarker="# END GenerativeZhipuAICustomModel"
language="py"
/>
</TabItem>

</Tabs>

You can [specify](#generative-parameters) one of the [available models](#available-models) for Weaviate to use. The [default model](#available-models) is used if no model is specified.

### Generative parameters

Configure the following generative parameters to customize the model behavior.

<Tabs groupId="languages">
<TabItem value="py" label="Python API v4">
<FilteredTextBlock
text={PyCode}
startMarker="# START FullGenerativeZhipuAI"
endMarker="# END FullGenerativeZhipuAI"
language="py"
/>
</TabItem>
</Tabs>


## References

### Available models

generative_config [model support](https://bigmodel.cn/dev/howuse/model)

* glm-4 (default)
* glm-4-plus
* glm-4-air
* glm-4-airx
* glm-4-0520
* glm-4-long
* glm-4-flashx
* glm-4-flash

## Questions and feedback

import DocsFeedback from '/_includes/docs-feedback.mdx';

<DocsFeedback/>