From 1e1acd4f58b5f767446d8db87ffc1e363e412529 Mon Sep 17 00:00:00 2001 From: Luke Marsden Date: Thu, 14 Nov 2024 10:48:18 +0000 Subject: [PATCH] add basic knowledge fields to crd types --- operator/api/v1alpha1/aiapp_types.go | 43 ++++++++- .../api/v1alpha1/zz_generated.deepcopy.go | 89 ++++++++++++++++++- .../crd/bases/app.aispec.org_aiapps.yaml | 87 +++++++++++++++++- 3 files changed, 211 insertions(+), 8 deletions(-) diff --git a/operator/api/v1alpha1/aiapp_types.go b/operator/api/v1alpha1/aiapp_types.go index 81232a1c..f10211f0 100644 --- a/operator/api/v1alpha1/aiapp_types.go +++ b/operator/api/v1alpha1/aiapp_types.go @@ -118,11 +118,48 @@ type TestStep struct { ExpectedOutput string `json:"expected_output"` } +// RAGSettings contains settings for RAG processing +type RAGSettings struct { + Threshold int `json:"threshold"` + ResultsCount int `json:"results_count"` + ChunkSize int `json:"chunk_size"` + ChunkOverflow int `json:"chunk_overflow"` + DisableChunking bool `json:"disable_chunking"` + DisableDownloading bool `json:"disable_downloading"` +} + +// FilestoreSource represents filestore configuration +type FilestoreSource struct { + Path string `json:"path"` +} + +// WebCrawlerConfig contains web crawler settings +type WebCrawlerConfig struct { + Enabled bool `json:"enabled"` + MaxDepth int `json:"max_depth"` + MaxPages int `json:"max_pages"` + Readability bool `json:"readability"` +} + +// WebSource represents web source configuration +type WebSource struct { + URLs []string `json:"urls"` + Crawler WebCrawlerConfig `json:"crawler"` +} + +// KnowledgeSource contains source configuration for knowledge +type KnowledgeSource struct { + Filestore FilestoreSource `json:"filestore"` + Web WebSource `json:"web"` +} + // AssistantKnowledge represents knowledge configuration for an assistant -// Note: This type wasn't in the original types.go, but was referenced. -// You'll need to define its structure based on your requirements type AssistantKnowledge struct { - // Add fields as needed + Name string `json:"name"` + RAGSettings RAGSettings `json:"rag_settings"` + Source KnowledgeSource `json:"source"` + RefreshEnabled bool `json:"refresh_enabled"` + RefreshSchedule string `json:"refresh_schedule,omitempty"` } // ToolApiConfig represents API tool configuration diff --git a/operator/api/v1alpha1/zz_generated.deepcopy.go b/operator/api/v1alpha1/zz_generated.deepcopy.go index c816e0d9..2565a151 100644 --- a/operator/api/v1alpha1/zz_generated.deepcopy.go +++ b/operator/api/v1alpha1/zz_generated.deepcopy.go @@ -155,7 +155,9 @@ func (in *AssistantConfig) DeepCopyInto(out *AssistantConfig) { if in.Knowledge != nil { in, out := &in.Knowledge, &out.Knowledge *out = make([]AssistantKnowledge, len(*in)) - copy(*out, *in) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } if in.APIs != nil { in, out := &in.APIs, &out.APIs @@ -218,6 +220,8 @@ func (in *AssistantGPTScript) DeepCopy() *AssistantGPTScript { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AssistantKnowledge) DeepCopyInto(out *AssistantKnowledge) { *out = *in + out.RAGSettings = in.RAGSettings + in.Source.DeepCopyInto(&out.Source) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AssistantKnowledge. @@ -265,6 +269,53 @@ func (in *AssistantZapier) DeepCopy() *AssistantZapier { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FilestoreSource) DeepCopyInto(out *FilestoreSource) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FilestoreSource. +func (in *FilestoreSource) DeepCopy() *FilestoreSource { + if in == nil { + return nil + } + out := new(FilestoreSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KnowledgeSource) DeepCopyInto(out *KnowledgeSource) { + *out = *in + out.Filestore = in.Filestore + in.Web.DeepCopyInto(&out.Web) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KnowledgeSource. +func (in *KnowledgeSource) DeepCopy() *KnowledgeSource { + if in == nil { + return nil + } + out := new(KnowledgeSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RAGSettings) DeepCopyInto(out *RAGSettings) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RAGSettings. +func (in *RAGSettings) DeepCopy() *RAGSettings { + if in == nil { + return nil + } + out := new(RAGSettings) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TestStep) DeepCopyInto(out *TestStep) { *out = *in @@ -406,3 +457,39 @@ func (in *ToolZapierConfig) DeepCopy() *ToolZapierConfig { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WebCrawlerConfig) DeepCopyInto(out *WebCrawlerConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebCrawlerConfig. +func (in *WebCrawlerConfig) DeepCopy() *WebCrawlerConfig { + if in == nil { + return nil + } + out := new(WebCrawlerConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WebSource) DeepCopyInto(out *WebSource) { + *out = *in + if in.URLs != nil { + in, out := &in.URLs, &out.URLs + *out = make([]string, len(*in)) + copy(*out, *in) + } + out.Crawler = in.Crawler +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebSource. +func (in *WebSource) DeepCopy() *WebSource { + if in == nil { + return nil + } + out := new(WebSource) + in.DeepCopyInto(out) + return out +} diff --git a/operator/config/crd/bases/app.aispec.org_aiapps.yaml b/operator/config/crd/bases/app.aispec.org_aiapps.yaml index d8c9e3f0..55269d5d 100644 --- a/operator/config/crd/bases/app.aispec.org_aiapps.yaml +++ b/operator/config/crd/bases/app.aispec.org_aiapps.yaml @@ -113,10 +113,89 @@ spec: knowledge: description: Knowledge available to the assistant items: - description: |- - AssistantKnowledge represents knowledge configuration for an assistant - Note: This type wasn't in the original types.go, but was referenced. - You'll need to define its structure based on your requirements + description: AssistantKnowledge represents knowledge configuration + for an assistant + properties: + name: + type: string + rag_settings: + description: RAGSettings contains settings for RAG processing + properties: + chunk_overflow: + type: integer + chunk_size: + type: integer + disable_chunking: + type: boolean + disable_downloading: + type: boolean + results_count: + type: integer + threshold: + type: integer + required: + - chunk_overflow + - chunk_size + - disable_chunking + - disable_downloading + - results_count + - threshold + type: object + refresh_enabled: + type: boolean + refresh_schedule: + type: string + source: + description: KnowledgeSource contains source configuration + for knowledge + properties: + filestore: + description: FilestoreSource represents filestore + configuration + properties: + path: + type: string + required: + - path + type: object + web: + description: WebSource represents web source configuration + properties: + crawler: + description: WebCrawlerConfig contains web crawler + settings + properties: + enabled: + type: boolean + max_depth: + type: integer + max_pages: + type: integer + readability: + type: boolean + required: + - enabled + - max_depth + - max_pages + - readability + type: object + urls: + items: + type: string + type: array + required: + - crawler + - urls + type: object + required: + - filestore + - web + type: object + required: + - name + - rag_settings + - refresh_enabled + - source type: object type: array lora_id: