pub struct Retrieval {
pub knowledge_id: String,
pub prompt_template: Option<String>,
}Expand description
Knowledge-base retrieval tool configuration.
Attaches a Zhipu AI knowledge base to a chat completion so the model can
retrieve relevant passages from it before answering. Create the knowledge
base (and obtain its knowledge_id) in the BigModel console, then pass the
id here via the Retrieval tool.
See the official guide: https://docs.bigmodel.cn/cn/guide/tools/knowledge/retrieval.
§Wire form
Serializes as {"knowledge_id":"…","prompt_template":"…"} (the
prompt_template field is omitted when not set).
§Usage
use zai_rs::model::tools::{Retrieval, Tools};
let tool = Tools::Retrieval {
retrieval: Retrieval::new("kb_1234567890"),
};
// Or attach a custom prompt template:
let tool = Tools::Retrieval {
retrieval: Retrieval::new("kb_1234567890")
.with_prompt_template("仅依据知识库回答:{knowledge}"),
};Fields§
§knowledge_id: StringKnowledge-base id (required). Obtain it from the BigModel console after creating and populating a knowledge base.
prompt_template: Option<String>Optional prompt template applied when the model consumes retrieved
knowledge. Serialized as prompt_template; omitted when None.
Implementations§
Trait Implementations§
Source§impl<'v_a> ValidateArgs<'v_a> for Retrieval
impl<'v_a> ValidateArgs<'v_a> for Retrieval
Auto Trait Implementations§
impl Freeze for Retrieval
impl RefUnwindSafe for Retrieval
impl Send for Retrieval
impl Sync for Retrieval
impl Unpin for Retrieval
impl UnsafeUnpin for Retrieval
impl UnwindSafe for Retrieval
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more