Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Code Graph Secret Alias for GraphRAG API Integration #2537

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions handlers/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ func buildVarsPayload(request SendMessageRequest, createdMessage *db.ChatMessage
url = "https://" + url
}
vars["codeGraph"] = url
vars["codeGraphAlias"] = codeGraph.SecretAlias
}

return vars
Expand Down
20 changes: 13 additions & 7 deletions handlers/chat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2635,6 +2635,7 @@ func TestSendMessage(t *testing.T) {
Uuid: uuid.New().String(),
WorkspaceUuid: workspace.Uuid,
Url: "boltwall.swarm38.sphinx.chat/",
SecretAlias: "{{test-secret-alias}}",
CreatedBy: person.OwnerPubKey,
UpdatedBy: person.OwnerPubKey,
}
Expand Down Expand Up @@ -2689,14 +2690,19 @@ func TestSendMessage(t *testing.T) {
chatHandler := NewChatHandler(stakworkServer, db.TestDB)
chatHandler.SendMessage(rr, req)

require.Equal(t, http.StatusOK, rr.Code)
require.Equal(t, http.StatusOK, rr.Code)

vars, ok := capturedPayload.WorkflowParams["set_var"].(map[string]interface{})["attributes"].(map[string]interface{})["vars"].(map[string]interface{})
require.True(t, ok, "Workflow params should contain vars")

codeGraphUrl, exists := vars["codeGraph"].(string)
require.True(t, exists, "codeGraph should exist in vars")
assert.Equal(t, "https://boltwall.swarm38.sphinx.chat", codeGraphUrl)
vars, ok := capturedPayload.WorkflowParams["set_var"].(map[string]interface{})["attributes"].(map[string]interface{})["vars"].(map[string]interface{})
require.True(t, ok, "Workflow params should contain vars")


codeGraphUrl, exist := vars["codeGraph"].(string)
codeGraphAlias, exists := vars["codeGraphAlias"].(string)
require.True(t, exist, "codeGraph should exist in vars")
assert.Equal(t, "https://boltwall.swarm38.sphinx.chat", codeGraphUrl)
require.True(t, exists, "codeGraph should exist in vars")
assert.Equal(t, "{{test-secret-alias}}", codeGraphAlias)

})

t.Run("should send message without code graph", func(t *testing.T) {
Expand Down
5 changes: 4 additions & 1 deletion handlers/ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func (th *ticketHandler) PostTicketDataToStakwork(w http.ResponseWriter, r *http
}

var (
productBrief, featureBrief, featureArchitecture, codeGraphURL string
productBrief, featureBrief, featureArchitecture, codeGraphURL, codeGraphAlias string
feature db.WorkspaceFeatures
)

Expand Down Expand Up @@ -464,8 +464,10 @@ func (th *ticketHandler) PostTicketDataToStakwork(w http.ResponseWriter, r *http
codeGraph, err := th.db.GetCodeGraphByUUID(feature.WorkspaceUuid)
if err == nil {
codeGraphURL = codeGraph.Url
codeGraphAlias = codeGraph.SecretAlias
} else {
codeGraphURL = ""
codeGraphAlias = ""
}

}
Expand Down Expand Up @@ -499,6 +501,7 @@ func (th *ticketHandler) PostTicketDataToStakwork(w http.ResponseWriter, r *http
"webhook_url": webhookURL,
"phaseSchematic": schematicURL,
"codeGraph": codeGraphURL,
"codeGraphAlias": codeGraphAlias,
"alias": user.OwnerAlias,
},
},
Expand Down
Loading