mirror of
https://github.com/microsoft/autogen.git
synced 2025-10-17 02:49:30 +00:00
simple dev understanding
This commit is contained in:
parent
31eaa4c3ce
commit
0cd4e32f23
@ -16,7 +16,7 @@ public class Dev : SemanticPersona, IDevelopCode
|
||||
|
||||
protected override string MemorySegment => "dev-memory";
|
||||
|
||||
public Dev([PersistentState("state", "messages")] IPersistentState<SemanticPersonaState> state,IKernel kernel,ISemanticTextMemory memory, ILogger<Dev> logger) : base(state)
|
||||
public Dev([PersistentState("state", "messages")] IPersistentState<SemanticPersonaState> state, IKernel kernel, ISemanticTextMemory memory, ILogger<Dev> logger) : base(state)
|
||||
{
|
||||
_kernel = kernel;
|
||||
_memory = memory;
|
||||
@ -51,7 +51,7 @@ public class Dev : SemanticPersona, IDevelopCode
|
||||
|
||||
return resultMessage;
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error generating code");
|
||||
return default;
|
||||
@ -65,8 +65,28 @@ public class Dev : SemanticPersona, IDevelopCode
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<string> BuildUnderstanding(string content)
|
||||
public async Task<UnderstandingResult> BuildUnderstanding(string content)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var explainFunction = _kernel.CreateSemanticFunction(Developer.Explain, new OpenAIRequestSettings { MaxTokens = 15000, Temperature = 0.8, TopP = 1 });
|
||||
var consolidateFunction = _kernel.CreateSemanticFunction(Developer.ConsolidateUnderstanding, new OpenAIRequestSettings { MaxTokens = 15000, Temperature = 0.8, TopP = 1 });
|
||||
var explainContext = new ContextVariables();
|
||||
explainContext.Set("input", content);
|
||||
var explainResult = await _kernel.RunAsync(explainContext, explainFunction);
|
||||
var explainMesage = explainResult.ToString();
|
||||
|
||||
var consolidateContext = new ContextVariables();
|
||||
consolidateContext.Set("input", _state.State.Understanding);
|
||||
consolidateContext.Set("newUnderstanding", explainMesage);
|
||||
|
||||
var consolidateResult = await _kernel.RunAsync(consolidateContext, consolidateFunction);
|
||||
var consolidateMessage = consolidateResult.ToString();
|
||||
|
||||
_state.State.Understanding = consolidateMessage;
|
||||
await _state.WriteStateAsync();
|
||||
|
||||
return new UnderstandingResult {
|
||||
NewUnderstanding = consolidateMessage,
|
||||
Explanation = explainMesage
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -34,6 +34,7 @@ public class Ingester : SemanticPersona, IIngestRepo
|
||||
codeAnalysis.ToList().ForEach(async c =>
|
||||
await _memory.SaveInformationAsync(MemorySegment, c.CodeBlock, Guid.NewGuid().ToString(), c.Meaning));
|
||||
|
||||
// TODO: do something with the result
|
||||
await dev.BuildUnderstanding(file.Content);
|
||||
}
|
||||
}
|
||||
|
@ -41,9 +41,16 @@ public interface IChatHistory
|
||||
|
||||
public interface IUnderstand
|
||||
{
|
||||
Task<string> BuildUnderstanding(string content);
|
||||
Task<UnderstandingResult> BuildUnderstanding(string content);
|
||||
}
|
||||
|
||||
[GenerateSerializer]
|
||||
public class UnderstandingResult {
|
||||
[Id(0)]
|
||||
public string NewUnderstanding { get; set; }
|
||||
[Id(1)]
|
||||
public string Explanation { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ChatHistoryItem
|
||||
|
Loading…
x
Reference in New Issue
Block a user