Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style:Run dotnet format #325

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions src/Databases/IntegrationTests/DatabaseTests.Configure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/Databases/Mongo/src/Client/MongoContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class MongoContext : IMongoContext
{
protected readonly IMongoDatabase _mongoDatabase;

Check warning on line 10 in src/Databases/Mongo/src/Client/MongoContext.cs

View workflow job for this annotation

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

Identifier '_mongoDatabase' is not CLS-compliant

Check warning on line 10 in src/Databases/Mongo/src/Client/MongoContext.cs

View workflow job for this annotation

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

Do not declare visible instance fields (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1051)

Check warning on line 10 in src/Databases/Mongo/src/Client/MongoContext.cs

View workflow job for this annotation

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

Identifier '_mongoDatabase' is not CLS-compliant

Check warning on line 10 in src/Databases/Mongo/src/Client/MongoContext.cs

View workflow job for this annotation

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

Do not declare visible instance fields (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1051)

public MongoContext(IDatabaseConfiguration databaseConfiguration)
{
Expand All @@ -22,7 +22,7 @@
name = name ?? throw new ArgumentNullException(nameof(name));

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

public IMongoDatabase GetDatabase()
{
Expand All @@ -32,9 +32,9 @@
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);
Expand Down
10 changes: 5 additions & 5 deletions src/Databases/Mongo/src/Client/MongoDbClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

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();
Expand Down Expand Up @@ -65,7 +65,7 @@

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

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

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

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

View workflow job for this annotation

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

View workflow job for this annotation

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);
Expand All @@ -93,6 +93,6 @@

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
Expand Up @@ -14,9 +14,9 @@
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

View workflow job for this annotation

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

View workflow job for this annotation

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(
new DatabaseConfiguration
{
Expand All @@ -38,7 +38,7 @@
DatabaseName = schema,
});

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

/// <inheritdoc />
Expand Down Expand Up @@ -71,9 +71,9 @@
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;
}

Expand Down
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;
Expand Down Expand Up @@ -51,6 +52,8 @@
};
}

[RequiresUnreferencedCode("Calls LangChain.Providers.Google.Extensions.GoogleGeminiExtensions.GetString()")]
[RequiresDynamicCode("Calls LangChain.Providers.Google.Extensions.GoogleGeminiExtensions.GetString()")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RequiresUnreferencedCode and RequiresDynamicCode attributes should include a description of the requirements.

- [RequiresUnreferencedCode("Calls LangChain.Providers.Google.Extensions.GoogleGeminiExtensions.GetString()")]
- [RequiresDynamicCode("Calls LangChain.Providers.Google.Extensions.GoogleGeminiExtensions.GetString()")]
+ [RequiresUnreferencedCode("This method calls LangChain.Providers.Google.Extensions.GoogleGeminiExtensions.GetString(), which cannot be statically analyzed.")]
+ [RequiresDynamicCode("This method calls LangChain.Providers.Google.Extensions.GoogleGeminiExtensions.GetString(), which may require dynamic code generation.")]
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
[RequiresUnreferencedCode("Calls LangChain.Providers.Google.Extensions.GoogleGeminiExtensions.GetString()")]
[RequiresDynamicCode("Calls LangChain.Providers.Google.Extensions.GoogleGeminiExtensions.GetString()")]
[RequiresUnreferencedCode("This method calls LangChain.Providers.Google.Extensions.GoogleGeminiExtensions.GetString(), which cannot be statically analyzed.")]
[RequiresDynamicCode("This method calls LangChain.Providers.Google.Extensions.GoogleGeminiExtensions.GetString(), which may require dynamic code generation.")]

private static Message ToMessage(EnhancedGenerateContentResponse message)
{
if (message.GetFunction() != null)
Expand Down Expand Up @@ -113,6 +116,8 @@
}

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

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

View workflow job for this annotation

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

View workflow job for this annotation

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

View workflow job for this annotation

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

View workflow job for this annotation

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

View workflow job for this annotation

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

View workflow job for this annotation

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

View workflow job for this annotation

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

View workflow job for this annotation

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

View workflow job for this annotation

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

View workflow job for this annotation

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)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The attributes RequiresUnreferencedCode and RequiresDynamicCode are missing required parameters. Please provide a message describing why the code requires this.

- [RequiresUnreferencedCode()]
- [RequiresDynamicCode()]
+ [RequiresUnreferencedCode("Description of the unreferenced code requirements")]
+ [RequiresDynamicCode("Description of the dynamic code requirements")]
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
[RequiresUnreferencedCode()]
[RequiresDynamicCode()]
[RequiresUnreferencedCode("Description of the unreferenced code requirements")]
[RequiresDynamicCode("Description of the dynamic code requirements")]
Tools
GitHub Check: Build and test / Build, test and publish

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


[failure] 120-120:
There is no argument given that corresponds to the required parameter 'message' of 'RequiresDynamicCodeAttribute.RequiresDynamicCodeAttribute(string)'


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


[failure] 120-120:
There is no argument given that corresponds to the required parameter 'message' of 'RequiresDynamicCodeAttribute.RequiresDynamicCodeAttribute(string)'


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


[failure] 120-120:
There is no argument given that corresponds to the required parameter 'message' of 'RequiresDynamicCodeAttribute.RequiresDynamicCodeAttribute(string)'


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


[failure] 120-120:
There is no argument given that corresponds to the required parameter 'message' of 'RequiresDynamicCodeAttribute.RequiresDynamicCodeAttribute(string)'


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


[failure] 120-120:
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,
Expand Down
Loading