Skip to content

Commit

Permalink
style: Run dotnet format
Browse files Browse the repository at this point in the history
github-actions[bot] committed Jun 3, 2024
1 parent f6f7457 commit 0dcab3b
Showing 5 changed files with 23 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/Databases/IntegrationTests/DatabaseTests.Configure.cs
Original file line number Diff line number Diff line change
@@ -105,21 +105,21 @@ private static async Task<DatabaseTestEnvironment> StartEnvironmentForAsync(Supp
}

case SupportedDatabase.Mongo:
{
{
var port = Random.Shared.Next(49152, 65535);
var container = new MongoDbBuilder()
.WithImage("mongo")
.WithPortBinding(hostPort: port, containerPort: 27017)
.WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(27017))
.Build();
.WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(27017))
.Build();

await container.StartAsync(cancellationToken);
await container.StartAsync(cancellationToken);

return new DatabaseTestEnvironment
{
VectorDatabase = new MongoVectorDatabase(container.GetConnectionString()),
Container = container,
};
};
}
default:
throw new ArgumentOutOfRangeException(nameof(database), database, null);
6 changes: 3 additions & 3 deletions src/Databases/Mongo/src/Client/MongoContext.cs
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ public IMongoCollection<T> GetCollection<T>(string name)
name = name ?? throw new ArgumentNullException(nameof(name));

return _mongoDatabase.GetCollection<T>(name);
}
}

