An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Update av
Daniel85d876e6672a
diff --git a/kernel/api/av.go b/kernel/api/av.goindex b1c9426dd6..a4843cde6d 100644--- a/kernel/api/av.go+++ b/kernel/api/av.go@@ -77,3 +77,21 @@ func getAttributeViewKeys(c *gin.Context) {blockAttributeViewKeys := model.GetBlockAttributeViewKeys(id)ret.Data = blockAttributeViewKeys}++func setAttributeViewBlockAttrs(c *gin.Context) {+ ret := gulu.Ret.NewResult()+ defer c.JSON(http.StatusOK, ret)++ arg, ok := util.JsonArg(c, ret)+ if !ok {+ return+ }++ avID := arg["avID"].(string)+ keyID := arg["keyID"].(string)+ rowID := arg["rowID"].(string)+ cellID := arg["cellID"].(string)+ value := arg["value"].(interface{})+ blockAttributeViewKeys := model.UpdateAttributeViewCell(avID, keyID, rowID, cellID, value)+ ret.Data = blockAttributeViewKeys+}diff --git a/kernel/api/router.go b/kernel/api/router.goindex 8ebb5568d9..17f6e8a09e 100644--- a/kernel/api/router.go+++ b/kernel/api/router.go@@ -360,6 +360,7 @@ func ServeAPI(ginServer *gin.Engine) {ginServer.Handle("POST", "/api/av/renderAttributeView", model.CheckAuth, renderAttributeView)ginServer.Handle("POST", "/api/av/getAttributeViewKeys", model.CheckAuth, getAttributeViewKeys)+ ginServer.Handle("POST", "/api/av/setAttributeViewBlockAttrs", model.CheckAuth, setAttributeViewBlockAttrs)ginServer.Handle("POST", "/api/ai/chatGPT", model.CheckAuth, model.CheckReadonly, chatGPT)ginServer.Handle("POST", "/api/ai/chatGPTWithAction", model.CheckAuth, model.CheckReadonly, chatGPTWithAction)diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex c0eeb642f5..20ae85818a 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -816,19 +816,24 @@ func (tx *Transaction) doUpdateAttrViewCell(operation *Operation) (ret *TxErr) {}func updateAttributeViewCell(operation *Operation, tx *Transaction) (err error) {- attrView, err := av.ParseAttributeView(operation.AvID)+ err = UpdateAttributeViewCell(operation.AvID, operation.KeyID, operation.RowID, operation.ID, operation.Data)+ return+}++func UpdateAttributeViewCell(avID, keyID, rowID, cellID string, value interface{}) (err error) {+ attrView, err := av.ParseAttributeView(avID)if nil != err {return}var val *av.Valuefor _, keyValues := range attrView.KeyValues {- if operation.KeyID != keyValues.Key.ID {+ if keyID != keyValues.Key.ID {continue}for _, value := range keyValues.Values {- if operation.ID == value.ID {+ if cellID == value.ID {val = valueval.Type = keyValues.Key.Typebreak@@ -836,13 +841,13 @@ func updateAttributeViewCell(operation *Operation, tx *Transaction) (err error)}if nil == val {- val = &av.Value{ID: operation.ID, KeyID: keyValues.Key.ID, BlockID: operation.RowID, Type: keyValues.Key.Type}+ val = &av.Value{ID: cellID, KeyID: keyValues.Key.ID, BlockID: rowID, Type: keyValues.Key.Type}keyValues.Values = append(keyValues.Values, val)}break}- tree, err := tx.loadTree(val.BlockID)+ tree, err := loadTreeByBlockID(val.BlockID)if nil != err {return}@@ -852,7 +857,7 @@ func updateAttributeViewCell(operation *Operation, tx *Transaction) (err error)return}- data, err := gulu.JSON.MarshalJSON(operation.Data)+ data, err := gulu.JSON.MarshalJSON(value)if nil != err {return}@@ -861,8 +866,9 @@ func updateAttributeViewCell(operation *Operation, tx *Transaction) (err error)}attrs := parse.IAL2Map(node.KramdownIAL)- attrs[NodeAttrNamePrefixAvKey+operation.AvID+"-"+val.KeyID] = val.ToJSONString()- if err = setNodeAttrsWithTx(tx, node, tree, attrs); nil != err {+ attrs[NodeAttrNamePrefixAvKey+avID+"-"+val.KeyID] = val.ToJSONString()++ if err = setNodeAttrs(node, tree, attrs); nil != err {return}