Added the research on individual participants to the BeyondFacts Lab (#1207)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-15 15:39:34 +01:00
1 parent 3ca4b3878b
commit 92d0ff68f4
69 files changed
+3869 -186

No files matched your search

@@ -193,7 +193,7 @@ public sealed class BflConversationService(BeyondFactsLabStore store, EmbeddedCh
var valueDeck = await LoadValueDeckAsync(stepLocation);
var shares = await this.ShareMaterialsAsync(stepLocation, parts, forms, workStates, tools, research, rules, valueDeck, language, provider);
var materials = await this.ReadMaterialsAsync(stepLocation.ProjectId, shares);
return new(BflPromptComposer.Compose(parts, stepLocation.Step, forms, materials, language, workStates, tools, research, rules, valueDeck), this.ImagesOf(stepLocation.ProjectId, shares), rules);
return new(BflPromptComposer.Compose(parts, stepLocation.Step, forms, materials, language, workStates, tools, research.Topics, rules, valueDeck, research.People), this.ImagesOf(stepLocation.ProjectId, shares), rules);
case BflOnboardingThreadLocation:
// It never gets the guidelines themselves, but it tells the person that they exist:
@@ -318,10 +318,10 @@ public sealed class BflConversationService(BeyondFactsLabStore store, EmbeddedCh
/// Loads the research a step carries in its prompt: the step "Strategy" all of it, every other step none.
/// </summary>
/// <param name="location">The step.</param>
/// <returns>The research this version can open, by its topics.</returns>
private async Task<IReadOnlyDictionary<BflResearchTopic, BflResearch>> LoadResearchAsync(BflStepThreadLocation location) => location.Step is BflStep.STRATEGY
? await store.LoadAllResearchAsync(location.ProjectId)
: new Dictionary<BflResearchTopic, BflResearch>();
/// <returns>The research this version can open: on the topics, and on the people of the current list.</returns>
private async Task<BflStepResearch> LoadResearchAsync(BflStepThreadLocation location) => location.Step is BflStep.STRATEGY
? BflStepResearch.Of(await store.LoadAllResearchAsync(location.ProjectId), await store.LoadAllPersonResearchAsync(location.ProjectId))
: BflStepResearch.NONE;
/// <summary>
/// Loads the value deck a step carries in its prompt, with the card sort of the person: the step "Values and
@@ -344,13 +344,13 @@ public sealed class BflConversationService(BeyondFactsLabStore store, EmbeddedCh
/// <param name="forms">The forms of the preparation.</param>
/// <param name="workStates">The work states of the preparation, whose confirmed ones take room in the prompt as well.</param>
/// <param name="tools">What keeps the tools of the lab from being offered, which the prompt describes as well.</param>
/// <param name="research">The research the prompt of the step carries, by its topics.</param>
/// <param name="research">The research the prompt of the step carries, on the topics and on people.</param>
/// <param name="organizationRules">The guidelines of the organization, which take room in the prompt and in the first message.</param>
/// <param name="valueDeck">The value deck with which the prompt of the step shows the card sort, which takes room as well; null for the other steps.</param>
/// <param name="language">The name of the language the model answers in.</param>
/// <param name="provider">The provider which answers.</param>
/// <returns>The share of each material this version can open, in the order the person added them.</returns>
private async Task<IReadOnlyList<BflMaterialShare>> ShareMaterialsAsync(BflStepThreadLocation location, BflPromptParts parts, IReadOnlyDictionary<BflStep, BflStepFormData> forms, IReadOnlyDictionary<BflStep, BflWorkState> workStates, BflResearchAvailability tools, IReadOnlyDictionary<BflResearchTopic, BflResearch> research, string organizationRules, BflValueDeck? valueDeck, string language, AIStudio.Settings.Provider provider)
private async Task<IReadOnlyList<BflMaterialShare>> ShareMaterialsAsync(BflStepThreadLocation location, BflPromptParts parts, IReadOnlyDictionary<BflStep, BflStepFormData> forms, IReadOnlyDictionary<BflStep, BflWorkState> workStates, BflResearchAvailability tools, BflStepResearch research, string organizationRules, BflValueDeck? valueDeck, string language, AIStudio.Settings.Provider provider)
{
var materials = (await store.ListMaterialsAsync(location.ProjectId)).Select(entry => entry.Material).OfType<BflMaterial>().ToList();
if (materials.Count is 0)
@@ -359,7 +359,7 @@ public sealed class BflConversationService(BeyondFactsLabStore store, EmbeddedCh
var imageShares = BflMaterialBudget.ShareImages([.. materials.Where(material => material.Kind is BflMaterialKind.IMAGE)], ImagesTheModelTakes(provider));
var sentImages = imageShares.Count(share => share.Image is BflImageDelivery.SENT);
var promptWithoutMaterials = BflPromptComposer.Compose(parts, location.Step, forms, [], language, workStates, tools, research, organizationRules, valueDeck);
var promptWithoutMaterials = BflPromptComposer.Compose(parts, location.Step, forms, [], language, workStates, tools, research.Topics, organizationRules, valueDeck, research.People);
var characters = BflMaterialBudget.CharactersFor(provider.GetModelProfile().Context, promptWithoutMaterials.Length + BflOrganizationRules.Frame(organizationRules).Length, sentImages);
var textShares = BflMaterialBudget.Share([.. materials.Where(material => material.Kind is not BflMaterialKind.IMAGE)], characters);