File size: 3,020 Bytes
7bd11ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Configuration for embeddings, including paths, models, and document settings
type EmbeddingsConfig = {
    embeddings_path: string; // Path where embeddings will be saved
    embedding_model: { // Optional embedding model specification
        model_name: string; // Name of the model
    };
    splade_config: { // Optional configuration for SPLADE
        n_batch: number; // Batch size for processing
    };
    chunk_sizes: number[]; // Chunk sizes for splitting during embedding
    document_settings: { // Settings for document processing
        doc_path: string; // Path to documents
        additional_parser_settings?: { // Optional settings for parsing documents
            md: { // Settings for Markdown documents
                skip_first: boolean; // Whether to skip the first section
                merge_sections: boolean; // Whether to merge sections
                remove_images: boolean; // Whether to remove images from documents
            };
        };
        passage_prefix: string; // Prefix for passages
    }[];
};

// Configuration for semantic search functionality
type SemanticSearchConfig = {
    max_k: number; // Maximum number of results to return
    max_char_size: number; // Max character size for context provided to models
    query_prefix: string; // Prefix for queries
};

export type AppConfig = {
    cache_folder: string;
    embeddings: EmbeddingsConfig;
    semantic_search: SemanticSearchConfig;
};

// Type definition for the LLM configuration section for OpenAI models
type OpenAIConfig = {
    type: 'openai'; // Specifies the use of an OpenAI model
    params: {
        prompt_template: string; // Template for constructing prompts for the model. It includes placeholders for context and questions.
        model_kwargs: { // Keyword arguments for configuring the model's inference behavior
            openai_api_key: string; // API key for accessing the OpenAI API
            temperature: number; // Temperature setting for controlling the randomness of response generation. A value of 0.0 generates deterministic responses.
            model_name: string; // Specifies the name of the model to be used for generating responses.
        };
    };
};

// Type definition for the LLM configuration section for Google VertexAI models
type VertexAIConfig = {
    type: 'vertexai'; // Specifies the use of an OpenAI model
    params: {
        prompt_template: string; // Template for constructing prompts for the model. It includes placeholders for context and questions.
        model_kwargs: { // Keyword arguments for configuring the model's inference behavior
            model_name: string; // Specifies the name of the model to be used for generating responses.
            temperature: number; // Temperature setting for controlling the randomness of response generation. A value of 0.0 generates deterministic responses.
        };
    };
};

// Type definition for the LLM configuration section
export type LLMConfig = OpenAIConfig | VertexAIConfig;