-
Notifications
You must be signed in to change notification settings - Fork 20
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
Chore: use SSE to deliver change event for knowledgefiles #1106
Conversation
Signed-off-by: Daishan Peng <[email protected]>
7cdfff6
to
8609fcf
Compare
@@ -141,9 +141,6 @@ export default function FileTreeNode({ | |||
filePathPrefixInclude, | |||
filePathPrefixExclude, | |||
}); | |||
|
|||
// We should manually approve/unapprove all files in the folder at once so that we don't rely on backend reconciliation logic as it will cause delay in updating the UI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems not ideal to approve files in frontend just for fast feedback from UI. I think it is ok to just rely on backend to reconcile all the files to be approved.
|
||
eventSource.onmessage = (event) => { | ||
const payload = JSON.parse(event.data); | ||
const { eventType, knowledgeFile } = payload; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you create a type for this?
Signed-off-by: Daishan Peng <[email protected]>
pkg/api/handlers/agent.go
Outdated
|
||
for event := range w.ResultChan() { | ||
if knowledgeFile, ok := event.Object.(*v1.KnowledgeFile); ok { | ||
payload := map[string]interface{}{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
payload := map[string]interface{}{ | |
payload := map[string]any{ |
pkg/api/router/router.go
Outdated
@@ -11,7 +11,7 @@ import ( | |||
func Router(services *services.Services) (http.Handler, error) { | |||
mux := services.APIServer | |||
|
|||
agents := handlers.NewAgentHandler(services.GPTClient, services.Invoker, services.ServerURL) | |||
agents := handlers.NewAgentHandler(services.GPTClient, services.Invoker, services.ServerURL, services.StorageClient) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The api.Context
object passed to each of these handlers already has a client. Can we just use that one instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! addressed
Signed-off-by: Daishan Peng <[email protected]>
We used to pull knowledge at an interval but this is not effiencient. Switching to use SSE events to watch for changes.