public IMongoDatabase GetDatabase()
{
@@ -32,9 +32,9 @@ public IMongoDatabase GetDatabase()
public async Task<List<string>> GetCollections()
{
List<string> collectionNames = new List<string>();
var collections = await _mongoDatabase.ListCollectionsAsync();
var collections = await _mongoDatabase.ListCollectionsAsync().ConfigureAwait(false);

foreach (BsonDocument collection in await collections.ToListAsync<BsonDocument>())
foreach (BsonDocument collection in await collections.ToListAsync<BsonDocument>().ConfigureAwait(false))
{
string name = collection["name"].AsString;
collectionNames.Add(name);
10 changes: 5 additions & 5 deletions src/Databases/Mongo/src/Client/MongoDbClient.cs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ namespace LangChain.Databases.Mongo.Client;

public class MongoDbClient(IMongoContext mongoContext) : IMongoDbClient
{

public async Task BatchDeactivate<T>(Expression<Func<T, bool>> filter) where T : BaseEntity
{
var entityIds = (await Get(filter, p => p.Id).ConfigureAwait(false)).ToList();
@@ -65,7 +65,7 @@ public async Task<bool> CollectionExistsAsync(string collectionName)

var collections = await mongoContext.GetDatabase().ListCollectionNamesAsync(options).ConfigureAwait(false);

return await collections.AnyAsync();
return await collections.AnyAsync().ConfigureAwait(false);
}

public bool CollectionExists(string collectionName)
@@ -77,14 +77,14 @@ public bool CollectionExists(string collectionName)

public async Task<List<string>> GetCollections()
{
return await mongoContext.GetCollections();
return await mongoContext.GetCollections().ConfigureAwait(false);
}

public async Task<IMongoCollection<T>> CreateCollection<T>(string collectionName)
{
await mongoContext.GetDatabase().CreateCollectionAsync(collectionName, new CreateCollectionOptions
{
AutoIndexId = true
AutoIndexId = true

Check warning on line 87 in src/Databases/Mongo/src/Client/MongoDbClient.cs

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

'CreateCollectionOptions.AutoIndexId' is obsolete: 'AutoIndexId has been deprecated since server version 3.2.'

Check warning on line 87 in src/Databases/Mongo/src/Client/MongoDbClient.cs

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

'CreateCollectionOptions.AutoIndexId' is obsolete: 'AutoIndexId has been deprecated since server version 3.2.'
}).ConfigureAwait(false);

var collection = mongoContext.GetCollection<T>(collectionName);
@@ -93,6 +93,6 @@ public async Task<IMongoCollection<T>> CreateCollection<T>(string collectionName

public async Task DropCollectionAsync(string collectionName)
{
await mongoContext.GetDatabase().DropCollectionAsync(collectionName);
await mongoContext.GetDatabase().DropCollectionAsync(collectionName).ConfigureAwait(false);
}
}
10 changes: 5 additions & 5 deletions src/Databases/Mongo/src/MongoVectorDatabase.cs
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ public class MongoVectorDatabase(
string schema = MongoVectorDatabase.DefaultSchema)
: IVectorDatabase
{
private const string DefaultSchema = "langchain";
private const string DefaultSchema = "langchain";

private readonly IMongoDbClient _client = new MongoDbClient(

Check warning on line 19 in src/Databases/Mongo/src/MongoVectorDatabase.cs

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

Change type of field '_client' from 'LangChain.Databases.Mongo.Client.IMongoDbClient' to 'LangChain.Databases.Mongo.Client.MongoDbClient' for improved performance (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1859)

Check warning on line 19 in src/Databases/Mongo/src/MongoVectorDatabase.cs

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

Change type of field '_client' from 'LangChain.Databases.Mongo.Client.IMongoDbClient' to 'LangChain.Databases.Mongo.Client.MongoDbClient' for improved performance (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1859)
new MongoContext(
@@ -38,7 +38,7 @@ public async Task<IVectorCollection> GetCollectionAsync(string collectionName, C
DatabaseName = schema,
});

return new MongoVectorCollection(context, "idx_"+collectionName, name: collectionName);
return new MongoVectorCollection(context, "idx_" + collectionName, name: collectionName);
}

/// <inheritdoc />
@@ -71,9 +71,9 @@ public async Task CreateCollectionAsync(string collectionName, int dimensions, C
var indexName = await collection.Indexes.CreateOneAsync(new CreateIndexModel<Vector>(
Builders<Vector>.IndexKeys.Ascending(v => v.Embedding)
.Ascending(v => v.Text), new CreateIndexOptions
{
Background = true,
}), cancellationToken: cancellationToken).ConfigureAwait(false);
{
Background = true,
}), cancellationToken: cancellationToken).ConfigureAwait(false);
return;
}

5 changes: 5 additions & 0 deletions src/Providers/Google/src/GoogleChatModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using GenerativeAI.Models;
using GenerativeAI.Types;
using LangChain.Providers.Google.Extensions;
@@ -51,6 +52,8 @@ private static Content ToRequestMessage(Message message)
};
}

[RequiresUnreferencedCode("Calls LangChain.Providers.Google.Extensions.GoogleGeminiExtensions.GetString()")]
[RequiresDynamicCode("Calls LangChain.Providers.Google.Extensions.GoogleGeminiExtensions.GetString()")]
private static Message ToMessage(EnhancedGenerateContentResponse message)
{
if (message.GetFunction() != null)
@@ -113,6 +116,8 @@ private async Task<Message> StreamCompletionAsync(IReadOnlyCollection<Message> m
}

/// <inheritdoc />
[RequiresUnreferencedCode()]

Check failure on line 119 in src/Providers/Google/src/GoogleChatModel.cs

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

There is no argument given that corresponds to the required parameter 'message' of 'RequiresUnreferencedCodeAttribute.RequiresUnreferencedCodeAttribute(string)'

Check failure on line 119 in src/Providers/Google/src/GoogleChatModel.cs

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

There is no argument given that corresponds to the required parameter 'message' of 'RequiresUnreferencedCodeAttribute.RequiresUnreferencedCodeAttribute(string)'

Check failure on line 119 in src/Providers/Google/src/GoogleChatModel.cs

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

There is no argument given that corresponds to the required parameter 'message' of 'RequiresUnreferencedCodeAttribute.RequiresUnreferencedCodeAttribute(string)'

Check failure on line 119 in src/Providers/Google/src/GoogleChatModel.cs

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

There is no argument given that corresponds to the required parameter 'message' of 'RequiresUnreferencedCodeAttribute.RequiresUnreferencedCodeAttribute(string)'

Check failure on line 119 in src/Providers/Google/src/GoogleChatModel.cs

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

There is no argument given that corresponds to the required parameter 'message' of 'RequiresUnreferencedCodeAttribute.RequiresUnreferencedCodeAttribute(string)'
[RequiresDynamicCode()]

Check failure on line 120 in src/Providers/Google/src/GoogleChatModel.cs

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

There is no argument given that corresponds to the required parameter 'message' of 'RequiresDynamicCodeAttribute.RequiresDynamicCodeAttribute(string)'

Check failure on line 120 in src/Providers/Google/src/GoogleChatModel.cs

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

There is no argument given that corresponds to the required parameter 'message' of 'RequiresDynamicCodeAttribute.RequiresDynamicCodeAttribute(string)'

Check failure on line 120 in src/Providers/Google/src/GoogleChatModel.cs

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

There is no argument given that corresponds to the required parameter 'message' of 'RequiresDynamicCodeAttribute.RequiresDynamicCodeAttribute(string)'

Check failure on line 120 in src/Providers/Google/src/GoogleChatModel.cs

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

There is no argument given that corresponds to the required parameter 'message' of 'RequiresDynamicCodeAttribute.RequiresDynamicCodeAttribute(string)'

Check failure on line 120 in src/Providers/Google/src/GoogleChatModel.cs

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

There is no argument given that corresponds to the required parameter 'message' of 'RequiresDynamicCodeAttribute.RequiresDynamicCodeAttribute(string)'
public override async Task<ChatResponse> GenerateAsync(
ChatRequest request,
ChatSettings? settings = null,

0 comments on commit 0dcab3b

Please sign in to comment.