Fix load agent error for InstructMode
This commit is contained in:
parent
78d66eb9c5
commit
ed96ff0fb9
|
|
@ -8,6 +8,11 @@ public partial class AgentService
|
|||
[MemoryCache(10 * 60, perInstanceCache: true)]
|
||||
public async Task<Agent> LoadAgent(string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id) || id == Guid.Empty.ToString())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var hooks = _services.GetServices<IAgentHook>();
|
||||
|
||||
// Before agent is loaded.
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ public class VerboseLogHook : IContentGeneratingHook
|
|||
var agent = await agentService.LoadAgent(message.CurrentAgentId);
|
||||
|
||||
var log = message.Role == AgentRole.Function ?
|
||||
$"[[msg_id: {message.MessageId}] [{agent.Name}]: {message.FunctionName}({message.FunctionArgs})" :
|
||||
$"[[msg_id: {message.MessageId}] [{agent.Name}]: {message.Content}";
|
||||
$"[[msg_id: {message.MessageId}] [{agent?.Name}]: {message.FunctionName}({message.FunctionArgs})" :
|
||||
$"[[msg_id: {message.MessageId}] [{agent?.Name}]: {message.Content}";
|
||||
|
||||
_logger.LogInformation(tokenStats.Prompt);
|
||||
_logger.LogInformation(log);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
using BotSharp.Abstraction.Agents.Enums;
|
||||
using BotSharp.Abstraction.ApiAdapters;
|
||||
using BotSharp.Abstraction.Conversations.Models;
|
||||
using BotSharp.Abstraction.Instructs;
|
||||
using BotSharp.Abstraction.Instructs.Models;
|
||||
using BotSharp.Core.Infrastructures;
|
||||
|
|
@ -48,6 +45,6 @@ public class InstructModeController : ControllerBase, IApiAdapter
|
|||
.SetState("model", input.Model);
|
||||
|
||||
var textCompletion = CompletionProvider.GetTextCompletion(_services);
|
||||
return await textCompletion.GetCompletion(input.Text, Guid.Empty.ToString(), Guid.Empty.ToString());
|
||||
return await textCompletion.GetCompletion(input.Text, Guid.Empty.ToString(), Guid.NewGuid().ToString());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue