chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace VectorStoreRAG.Options;
|
||||
|
||||
/// <summary>
|
||||
/// Helper class to load all configuration settings for the VectorStoreRAG project.
|
||||
/// </summary>
|
||||
internal sealed class ApplicationConfig
|
||||
{
|
||||
private readonly AzureOpenAIConfig _azureOpenAIConfig;
|
||||
private readonly AzureOpenAIEmbeddingsConfig _azureOpenAIEmbeddingsConfig = new();
|
||||
private readonly OpenAIConfig _openAIConfig = new();
|
||||
private readonly OpenAIEmbeddingsConfig _openAIEmbeddingsConfig = new();
|
||||
private readonly RagConfig _ragConfig = new();
|
||||
private readonly AzureAISearchConfig _azureAISearchConfig = new();
|
||||
private readonly CosmosConfig _cosmosMongoConfig = new();
|
||||
private readonly CosmosConfig _cosmosNoSqlConfig = new();
|
||||
private readonly QdrantConfig _qdrantConfig = new();
|
||||
private readonly RedisConfig _redisConfig = new();
|
||||
private readonly WeaviateConfig _weaviateConfig = new();
|
||||
|
||||
public ApplicationConfig(ConfigurationManager configurationManager)
|
||||
{
|
||||
this._azureOpenAIConfig = new();
|
||||
configurationManager
|
||||
.GetRequiredSection($"AIServices:{AzureOpenAIConfig.ConfigSectionName}")
|
||||
.Bind(this._azureOpenAIConfig);
|
||||
configurationManager
|
||||
.GetRequiredSection($"AIServices:{AzureOpenAIEmbeddingsConfig.ConfigSectionName}")
|
||||
.Bind(this._azureOpenAIEmbeddingsConfig);
|
||||
configurationManager
|
||||
.GetRequiredSection($"AIServices:{OpenAIConfig.ConfigSectionName}")
|
||||
.Bind(this._openAIConfig);
|
||||
configurationManager
|
||||
.GetRequiredSection($"AIServices:{OpenAIEmbeddingsConfig.ConfigSectionName}")
|
||||
.Bind(this._openAIEmbeddingsConfig);
|
||||
configurationManager
|
||||
.GetRequiredSection(RagConfig.ConfigSectionName)
|
||||
.Bind(this._ragConfig);
|
||||
configurationManager
|
||||
.GetRequiredSection($"VectorStores:{AzureAISearchConfig.ConfigSectionName}")
|
||||
.Bind(this._azureAISearchConfig);
|
||||
configurationManager
|
||||
.GetRequiredSection($"VectorStores:{CosmosConfig.MongoConfigSectionName}")
|
||||
.Bind(this._cosmosMongoConfig);
|
||||
configurationManager
|
||||
.GetRequiredSection($"VectorStores:{CosmosConfig.NoSqlConfigSectionName}")
|
||||
.Bind(this._cosmosNoSqlConfig);
|
||||
configurationManager
|
||||
.GetRequiredSection($"VectorStores:{QdrantConfig.ConfigSectionName}")
|
||||
.Bind(this._qdrantConfig);
|
||||
configurationManager
|
||||
.GetRequiredSection($"VectorStores:{RedisConfig.ConfigSectionName}")
|
||||
.Bind(this._redisConfig);
|
||||
configurationManager
|
||||
.GetRequiredSection($"VectorStores:{WeaviateConfig.ConfigSectionName}")
|
||||
.Bind(this._weaviateConfig);
|
||||
}
|
||||
|
||||
public AzureOpenAIConfig AzureOpenAIConfig => this._azureOpenAIConfig;
|
||||
|
||||
public AzureOpenAIEmbeddingsConfig AzureOpenAIEmbeddingsConfig => this._azureOpenAIEmbeddingsConfig;
|
||||
|
||||
public OpenAIConfig OpenAIConfig => this._openAIConfig;
|
||||
|
||||
public OpenAIEmbeddingsConfig OpenAIEmbeddingsConfig => this._openAIEmbeddingsConfig;
|
||||
|
||||
public RagConfig RagConfig => this._ragConfig;
|
||||
|
||||
public AzureAISearchConfig AzureAISearchConfig => this._azureAISearchConfig;
|
||||
|
||||
public CosmosConfig CosmosMongoConfig => this._cosmosMongoConfig;
|
||||
|
||||
public CosmosConfig CosmosNoSqlConfig => this._cosmosNoSqlConfig;
|
||||
|
||||
public QdrantConfig QdrantConfig => this._qdrantConfig;
|
||||
|
||||
public RedisConfig RedisConfig => this._redisConfig;
|
||||
|
||||
public WeaviateConfig WeaviateConfig => this._weaviateConfig;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace VectorStoreRAG.Options;
|
||||
|
||||
/// <summary>
|
||||
/// Azure AI Search service settings.
|
||||
/// </summary>
|
||||
internal sealed class AzureAISearchConfig
|
||||
{
|
||||
public const string ConfigSectionName = "AzureAISearch";
|
||||
|
||||
[Required]
|
||||
public string Endpoint { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string ApiKey { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace VectorStoreRAG.Options;
|
||||
|
||||
/// <summary>
|
||||
/// Azure OpenAI service settings.
|
||||
/// </summary>
|
||||
internal sealed class AzureOpenAIConfig
|
||||
{
|
||||
public const string ConfigSectionName = "AzureOpenAI";
|
||||
|
||||
[Required]
|
||||
public string ChatDeploymentName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Endpoint { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace VectorStoreRAG.Options;
|
||||
|
||||
/// <summary>
|
||||
/// Azure OpenAI Embeddings service settings.
|
||||
/// </summary>
|
||||
internal sealed class AzureOpenAIEmbeddingsConfig
|
||||
{
|
||||
public const string ConfigSectionName = "AzureOpenAIEmbeddings";
|
||||
|
||||
[Required]
|
||||
public string DeploymentName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Endpoint { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace VectorStoreRAG.Options;
|
||||
|
||||
/// <summary>
|
||||
/// Azure CosmosDB service settings for use with CosmosMongo and CosmosNoSql.
|
||||
/// </summary>
|
||||
internal sealed class CosmosConfig
|
||||
{
|
||||
public const string MongoConfigSectionName = "CosmosMongoDB";
|
||||
public const string NoSqlConfigSectionName = "CosmosNoSql";
|
||||
|
||||
[Required]
|
||||
public string ConnectionString { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string DatabaseName { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace VectorStoreRAG.Options;
|
||||
|
||||
/// <summary>
|
||||
/// OpenAI service settings.
|
||||
/// </summary>
|
||||
internal sealed class OpenAIConfig
|
||||
{
|
||||
public const string ConfigSectionName = "OpenAI";
|
||||
|
||||
[Required]
|
||||
public string ModelId { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string ApiKey { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string? OrgId { get; set; } = null;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace VectorStoreRAG.Options;
|
||||
|
||||
/// <summary>
|
||||
/// OpenAI Embeddings service settings.
|
||||
/// </summary>
|
||||
internal sealed class OpenAIEmbeddingsConfig
|
||||
{
|
||||
public const string ConfigSectionName = "OpenAIEmbeddings";
|
||||
|
||||
[Required]
|
||||
public string ModelId { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string ApiKey { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string? OrgId { get; set; } = null;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace VectorStoreRAG.Options;
|
||||
|
||||
/// <summary>
|
||||
/// Qdrant service settings.
|
||||
/// </summary>
|
||||
internal sealed class QdrantConfig
|
||||
{
|
||||
public const string ConfigSectionName = "Qdrant";
|
||||
|
||||
[Required]
|
||||
public string Host { get; set; } = string.Empty;
|
||||
|
||||
public int Port { get; set; } = 6334;
|
||||
|
||||
public bool Https { get; set; } = false;
|
||||
|
||||
public string ApiKey { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace VectorStoreRAG.Options;
|
||||
|
||||
/// <summary>
|
||||
/// Contains settings to control the RAG experience.
|
||||
/// </summary>
|
||||
internal sealed class RagConfig
|
||||
{
|
||||
public const string ConfigSectionName = "Rag";
|
||||
|
||||
[Required]
|
||||
public string AIChatService { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string AIEmbeddingService { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public bool BuildCollection { get; set; } = true;
|
||||
|
||||
[Required]
|
||||
public string CollectionName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public int DataLoadingBatchSize { get; set; } = 2;
|
||||
|
||||
[Required]
|
||||
public int DataLoadingBetweenBatchDelayInMilliseconds { get; set; } = 0;
|
||||
|
||||
[Required]
|
||||
public string[]? PdfFilePaths { get; set; }
|
||||
|
||||
[Required]
|
||||
public string VectorStoreType { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace VectorStoreRAG.Options;
|
||||
|
||||
/// <summary>
|
||||
/// Redis service settings.
|
||||
/// </summary>
|
||||
internal sealed class RedisConfig
|
||||
{
|
||||
public const string ConfigSectionName = "Redis";
|
||||
|
||||
[Required]
|
||||
public string ConnectionConfiguration { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace VectorStoreRAG.Options;
|
||||
|
||||
/// <summary>
|
||||
/// Weaviate service settings.
|
||||
/// </summary>
|
||||
internal sealed class WeaviateConfig
|
||||
{
|
||||
public const string ConfigSectionName = "Weaviate";
|
||||
|
||||
[Required]
|
||||
public string Endpoint { get; set; } = string.Empty;
|
||||
}
|
||||
Reference in New Issue
Block a user