Skip to main content

Module knowledge

Module knowledge 

Source
Expand description

§Knowledge Base Module

Provides knowledge-base management for the Zhipu AI API: create, update, delete knowledge bases; upload, list, and retrieve documents; perform semantic search.

§Knowledge-Base Operations

OperationModuleDescription
CreateKnowledgeCreateRequestCreate a new knowledge base
ListKnowledgeListRequestList knowledge bases
RetrieveKnowledgeGetRequestGet knowledge-base details
SearchKnowledgeSearchRequestRun semantic retrieval against a knowledge base
UpdateKnowledgeUpdateRequestUpdate metadata
DeleteKnowledgeDeleteRequestDelete a knowledge base
CapacityKnowledgeCapacityRequestCheck usage / quota

§Document Operations

OperationModuleDescription
Upload (file)DocumentUploadRequestUpload a local file
Upload (URL)DocumentUrlUploadRequestUpload from a URL
ListDocumentListRequestList documents in a KB
RetrieveDocumentGetRequestGet document details
DeleteDocumentDeleteRequestDelete documents
Re-embedDocumentReembedRequestRe-run vectorisation
ImagesDocumentImageListRequestList extracted images

§Supported Document Types

PDF, plain text, Markdown, Word, HTML, and more.

§Usage

use zai_rs::{ZaiResult, client::ZaiClient, knowledge::*};

let created = KnowledgeCreateRequest::new(EmbeddingId::Embedding3New, "Product docs")
    .send_via(client)
    .await?;
let uploaded = DocumentUploadRequest::new("knowledge-base-id")
    .add_file_path("guide.pdf")
    .send_via(client)
    .await?;
let matches = KnowledgeSearchRequest::new("knowledge-base-id", "How do I authenticate?")
    .with_top_k(5)
    .send_via(client)
    .await?;

Structs§

DocumentDeleteRequest
Document delete request (DELETE /llm-application/open/document/{id})
DocumentFailInfo
Document vectorization failure info
DocumentGetRequest
Retrieve document detail by id.
DocumentImageItem
One parsed image mapping item
DocumentImageListData
Image list data payload
DocumentImageListRequest
Retrieve parsed image index-url mapping for a document (POST, no body)
DocumentItem
Document item in a knowledge base
DocumentListData
Inner data of DocumentListResponse — the document list and total count.
DocumentListQuery
Query parameters for listing documents under a knowledge base
DocumentListRequest
Document list request (GET /llm-application/open/document)
DocumentReembedBody
Request body for re-embedding a document
DocumentReembedRequest
Re-embedding request (POST /llm-application/open/document/embedding/{id})
DocumentUploadData
Upload file response data payload
DocumentUploadFailedInfo
Failed info for file upload
DocumentUploadOptions
Optional parameters for file upload
DocumentUploadRequest
File upload request (multipart/form-data)
DocumentUploadSuccessInfo
Success info for file upload
DocumentUrlUploadBody
Upload URL request body
DocumentUrlUploadData
Upload URL response data payload
DocumentUrlUploadDetail
Single URL upload detail
DocumentUrlUploadFailedInfo
Failed info for URL upload
DocumentUrlUploadRequest
Upload URL request (POST /llm-application/open/document/upload_url)
DocumentUrlUploadSuccessInfo
Success info for URL upload
KnowledgeCapacityData
Capacity data payload
KnowledgeCapacityRequest
Knowledge capacity request (GET /llm-application/open/knowledge/capacity)
KnowledgeCreateBody
Request body for creating a knowledge base
KnowledgeCreateData
Inner data of KnowledgeCreateResponse — the newly created id.
KnowledgeCreateRequest
Create knowledge request (POST /llm-application/open/knowledge)
KnowledgeDeleteRequest
Knowledge delete request (DELETE /llm-application/open/knowledge/{id})
KnowledgeGetRequest
Knowledge detail request (GET /llm-application/open/knowledge/{id})
KnowledgeItem
Knowledge base item
KnowledgeListData
Knowledge list data payload
KnowledgeListQuery
Query parameters for knowledge list API
KnowledgeListRequest
Knowledge list request (GET /llm-application/open/knowledge)
KnowledgeOperationResponse
Standard knowledge API response envelope for operations without a payload.
KnowledgeResponse
Standard knowledge API success envelope.
KnowledgeSearchBody
JSON body for a semantic knowledge search.
KnowledgeSearchMetadata
Metadata attached to one retrieved knowledge chunk.
KnowledgeSearchRequest
Request for semantic retrieval across one or more knowledge bases.
KnowledgeSearchResponse
Semantic search success response.
KnowledgeSearchResult
One semantic-retrieval result.
KnowledgeUpdateBody
Update body for editing a knowledge base
KnowledgeUpdateRequest
Knowledge update request (PUT /llm-application/open/knowledge/{id})
KnowledgeUsageCounts
Capacity usage counters

Enums§

BackgroundColor
Background color enum
DocumentSliceType
Slice type (knowledge_type)
EmbeddingId
Embedding model identifier encoded as the service’s integer value.
KnowledgeIcon
Knowledge icon enum
KnowledgeRecallMethod
Retrieval strategy used before optional reranking.
KnowledgeRerankModel
Reranking model applied to recalled chunks.

Type Aliases§

DocumentDeleteResponse
Delete response envelope without data.
DocumentGetResponse
Document detail response envelope (data is a single document item).
DocumentImageListResponse
Parsed-image list response envelope.
DocumentListResponse
Document list response envelope.
DocumentReembedResponse
Simple response envelope without a data payload.
DocumentUploadResponse
File-upload response envelope.
DocumentUrlUploadResponse
Upload-by-URL response envelope.
KnowledgeCapacityResponse
Capacity response envelope.
KnowledgeCreateResponse
Response of knowledge creation.
KnowledgeDeleteResponse
Delete response envelope without data.
KnowledgeGetResponse
Knowledge detail response envelope (data is a single item).
KnowledgeListResponse
Knowledge list response envelope.
KnowledgeUpdateResponse
Update response envelope without a data payload.