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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
List<User> GetUsersByAffiliateId(string affiliateId) => throw new NotImplementedException();
User? GetUserByUserName(string userName) => throw new NotImplementedException();
void UpdateUserName(string userId, string userName) => throw new NotImplementedException();
Dashboard? GetDashboard(string id = null) => throw new NotImplementedException();

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Cannot convert null literal to non-nullable reference type.
void CreateUser(User user) => throw new NotImplementedException();
void UpdateExistUser(string userId, User user) => throw new NotImplementedException();
void UpdateUserVerified(string userId) => throw new NotImplementedException();
Expand Down Expand Up @@ -233,6 +233,8 @@
=> throw new NotImplementedException();
IEnumerable<VectorCollectionConfig> GetKnowledgeCollectionConfigs(VectorCollectionConfigFilter filter)
=> throw new NotImplementedException();
VectorCollectionConfig GetKnowledgeCollectionConfig(string collectionName, string vectorStroageProvider)
=> throw new NotImplementedException();
bool SaveKnolwedgeBaseFileMeta(KnowledgeDocMetaData metaData)
=> throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ public IEnumerable<VectorCollectionConfig> GetKnowledgeCollectionConfigs(VectorC

return configs;
}

[SharpCache(10)]
public VectorCollectionConfig GetKnowledgeCollectionConfig(string collectionName, string vectorStroageProvider)
{
var configs = GetKnowledgeCollectionConfigs(new VectorCollectionConfigFilter
{
CollectionNames = [collectionName],
VectorStroageProviders = [vectorStroageProvider]
});
return configs?.FirstOrDefault();
}
#endregion


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,12 @@ public static ITextEmbedding GetTextEmbeddingSetting(IServiceProvider services,
var db = services.GetRequiredService<IBotSharpRepository>();

// Get collection config from db
var configs = db.GetKnowledgeCollectionConfigs(new VectorCollectionConfigFilter
{
CollectionNames = [collectionName],
VectorStroageProviders = [settings.VectorDb.Provider]
});

var found = configs?.FirstOrDefault()?.TextEmbedding;
var provider = found?.Provider ?? string.Empty;
var model = found?.Model ?? string.Empty;
var dimension = found?.Dimension ?? 0;
var config = db.GetKnowledgeCollectionConfig(collectionName, settings.VectorDb.Provider);

if (found == null)
{
provider = settings.Default.TextEmbedding.Provider;
model = settings.Default.TextEmbedding.Model;
dimension = settings.Default.TextEmbedding.Dimension;
}
var textEmbeddingConfig = config?.TextEmbedding;
var provider = textEmbeddingConfig?.Provider ?? settings.Default.TextEmbedding.Provider;
var model = textEmbeddingConfig?.Model ?? settings.Default.TextEmbedding.Model;
var dimension = textEmbeddingConfig?.Dimension ?? settings.Default.TextEmbedding.Dimension;

// Set up text embedding
var embedding = services.GetServices<ITextEmbedding>().FirstOrDefault(x => x.Provider == provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<ItemGroup>
<PackageReference Include="MongoDB.Driver" />
<PackageReference Include="Rougamo.Fody" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,17 @@ public void CreateNewConversation(Conversation conversation)
UpdatedTime = utcNow
};

_dc.Conversations.InsertOne(convDoc);
_dc.ConversationDialogs.InsertOne(dialogDoc);
_dc.ConversationStates.InsertOne(stateDoc);
var convFilter = Builders<ConversationDocument>.Filter.Eq(x => x.Id, convDoc.Id);
var update = Builders<ConversationDocument>.Update
.Set(x => x.UpdatedTime, DateTime.UtcNow)
.SetOnInsert(x => x, convDoc);

var updateResult = _dc.Conversations.UpdateOne(convFilter, update, new UpdateOptions { IsUpsert = true});
if (updateResult.UpsertedId != null)
{
_dc.ConversationDialogs.InsertOne(dialogDoc);
_dc.ConversationStates.InsertOne(stateDoc);
}
}

public bool DeleteConversations(IEnumerable<string> conversationIds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ public IEnumerable<VectorCollectionConfig> GetKnowledgeCollectionConfigs(VectorC
TextEmbedding = KnowledgeEmbeddingConfigMongoModel.ToDomainModel(x.TextEmbedding)
});
}

[SharpCache(10)]
public VectorCollectionConfig GetKnowledgeCollectionConfig(string collectionName, string vectorStroageProvider)
{
var configs = GetKnowledgeCollectionConfigs(new VectorCollectionConfigFilter
{
CollectionNames = [collectionName],
VectorStroageProviders = [vectorStroageProvider]
});
return configs?.FirstOrDefault();
}
#endregion

#region Documents
Expand Down
Loading