mirror of
https://github.com/marcominerva/SqlDatabaseVectorSearch.git
synced 2026-06-20 12:23:10 +00:00
Enhance documentation and update DocumentChunk model
Updated `copilot-instructions.md` to include new guidelines for Markdown documentation and testing practices. Modified the `DocumentChunk` record in `DocumentChunk.cs` to add `PageNumber` and `IndexOnPage` properties. Adjusted `GetChunksAsync` and `GetChunkEmbeddingAsync` methods in `DocumentService.cs` to accommodate the new properties.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
- Always use the latest version C#, currently C# 13 features.
|
||||
- Write code that is clean, maintainable, and easy to understand.
|
||||
- Only add comments rarely to explain why a non-intuitive solution was used. The code should be self-explanatory otherwise.
|
||||
- Don't add the UTF-8 BOM to files unless they have non-ASCII characters
|
||||
- Don't add the UTF-8 BOM to files unless they have non-ASCII characters.
|
||||
- Never change global.json unless explicitly asked to.
|
||||
- Never change package.json or package-lock.json files unless explicitly asked to.
|
||||
- Never change NuGet.config files unless explicitly asked to.
|
||||
@@ -69,6 +69,10 @@
|
||||
- Include code examples in documentation where appropriate.
|
||||
- Overriding members should inherit the XML documentation from the base type via `/// <inheritdoc />`.
|
||||
|
||||
## Markdown
|
||||
- Use Markdown for documentation files (e.g., README.md).
|
||||
- Use triple backticks for code blocks, JSON snippets and bash commands, specifying the language (e.g., ```csharp, ```json and ```bash).
|
||||
|
||||
## Testing
|
||||
|
||||
- When adding new unit tests, strongly prefer to add them to existing test code files rather than creating new code files.
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace SqlDatabaseVectorSearch.Models;
|
||||
|
||||
public record class DocumentChunk(Guid Id, int Index, string Content, float[]? Embedding = null);
|
||||
public record class DocumentChunk(Guid Id, int Index, string Content, int? PageNumber, int IndexOnPage, float[]? Embedding = null);
|
||||
|
||||
@@ -19,7 +19,7 @@ public class DocumentService(ApplicationDbContext dbContext)
|
||||
public async Task<IEnumerable<DocumentChunk>> GetChunksAsync(Guid documentId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var documentChunks = await dbContext.DocumentChunks.Where(c => c.DocumentId == documentId).OrderBy(c => c.Index)
|
||||
.Select(c => new DocumentChunk(c.Id, c.Index, c.Content, null))
|
||||
.Select(c => new DocumentChunk(c.Id, c.Index, c.Content, c.PageNumber, c.IndexOnPage, null))
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return documentChunks;
|
||||
@@ -28,7 +28,7 @@ public class DocumentService(ApplicationDbContext dbContext)
|
||||
public async Task<DocumentChunk?> GetChunkEmbeddingAsync(Guid documentId, Guid documentChunkId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var documentChunk = await dbContext.DocumentChunks.Where(c => c.Id == documentChunkId && c.DocumentId == documentId)
|
||||
.Select(c => new DocumentChunk(c.Id, c.Index, c.Content, c.Embedding))
|
||||
.Select(c => new DocumentChunk(c.Id, c.Index, c.Content, c.PageNumber, c.IndexOnPage, c.Embedding))
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
return documentChunk;
|
||||
|
||||
Reference in New Issue
Block a user