|
| 1 | +// Copyright (c) Microsoft. All rights reserved. |
| 2 | + |
| 3 | +namespace Microsoft.KernelMemory; |
| 4 | + |
| 5 | +public static class Constants |
| 6 | +{ |
| 7 | + public static class WebService |
| 8 | + { |
| 9 | + // Form field/Query param containing the Index Name |
| 10 | + public const string IndexField = "index"; |
| 11 | + |
| 12 | + // Form field/Query param containing the Document ID |
| 13 | + public const string DocumentIdField = "documentId"; |
| 14 | + |
| 15 | + // Form field/Query param containing the Filename |
| 16 | + public const string FilenameField = "filename"; |
| 17 | + |
| 18 | + // Form field containing the list of tags |
| 19 | + public const string TagsField = "tags"; |
| 20 | + |
| 21 | + // Form field containing the list of pipeline steps |
| 22 | + public const string StepsField = "steps"; |
| 23 | + |
| 24 | + // Form field containing the optional arguments JSON string |
| 25 | + public const string ArgsField = "args"; |
| 26 | + } |
| 27 | + |
| 28 | + public static class CustomContext |
| 29 | + { |
| 30 | + public static class Partitioning |
| 31 | + { |
| 32 | + // Used to override MaxTokensPerParagraph config |
| 33 | + public const string MaxTokensPerParagraph = "custom_partitioning_max_tokens_per_paragraph_int"; |
| 34 | + |
| 35 | + // Used to override OverlappingTokens config |
| 36 | + public const string OverlappingTokens = "custom_partitioning_overlapping_tokens_int"; |
| 37 | + |
| 38 | + // Used to prepend header to each partition |
| 39 | + public const string ChunkHeader = "custom_partitioning_chunk_header_str"; |
| 40 | + } |
| 41 | + |
| 42 | + public static class EmbeddingGeneration |
| 43 | + { |
| 44 | + // Used to override MaxBatchSize embedding generators config |
| 45 | + public const string BatchSize = "custom_embedding_generation_batch_size_int"; |
| 46 | + } |
| 47 | + |
| 48 | + public static class Rag |
| 49 | + |
| 50 | + { |
| 51 | + // Used to override No Answer config |
| 52 | + public const string EmptyAnswer = "custom_rag_empty_answer_str"; |
| 53 | + |
| 54 | + // Used to override the RAG prompt |
| 55 | + public const string Prompt = "custom_rag_prompt_str"; |
| 56 | + |
| 57 | + // Used to override how facts are injected into RAG prompt |
| 58 | + public const string FactTemplate = "custom_rag_fact_template_str"; |
| 59 | + |
| 60 | + // Used to override the max tokens to generate when using the RAG prompt |
| 61 | + public const string MaxTokens = "custom_rag_max_tokens_int"; |
| 62 | + |
| 63 | + // Used to override the temperature (default 0) used with the RAG prompt |
| 64 | + public const string Temperature = "custom_rag_temperature_float"; |
| 65 | + |
| 66 | + // Used to override the nucleus sampling probability (default 0) used with the RAG prompt |
| 67 | + public const string NucleusSampling = "custom_rag_nucleus_sampling_float"; |
| 68 | + } |
| 69 | + |
| 70 | + public static class Summary |
| 71 | + { |
| 72 | + // Used to override the summarization prompt |
| 73 | + public const string Prompt = "custom_summary_prompt_str"; |
| 74 | + |
| 75 | + // Used to override the size of the summary |
| 76 | + public const string TargetTokenSize = "custom_summary_target_token_size_int"; |
| 77 | + |
| 78 | + // Used to override the number of overlapping tokens |
| 79 | + public const string OverlappingTokens = "custom_summary_overlapping_tokens_int"; |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + // // Default User ID owning documents uploaded without specifying a user |
| 84 | + // public const string DefaultDocumentOwnerUserId = "defaultUser"; |
| 85 | + |
| 86 | + // Internal file used to track progress of asynchronous pipelines |
| 87 | + public const string PipelineStatusFilename = "__pipeline_status.json"; |
| 88 | + |
| 89 | + // Tags settings |
| 90 | + public const char ReservedEqualsChar = ':'; |
| 91 | + public const string ReservedTagsPrefix = "__"; |
| 92 | + |
| 93 | + // Tags reserved for internal logic |
| 94 | + public const string ReservedDocumentIdTag = $"{ReservedTagsPrefix}document_id"; |
| 95 | + public const string ReservedFileIdTag = $"{ReservedTagsPrefix}file_id"; |
| 96 | + public const string ReservedFilePartitionTag = $"{ReservedTagsPrefix}file_part"; |
| 97 | + public const string ReservedFilePartitionNumberTag = $"{ReservedTagsPrefix}part_n"; |
| 98 | + public const string ReservedFileSectionNumberTag = $"{ReservedTagsPrefix}sect_n"; |
| 99 | + public const string ReservedFileTypeTag = $"{ReservedTagsPrefix}file_type"; |
| 100 | + public const string ReservedSyntheticTypeTag = $"{ReservedTagsPrefix}synth"; |
| 101 | + |
| 102 | + // Known tags |
| 103 | + public const string TagsSyntheticSummary = "summary"; |
| 104 | + |
| 105 | + // Properties stored inside the payload |
| 106 | + public const string ReservedPayloadSchemaVersionField = "schema"; |
| 107 | + public const string ReservedPayloadTextField = "text"; |
| 108 | + public const string ReservedPayloadFileNameField = "file"; |
| 109 | + public const string ReservedPayloadUrlField = "url"; |
| 110 | + public const string ReservedPayloadLastUpdateField = "last_update"; |
| 111 | + public const string ReservedPayloadVectorProviderField = "vector_provider"; |
| 112 | + public const string ReservedPayloadVectorGeneratorField = "vector_generator"; |
| 113 | + |
| 114 | + // Endpoints |
| 115 | + public const string HttpAskEndpoint = "/ask"; |
| 116 | + public const string HttpSearchEndpoint = "/search"; |
| 117 | + public const string HttpDownloadEndpoint = "/download"; |
| 118 | + public const string HttpUploadEndpoint = "/upload"; |
| 119 | + public const string HttpUploadStatusEndpoint = "/upload-status"; |
| 120 | + public const string HttpDocumentsEndpoint = "/documents"; |
| 121 | + public const string HttpIndexesEndpoint = "/indexes"; |
| 122 | + public const string HttpDeleteDocumentEndpointWithParams = $"{HttpDocumentsEndpoint}?{WebService.IndexField}={HttpIndexPlaceholder}&{WebService.DocumentIdField}={HttpDocumentIdPlaceholder}"; |
| 123 | + public const string HttpDeleteIndexEndpointWithParams = $"{HttpIndexesEndpoint}?{WebService.IndexField}={HttpIndexPlaceholder}"; |
| 124 | + public const string HttpUploadStatusEndpointWithParams = $"{HttpUploadStatusEndpoint}?{WebService.IndexField}={HttpIndexPlaceholder}&{WebService.DocumentIdField}={HttpDocumentIdPlaceholder}"; |
| 125 | + public const string HttpDownloadEndpointWithParams = $"{HttpDownloadEndpoint}?{WebService.IndexField}={HttpIndexPlaceholder}&{WebService.DocumentIdField}={HttpDocumentIdPlaceholder}&{WebService.FilenameField}={HttpFilenamePlaceholder}"; |
| 126 | + public const string HttpIndexPlaceholder = "{index}"; |
| 127 | + public const string HttpDocumentIdPlaceholder = "{documentId}"; |
| 128 | + public const string HttpFilenamePlaceholder = "{filename}"; |
| 129 | + |
| 130 | + // Pipeline Handlers, Step names |
| 131 | + public const string PipelineStepsExtract = "extract"; |
| 132 | + public const string PipelineStepsPartition = "partition"; |
| 133 | + public const string PipelineStepsGenEmbeddings = "gen_embeddings"; |
| 134 | + public const string PipelineStepsSaveRecords = "save_records"; |
| 135 | + public const string PipelineStepsSummarize = "summarize"; |
| 136 | + public const string PipelineStepsDeleteGeneratedFiles = "delete_generated_files"; |
| 137 | + public const string PipelineStepsDeleteDocument = "private_delete_document"; |
| 138 | + public const string PipelineStepsDeleteIndex = "private_delete_index"; |
| 139 | + public const string PipelineStepsKeywordExtraction = "keyword_extraction"; |
| 140 | + |
| 141 | + // Pipeline steps |
| 142 | + public static readonly string[] DefaultPipeline = |
| 143 | + { |
| 144 | + PipelineStepsExtract, PipelineStepsPartition, PipelineStepsGenEmbeddings, PipelineStepsSaveRecords |
| 145 | + }; |
| 146 | + |
| 147 | + public static readonly string[] PipelineWithoutSummary = |
| 148 | + { |
| 149 | + PipelineStepsExtract, PipelineStepsPartition, PipelineStepsGenEmbeddings, PipelineStepsSaveRecords |
| 150 | + }; |
| 151 | + |
| 152 | + public static readonly string[] PipelineWithSummary = |
| 153 | + { |
| 154 | + PipelineStepsExtract, PipelineStepsPartition, PipelineStepsGenEmbeddings, PipelineStepsSaveRecords, |
| 155 | + PipelineStepsSummarize, PipelineStepsGenEmbeddings, PipelineStepsSaveRecords |
| 156 | + }; |
| 157 | + |
| 158 | + public static readonly string[] PipelineOnlySummary = |
| 159 | + { |
| 160 | + PipelineStepsExtract, PipelineStepsSummarize, PipelineStepsGenEmbeddings, PipelineStepsSaveRecords |
| 161 | + }; |
| 162 | + |
| 163 | + // Standard prompt names |
| 164 | + public const string PromptNamesSummarize = "summarize"; |
| 165 | + public const string PromptNamesAnswerWithFacts = "answer-with-facts"; |
| 166 | +} |
0 commit comments