resolvePath 根据 scope 解析存储路径
(threadID, resourceID string)
| 283 | |
| 284 | // resolvePath 根据 scope 解析存储路径 |
| 285 | func (wm *WorkingMemoryManager) resolvePath(threadID, resourceID string) string { |
| 286 | var filename string |
| 287 | |
| 288 | switch wm.scope { |
| 289 | case ScopeThread: |
| 290 | if threadID == "" { |
| 291 | // 如果没有 threadID,使用 resourceID 作为后备 |
| 292 | threadID = resourceID |
| 293 | } |
| 294 | filename = filepath.ToSlash(filepath.Join(wm.basePath, "threads", threadID+".json")) |
| 295 | |
| 296 | case ScopeResource: |
| 297 | if resourceID == "" { |
| 298 | // 如果没有 resourceID,使用 threadID 作为后备 |
| 299 | resourceID = threadID |
| 300 | } |
| 301 | filename = filepath.ToSlash(filepath.Join(wm.basePath, "resources", resourceID+".json")) |
| 302 | } |
| 303 | |
| 304 | return filename |
| 305 | } |