Skip to content

Commit

Permalink
feat: add notReadyReasonCode into app
Browse files Browse the repository at this point in the history
Signed-off-by: Abirdcfly <[email protected]>
  • Loading branch information
Abirdcfly committed Apr 8, 2024
1 parent e4f56bf commit 24612a4
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 32 deletions.
100 changes: 84 additions & 16 deletions apiserver/graph/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion apiserver/graph/generated/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions apiserver/graph/schema/application.gql
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mutation createApplication($input:CreateApplicationMetadataInput!){
isRecommended
status
category
notReadyReasonCode
}
}
}
Expand All @@ -38,6 +39,7 @@ mutation updateApplication($input: UpdateApplicationMetadataInput!){
isRecommended
status
category
notReadyReasonCode
}
}
}
Expand Down Expand Up @@ -66,6 +68,7 @@ mutation updateApplicationConfig($input: UpdateApplicationConfigInput!){
isRecommended
status
category
notReadyReasonCode
}
prologue
model
Expand Down Expand Up @@ -118,6 +121,7 @@ query getApplication($name: String!, $namespace: String!){
isRecommended
status
category
notReadyReasonCode
}
prologue
model
Expand Down Expand Up @@ -175,6 +179,7 @@ query listApplications($input: ListCommonInput!) {
isRecommended
status
category
notReadyReasonCode
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions apiserver/graph/schema/application.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,17 @@ type ApplicationMetadata {
category:所属分类
"""
category: [String]
"""
notReadyReasonCode: 用于指明当前应用状态不正常的原因。状态码要和gpts中同字段保持一致。
可选值:
- 空:就绪,应用 可以使用
- VectorStoreIsNotReady: 向量数据库没有就绪
- EmbedderIsNotReady: embedder服务没有就绪
- KnowledgeBaseNotReady: 知识库未就绪,指向量数据库和embedder出错之外的其他情况
- LLMNotReady: 模型服务没有就绪
- ConfigError: 应用配置错误,比如写了多个Output节点,比如节点名称重复等其他错误
"""
notReadyReasonCode: String
}

input CreateApplicationMetadataInput {
Expand Down
2 changes: 1 addition & 1 deletion apiserver/graph/schema/gpt.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type GPT {
"""
enableUploadFile: Boolean
"""
notReadyReasonCode: 用于指明当前gpt状态不正常的原因。
notReadyReasonCode: 用于指明当前gpt状态不正常的原因。状态码要和应用中同字段保持一致。
可选值:
- 空:就绪,gpt 可以使用
- VectorStoreIsNotReady: 向量数据库没有就绪
Expand Down
32 changes: 18 additions & 14 deletions apiserver/pkg/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
pkgconf "github.com/kubeagi/arcadia/apiserver/config"
"github.com/kubeagi/arcadia/apiserver/graph/generated"
"github.com/kubeagi/arcadia/apiserver/pkg/common"
"github.com/kubeagi/arcadia/apiserver/pkg/gpt"
"github.com/kubeagi/arcadia/apiserver/pkg/utils"
"github.com/kubeagi/arcadia/pkg/config"
"github.com/kubeagi/arcadia/pkg/datasource"
Expand Down Expand Up @@ -85,20 +86,21 @@ func cr2app(prompt *apiprompt.Prompt, chainConfig *apichain.CommonChainConfig, r
icon := common.AppIconLink(app, pkgconf.GetConfig().PlaygroundEndpointPrefix)
gApp := &generated.Application{
Metadata: &generated.ApplicationMetadata{
Name: app.Name,
Namespace: app.Namespace,
ID: pointer.String(string(app.UID)),
Labels: utils.MapStr2Any(app.Labels),
Annotations: utils.MapStr2Any(app.Annotations),
DisplayName: pointer.String(app.Spec.DisplayName),
Description: pointer.String(app.Spec.Description),
Icon: &icon,
Creator: pointer.String(app.Spec.Creator),
CreationTimestamp: &app.CreationTimestamp.Time,
UpdateTimestamp: UpdateTimestamp,
IsPublic: pointer.Bool(app.Spec.IsPublic),
IsRecommended: pointer.Bool(app.Spec.IsRecommended),
Status: pointer.String(status),
Name: app.Name,
Namespace: app.Namespace,
ID: pointer.String(string(app.UID)),
Labels: utils.MapStr2Any(app.Labels),
Annotations: utils.MapStr2Any(app.Annotations),
DisplayName: pointer.String(app.Spec.DisplayName),
Description: pointer.String(app.Spec.Description),
Icon: &icon,
Creator: pointer.String(app.Spec.Creator),
CreationTimestamp: &app.CreationTimestamp.Time,
UpdateTimestamp: UpdateTimestamp,
IsPublic: pointer.Bool(app.Spec.IsPublic),
IsRecommended: pointer.Bool(app.Spec.IsRecommended),
Status: pointer.String(status),
NotReadyReasonCode: pointer.String(string(gpt.GetGPTNotReadyReasonCode(app))),
},
Prologue: pointer.String(app.Spec.Prologue),
ShowNextGuide: pointer.Bool(app.Spec.ShowNextGuide),
Expand Down Expand Up @@ -491,11 +493,13 @@ func UpdateApplicationConfig(ctx context.Context, c client.Client, input generat
},
ChunkSize: pointer.IntDeref(input.ChunkSize, 1024),
ChunkOverlap: input.ChunkOverlap,
BatchSize: pointer.IntDeref(input.BatchSize, 3),
LoaderConfig: apidocumentloader.LoaderConfig{},
},
}
if _, err := controllerutil.CreateOrUpdate(ctx, c, documentLoader, func() error {
documentLoader.Spec.ChunkSize = pointer.IntDeref(input.ChunkSize, documentLoader.Spec.ChunkSize)
documentLoader.Spec.BatchSize = pointer.IntDeref(input.BatchSize, documentLoader.Spec.BatchSize)
if input.ChunkOverlap == nil {
documentLoader.Spec.ChunkOverlap = pointer.Int(50)
} else {
Expand Down

0 comments on commit 24612a4

Please sign in to comment.