-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding a query mode for the schednex scheduler (#1257)
Signed-off-by: AlexsJones <[email protected]>
- Loading branch information
1 parent
ce5ade8
commit 1dea6dc
Showing
5 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package query | ||
|
||
import rpc "buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go/schema/v1/schemav1grpc" | ||
|
||
type Handler struct { | ||
rpc.UnimplementedServerQueryServiceServer | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package query | ||
|
||
import ( | ||
schemav1 "buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go/schema/v1" | ||
"context" | ||
"github.com/k8sgpt-ai/k8sgpt/pkg/ai" | ||
) | ||
|
||
func (h *Handler) Query(ctx context.Context, i *schemav1.QueryRequest) ( | ||
*schemav1.QueryResponse, | ||
error, | ||
) { | ||
aiClient := ai.NewClient(i.Backend) | ||
defer aiClient.Close() | ||
|
||
resp, err := aiClient.GetCompletion(ctx, i.Query) | ||
var errMessage string = "" | ||
if err != nil { | ||
errMessage = err.Error() | ||
} | ||
return &schemav1.QueryResponse{ | ||
Response: resp, | ||
Error: &schemav1.QueryError{ | ||
Message: errMessage, | ||
}, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters