chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,38 @@
|
||||
package modelcontext
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// ImageSourcesNote binds images to handles already present in the final model
|
||||
// context. offset counts user images preceding the retrieved ones in this
|
||||
// message. Unknown sources stay explicitly unavailable, never fabricated.
|
||||
func (r *Registry) ImageSourcesNote(chunkIDs []string, offset int) string {
|
||||
if len(chunkIDs) == 0 {
|
||||
return ""
|
||||
}
|
||||
var note strings.Builder
|
||||
note.WriteString("\n\nRetrieved image sources (image numbers are 1-based within this message):")
|
||||
for i, id := range chunkIDs {
|
||||
if handle := r.ChunkHandle(id); handle != "" {
|
||||
fmt.Fprintf(¬e, "\nImage %d: chunk %s.", offset+i+1, handle)
|
||||
} else {
|
||||
fmt.Fprintf(¬e, "\nImage %d: source unavailable; do not invent a citation.", offset+i+1)
|
||||
}
|
||||
}
|
||||
return note.String()
|
||||
}
|
||||
|
||||
// ToolImageSourcesNote is rendered beside the actual images after tool result
|
||||
// rendering has registered its source handles. Stored results have no images
|
||||
// and must not claim to attach them on replay.
|
||||
func (r *Registry) ToolImageSourcesNote(result *types.ToolResult) string {
|
||||
if result == nil || len(result.Images) == 0 {
|
||||
return ""
|
||||
}
|
||||
ids := stringSliceValue(result.Data["context_images"])
|
||||
return r.ImageSourcesNote(ids[:min(len(ids), len(result.Images))], 0)
|
||||
}
|
||||
Reference in new issue
Block a user