From 0cdc929590cfb8b7e65a8ce3b516e54e0d7b0a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Wed, 24 Sep 2025 23:37:27 +0800 Subject: [PATCH] feat: add view image status management --- agent.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/agent.go b/agent.go index ac4e4b5..b14de58 100644 --- a/agent.go +++ b/agent.go @@ -28,6 +28,7 @@ type Agent struct { chars string perm *Perm manualaddreq bool + hasimageapi bool } // NewAgent 创建一个 Agent 实例。 @@ -59,6 +60,11 @@ func (ag *Agent) AddRequest(grp int64, req *zero.APIRequest) { ag.log.Add(grp, req, true) } +// CanViewImage will be true if SetViewImageAPI is called +func (ag *Agent) CanViewImage() bool { + return ag.hasimageapi +} + // SetViewImageAPI 为 agent 增加识图功能, 需要模型支持视觉 func (ag *Agent) SetViewImageAPI(api deepinfra.API, p model.Protocol) { ag.log.SetPreModelize(func(s *fmt.Stringer) { @@ -93,6 +99,13 @@ func (ag *Agent) SetViewImageAPI(api deepinfra.API, p model.Protocol) { } } }) + ag.hasimageapi = true +} + +// ClearViewImageAPI ... +func (ag *Agent) ClearViewImageAPI() { + ag.log.SetPreModelize(nil) + ag.hasimageapi = false } // GetAction get OneBot CallAction from LLM and add it to context.