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

feat: Add vector store settings #1932

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
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,48 @@ spec:
x-kubernetes-map-type: atomic
type: object
type: object
vectorStore:
properties:
elastic:
properties:
host:
type: string
index:
type: string
passwordSecretRef:
description: SecretKeySelector selects a key of a Secret.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
optional:
description: Specify whether the Secret or its key
must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
user:
type: string
required:
- host
- index
type: object
enabled:
default: false
type: boolean
vectorStore:
enum:
- ELASTIC
type: string
type: object
vertex:
description: Vertex holds configuration for using GCP VertexAI
to generate LLM insights
Expand Down
85 changes: 85 additions & 0 deletions go/controller/api/v1alpha1/deploymentsettings_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ type AISettings struct {
//
// +kubebuilder:validation:Optional
Vertex *VertexSettings `json:"vertex,omitempty"`

// +kubebuilder:validation:Optional
VectorStore *VectorStore `json:"vectorStore,omitempty"`
}

type Tools struct {
Expand Down Expand Up @@ -369,11 +372,17 @@ func (in *LoggingSettings) Attributes(ctx context.Context, c client.Client, name
}

func (in *AISettings) Attributes(ctx context.Context, c client.Client, namespace string) (*console.AiSettingsAttributes, error) {
vectorStoreAttributes, err := in.VectorStore.Attributes(ctx, c, namespace)
if err != nil {
return nil, err
}

attr := &console.AiSettingsAttributes{
Enabled: in.Enabled,
Provider: in.Provider,
ToolProvider: in.ToolProvider,
EmbeddingProvider: in.EmbeddingProvider,
VectorStore: vectorStoreAttributes,
}

if in.Tools != nil && in.Tools.CreatePr != nil {
Expand Down Expand Up @@ -691,3 +700,79 @@ func (in *VertexSettings) ServiceAccountJSON(ctx context.Context, c client.Clien
res, err := utils.GetSecretKey(ctx, c, in.ServiceAccountJsonSecretRef, namespace)
return lo.ToPtr(res), err
}

type VectorStore struct {
// +kubebuilder:default=false
// +kubebuilder:validation:Optional
Enabled *bool `json:"enabled,omitempty"`

// +kubebuilder:validation:Enum=ELASTIC
// +kubebuilder:validation:Optional
VectorStore *console.VectorStore `json:"vectorStore,omitempty"`

// +kubebuilder:validation:Optional
Elastic *ElasticsearchConnectionSettings `json:"elastic,omitempty"`
}

func (in *VectorStore) Attributes(ctx context.Context, c client.Client, namespace string) (*console.VectorStoreAttributes, error) {
if in == nil {
return nil, nil
}

if lo.FromPtr(in.Enabled) && in.VectorStore == nil {
return nil, fmt.Errorf("vector store type has to be set if it is enabled")
}

attr := &console.VectorStoreAttributes{
Enabled: in.Enabled,
Store: in.VectorStore,
}

switch *in.VectorStore {
case console.VectorStoreElastic:
if in.Elastic == nil {
return nil, fmt.Errorf("must provide elastic configuration to set the provider to ELASTIC")
}

password, err := in.Elastic.Password(ctx, c, namespace)
if err != nil {
return nil, err
}

attr.Elastic = &console.ElasticsearchConnectionAttributes{
Host: in.Elastic.Host,
Index: in.Elastic.Index,
User: in.Elastic.User,
Password: password,
}
}

return attr, nil
}

type ElasticsearchConnectionSettings struct {
// +kubebuilder:validation:Required
Host string `json:"host"`

// +kubebuilder:validation:Required
Index string `json:"index"`

// +kubebuilder:validation:Optional
User *string `json:"user,omitempty"`

// +kubebuilder:validation:Optional
PasswordSecretRef *corev1.SecretKeySelector `json:"passwordSecretRef,omitempty"`
}

func (in *ElasticsearchConnectionSettings) Password(ctx context.Context, c client.Client, namespace string) (*string, error) {
if in == nil {
return nil, fmt.Errorf("configured elastic settings cannot be nil")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to make sure that error is able to be backoffed properly by the controller when the secret doesn't yet exist

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you review controller improvements that we did with @zreigz? It would make it easier. Otherwise I can just take some bits from that PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've integrated part of the changes from #1893. Now, not found error will be propagated to the Reconcile function and handled in handleRequeue function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh my fault, yea approved that pr

}

if in.PasswordSecretRef == nil {
return nil, nil
}

res, err := utils.GetSecretKey(ctx, c, in.PasswordSecretRef, namespace)
return lo.ToPtr(res), err
}
60 changes: 60 additions & 0 deletions go/controller/api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,48 @@ spec:
x-kubernetes-map-type: atomic
type: object
type: object
vectorStore:
properties:
elastic:
properties:
host:
type: string
index:
type: string
passwordSecretRef:
description: SecretKeySelector selects a key of a Secret.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
optional:
description: Specify whether the Secret or its key
must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
user:
type: string
required:
- host
- index
type: object
enabled:
default: false
type: boolean
vectorStore:
enum:
- ELASTIC
type: string
type: object
vertex:
description: Vertex holds configuration for using GCP VertexAI
to generate LLM insights
Expand Down
44 changes: 44 additions & 0 deletions go/controller/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ _Appears in:_
| --- | --- | --- | --- |
| `model` _string_ | Model is the LLM model name to use. | | Optional: {} <br /> |
| `toolModel` _string_ | Model to use for tool calling, which is less frequent and often requires more advanced reasoning | | Optional: {} <br /> |
| `embeddingModel` _string_ | Model to use for generating embeddings | | Optional: {} <br /> |
| `baseUrl` _string_ | A custom base url to use, for reimplementations of the same API scheme (for instance Together.ai uses the OpenAI API spec) | | Optional: {} <br /> |
| `tokenSecretRef` _[SecretKeySelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#secretkeyselector-v1-core)_ | TokenSecretRef is a reference to the local secret holding the token to access<br />the configured AI provider. | | Required: {} <br /> |

Expand All @@ -77,12 +78,14 @@ _Appears in:_
| `tools` _[Tools](#tools)_ | | | Optional: {} <br /> |
| `provider` _[AiProvider](#aiprovider)_ | Provider defines which of the supported LLM providers should be used. | OPENAI | Enum: [OPENAI ANTHROPIC OLLAMA AZURE BEDROCK VERTEX] <br />Optional: {} <br /> |
| `toolProvider` _[AiProvider](#aiprovider)_ | Provider to use for tool calling, in case you want to use a different LLM more optimized to those tasks | | Enum: [OPENAI ANTHROPIC OLLAMA AZURE BEDROCK VERTEX] <br />Optional: {} <br /> |
| `embeddingProvider` _[AiProvider](#aiprovider)_ | Provider to use for generating embeddings. Oftentimes foundational model providers do not have embeddings models, and it's better to simply use OpenAI. | | Enum: [OPENAI ANTHROPIC OLLAMA AZURE BEDROCK VERTEX] <br />Optional: {} <br /> |
| `openAI` _[AIProviderSettings](#aiprovidersettings)_ | OpenAI holds the OpenAI provider configuration. | | Optional: {} <br /> |
| `anthropic` _[AIProviderSettings](#aiprovidersettings)_ | Anthropic holds the Anthropic provider configuration. | | Optional: {} <br /> |
| `ollama` _[OllamaSettings](#ollamasettings)_ | Ollama holds configuration for a self-hosted Ollama deployment, more details available at https://github.com/ollama/ollama | | Optional: {} <br /> |
| `azure` _[AzureOpenAISettings](#azureopenaisettings)_ | Azure holds configuration for using AzureOpenAI to generate LLM insights | | Optional: {} <br /> |
| `bedrock` _[BedrockSettings](#bedrocksettings)_ | Bedrock holds configuration for using AWS Bedrock to generate LLM insights | | Optional: {} <br /> |
| `vertex` _[VertexSettings](#vertexsettings)_ | Vertex holds configuration for using GCP VertexAI to generate LLM insights | | Optional: {} <br /> |
| `vectorStore` _[VectorStore](#vectorstore)_ | | | Optional: {} <br /> |



Expand All @@ -104,6 +107,7 @@ _Appears in:_
| `apiVersion` _string_ | The azure openai Data plane - inference api version to use, defaults to 2024-10-01-preview or the latest available | | Optional: {} <br /> |
| `model` _string_ | The OpenAi Model you wish to use. If not specified, Plural will provide a default | | Optional: {} <br /> |
| `toolModel` _string_ | Model to use for tool calling, which is less frequent and often requires more advanced reasoning | | Optional: {} <br /> |
| `embeddingModel` _string_ | Model to use for generating embeddings | | Optional: {} <br /> |
| `tokenSecretRef` _[SecretKeySelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#secretkeyselector-v1-core)_ | TokenSecretRef is a reference to the local secret holding the token to access<br />the configured AI provider. | | Required: {} <br /> |


Expand Down Expand Up @@ -821,6 +825,8 @@ _Appears in:_
| `ai` _[AISettings](#aisettings)_ | AI settings specifies a configuration for LLM provider clients | | Optional: {} <br /> |
| `logging` _[LoggingSettings](#loggingsettings)_ | Settings for connections to log aggregation datastores | | Optional: {} <br /> |
| `cost` _[CostSettings](#costsettings)_ | Settings for managing Plural's cost management features | | Optional: {} <br /> |
| `deploymentRepositoryRef` _[NamespacedName](#namespacedname)_ | pointer to the deployment GIT repository to use | | Optional: {} <br /> |
| `scaffoldsRepositoryRef` _[NamespacedName](#namespacedname)_ | pointer to the Scaffolds GIT repository to use | | Optional: {} <br /> |


#### ElasticsearchConnection
Expand All @@ -842,6 +848,25 @@ _Appears in:_
| `passwordSecretRef` _[SecretKeySelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#secretkeyselector-v1-core)_ | PasswordSecretRef selects a key of a password Secret | | Optional: {} <br /> |


#### ElasticsearchConnectionSettings







_Appears in:_
- [VectorStore](#vectorstore)

| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `host` _string_ | | | Required: {} <br /> |
| `index` _string_ | | | Required: {} <br /> |
| `user` _string_ | | | Optional: {} <br /> |
| `passwordSecretRef` _[SecretKeySelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#secretkeyselector-v1-core)_ | | | Optional: {} <br /> |





Expand Down Expand Up @@ -1390,6 +1415,7 @@ with the addition of kubebuilder/json annotations for better schema support.


_Appears in:_
- [DeploymentSettingsSpec](#deploymentsettingsspec)
- [ServiceHelm](#servicehelm)

| Field | Description | Default | Validation |
Expand Down Expand Up @@ -2918,6 +2944,24 @@ _Appears in:_
| `createPr` _[CreatePr](#createpr)_ | | | |


#### VectorStore







_Appears in:_
- [AISettings](#aisettings)

| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `enabled` _boolean_ | | false | Optional: {} <br /> |
| `vectorStore` _[VectorStore](#vectorstore)_ | | | Enum: [ELASTIC] <br />Optional: {} <br /> |
| `elastic` _[ElasticsearchConnectionSettings](#elasticsearchconnectionsettings)_ | | | Optional: {} <br /> |


#### VertexSettings


Expand Down
Loading
Loading