Skip to content

Commit

Permalink
feat: able to set/update models in LLM and Embedder
Browse files Browse the repository at this point in the history
Signed-off-by: bjwswang <[email protected]>
  • Loading branch information
bjwswang committed Jan 24, 2024
1 parent 2626e7b commit 3d5751f
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 36 deletions.
64 changes: 60 additions & 4 deletions apiserver/graph/generated/generated.go

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

8 changes: 8 additions & 0 deletions apiserver/graph/generated/models_gen.go

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

10 changes: 10 additions & 0 deletions apiserver/graph/schema/embedder.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ input CreateEmbedderInput {
规则: 目前支持 zhipuai,openai两种接口类型
"""
type: String

"""
此LLM支持调用的模型列表
"""
models: [String!]
}

input UpdateEmbedderInput {
Expand All @@ -80,6 +85,11 @@ input UpdateEmbedderInput {
规则: 目前支持 zhipuai,openai两种接口类型
"""
type: String

"""
此LLM支持调用的模型列表
"""
models: [String!]
}

type EmbedderQuery {
Expand Down
10 changes: 10 additions & 0 deletions apiserver/graph/schema/llm.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ input CreateLLMInput {
规则: 目前支持 zhipuai,openai两种接口类型
"""
type: String

"""
此LLM支持调用的模型列表
"""
models: [String!]
}

input UpdateLLMInput {
Expand All @@ -79,6 +84,11 @@ input UpdateLLMInput {
规则: 目前支持 zhipuai,openai两种接口类型
"""
type: String

"""
此LLM支持调用的模型列表
"""
models: [String!]
}

type LLMQuery {
Expand Down
8 changes: 7 additions & 1 deletion apiserver/pkg/embedder/embedder.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ func CreateEmbedder(ctx context.Context, c dynamic.Interface, input generated.Cr
URL: input.Endpointinput.URL,
},
},
Type: embeddings.EmbeddingType(servicetype),
Type: embeddings.EmbeddingType(servicetype),
Models: input.Models,
},
}

Expand Down Expand Up @@ -210,6 +211,11 @@ func UpdateEmbedder(ctx context.Context, c dynamic.Interface, input *generated.U
updatedEmbedder.Spec.Type = embeddings.EmbeddingType(*input.Type)
}

// update LLM's models if specified
if input.Models != nil {
updatedEmbedder.Spec.Models = input.Models
}

// Update endpoint
if input.Endpointinput != nil {
endpoint, err := common.MakeEndpoint(ctx, c, generated.TypedObjectReferenceInput{
Expand Down
8 changes: 7 additions & 1 deletion apiserver/pkg/llm/llm.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ func CreateLLM(ctx context.Context, c dynamic.Interface, input generated.CreateL
URL: input.Endpointinput.URL,
},
},
Type: llms.LLMType(APIType),
Type: llms.LLMType(APIType),
Models: input.Models,
},
}
common.SetCreator(ctx, &llm.Spec.CommonSpec)
Expand Down Expand Up @@ -266,6 +267,11 @@ func UpdateLLM(ctx context.Context, c dynamic.Interface, input *generated.Update
updatedLLM.Spec.Type = llms.LLMType(*input.Type)
}

// update LLM's models if specified
if input.Models != nil {
updatedLLM.Spec.Models = input.Models
}

// Update endpoint
if input.Endpointinput != nil {
endpoint, err := common.MakeEndpoint(ctx, c, generated.TypedObjectReferenceInput{
Expand Down
Loading

0 comments on commit 3d5751f

Please sign in to comment.