Skip to content
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
5 changes: 5 additions & 0 deletions src/Abstractions/src/MessageHistory/FileChatMessageHistory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.AI;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;

namespace LangChain.Memory;
Expand Down Expand Up @@ -61,13 +62,17 @@ public override Task Clear()
return Task.CompletedTask;
}

[RequiresUnreferencedCode("Calls System.Text.Json.JsonSerializer.Serialize<TValue>(TValue, JsonSerializerOptions)")]
[RequiresDynamicCode("Calls System.Text.Json.JsonSerializer.Serialize<TValue>(TValue, JsonSerializerOptions)")]
private void SaveMessages()
{
var json = JsonSerializer.Serialize(_messages, JsonOptions);

File.WriteAllText(MessagesFilePath, json);
}

[RequiresUnreferencedCode("Calls System.Text.Json.JsonSerializer.Deserialize<TValue>(String, JsonSerializerOptions)")]
[RequiresDynamicCode("Calls System.Text.Json.JsonSerializer.Deserialize<TValue>(String, JsonSerializerOptions)")]
private async Task LoadMessages()
{
if (File.Exists(MessagesFilePath))
Expand Down
1 change: 1 addition & 0 deletions src/IntegrationTests/DatabaseTests.Configure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace LangChain.Databases.IntegrationTests;

public partial class DatabaseTests
{
[Obsolete]
internal static async Task<DatabaseTestEnvironment> StartEnvironmentForAsync(SupportedDatabase database, CancellationToken cancellationToken = default)
{
switch (database)
Expand Down
1 change: 1 addition & 0 deletions src/IntegrationTests/HistoryTests.Configure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace LangChain.Databases.IntegrationTests;

public partial class HistoryTests
{
[Obsolete]
private static async Task<HistoryTestEnvironment> StartEnvironmentForAsync(SupportedDatabase database, CancellationToken cancellationToken = default)
{
switch (database)
Expand Down
3 changes: 3 additions & 0 deletions src/Mongo/src/MongoChatMessageHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using LangChain.Databases.Mongo.Model;
using System.Text.Json;
using Microsoft.Extensions.AI;
using System.Diagnostics.CodeAnalysis;

namespace LangChain.Databases.Mongo;

Expand All @@ -19,6 +20,8 @@ await MongoRepository
.BatchDeactivate<LangChainAiSessionHistory>(i => i.SessionId == sessionId).ConfigureAwait(false);
}

[RequiresUnreferencedCode("Uses System.Text.Json serialization.")]
[RequiresDynamicCode("Uses System.Text.Json serialization.")]
public override async Task AddMessage(ChatMessage message)
{
await MongoRepository.InsertAsync(new LangChainAiSessionHistory
Expand Down
3 changes: 2 additions & 1 deletion src/OpenSearch/src/OpenSearchVectorStore.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using Microsoft.Extensions.VectorData;
using OpenSearch.Client;
Expand All @@ -8,7 +9,7 @@
/// <summary>
/// MEVA-compatible vector store backed by OpenSearch with k-NN plugin.
/// </summary>
public class OpenSearchVectorStore : VectorStore

Check warning on line 12 in src/OpenSearch/src/OpenSearchVectorStore.cs

View workflow job for this annotation

GitHub Actions / Build and test / Build, test and publish

'OpenSearchVectorStore': base type 'VectorStore' is not CLS-compliant
{
private readonly IOpenSearchClient _client;
private readonly string? _vectorStoreName;
Expand Down Expand Up @@ -43,9 +44,9 @@
public IOpenSearchClient Client => _client;

/// <inheritdoc />
public override VectorStoreCollection<TKey, TRecord> GetCollection<TKey, TRecord>(
public override VectorStoreCollection<TKey, TRecord> GetCollection<TKey, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] TRecord>(

Check warning on line 47 in src/OpenSearch/src/OpenSearchVectorStore.cs

View workflow job for this annotation

GitHub Actions / Build and test / Build, test and publish

Return type of 'OpenSearchVectorStore.GetCollection<TKey, TRecord>(string, VectorStoreCollectionDefinition?)' is not CLS-compliant
string name,
VectorStoreCollectionDefinition? definition = null)

Check warning on line 49 in src/OpenSearch/src/OpenSearchVectorStore.cs

View workflow job for this annotation

GitHub Actions / Build and test / Build, test and publish

Argument type 'VectorStoreCollectionDefinition' is not CLS-compliant
{
if (typeof(TKey) != typeof(string))
{
Expand All @@ -60,7 +61,7 @@
}

/// <inheritdoc />
public override VectorStoreCollection<object, Dictionary<string, object?>> GetDynamicCollection(

Check warning on line 64 in src/OpenSearch/src/OpenSearchVectorStore.cs

View workflow job for this annotation

GitHub Actions / Build and test / Build, test and publish

Return type of 'OpenSearchVectorStore.GetDynamicCollection(string, VectorStoreCollectionDefinition)' is not CLS-compliant
string name,
VectorStoreCollectionDefinition definition)
{
Expand Down
3 changes: 2 additions & 1 deletion src/OpenSearch/src/OpenSearchVectorStoreCollection.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using Microsoft.Extensions.VectorData;
Expand All @@ -10,7 +11,7 @@
/// <summary>
/// MEVA-compatible vector store collection backed by an OpenSearch index with k-NN.
/// </summary>
public class OpenSearchVectorStoreCollection<TRecord> :
public class OpenSearchVectorStoreCollection<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] TRecord> :

Check warning on line 14 in src/OpenSearch/src/OpenSearchVectorStoreCollection.cs

View workflow job for this annotation

GitHub Actions / Build and test / Build, test and publish

'OpenSearchVectorStoreCollection<TRecord>': base type 'VectorStoreCollection<string, TRecord>' is not CLS-compliant
VectorStoreCollection<string, TRecord>
where TRecord : class
{
Expand All @@ -26,7 +27,7 @@
public OpenSearchVectorStoreCollection(
IOpenSearchClient client,
string name,
VectorStoreCollectionDefinition? definition = null,

Check warning on line 30 in src/OpenSearch/src/OpenSearchVectorStoreCollection.cs

View workflow job for this annotation

GitHub Actions / Build and test / Build, test and publish

Argument type 'VectorStoreCollectionDefinition' is not CLS-compliant
string? vectorStoreName = null)
{
_client = client ?? throw new ArgumentNullException(nameof(client));
Expand Down Expand Up @@ -140,7 +141,7 @@
/// <inheritdoc />
public override async Task<TRecord?> GetAsync(
string key,
RecordRetrievalOptions? options = null,

Check warning on line 144 in src/OpenSearch/src/OpenSearchVectorStoreCollection.cs

View workflow job for this annotation

GitHub Actions / Build and test / Build, test and publish

Argument type 'RecordRetrievalOptions' is not CLS-compliant
CancellationToken cancellationToken = default)
{
using var activity = StartActivity("get");
Expand Down Expand Up @@ -290,17 +291,17 @@
public override IAsyncEnumerable<TRecord> GetAsync(
Expression<Func<TRecord, bool>> filter,
int top,
FilteredRecordRetrievalOptions<TRecord>? options = null,

Check warning on line 294 in src/OpenSearch/src/OpenSearchVectorStoreCollection.cs

View workflow job for this annotation

GitHub Actions / Build and test / Build, test and publish

Argument type 'FilteredRecordRetrievalOptions<TRecord>' is not CLS-compliant
CancellationToken cancellationToken = default)
{
throw new NotSupportedException("Expression-based filtering is not supported by OpenSearchVectorStoreCollection.");
}

/// <inheritdoc />
public override async IAsyncEnumerable<VectorSearchResult<TRecord>> SearchAsync<TInput>(

Check warning on line 301 in src/OpenSearch/src/OpenSearchVectorStoreCollection.cs

View workflow job for this annotation

GitHub Actions / Build and test / Build, test and publish

Return type of 'OpenSearchVectorStoreCollection<TRecord>.SearchAsync<TInput>(TInput, int, VectorSearchOptions<TRecord>?, CancellationToken)' is not CLS-compliant
TInput searchValue,
int top,
VectorSearchOptions<TRecord>? options = null,

Check warning on line 304 in src/OpenSearch/src/OpenSearchVectorStoreCollection.cs

View workflow job for this annotation

GitHub Actions / Build and test / Build, test and publish

Argument type 'VectorSearchOptions<TRecord>' is not CLS-compliant
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
using var activity = StartActivity("search");
Expand Down