ExecuteAiConversationWithRoutineComplete
This commit is contained in:
@@ -192,7 +192,43 @@ namespace BeWo.ServiceProxy
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.ValueListEntryType))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.AiRoutineType))]
|
||||
System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiConversationMessageDC> ExecuteAiConversationWithRoutine(long conversation, BS.Shared.DataContracts.Feature.AI.AiViewContextDC view_context, long routine, int step);
|
||||
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/ExecuteAiConversationWithRoutineComplete", ReplyAction="http://tempuri.org/IAiEnhancedService/ExecuteAiConversationWithRoutineCompleteResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/ExecuteAiConversationWithRoutineCompleteBeW" +
|
||||
"oFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.BeWoDataContract))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.Feature.AI.AiConfigDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.Feature.AI.AiModelDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiModelDC>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiConversationDC>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.Feature.AI.AiConversationDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiConversationMessageDC>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.Feature.AI.AiConversationMessageDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiPromptbausteinFolderDC>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.Feature.AI.AiPromptbausteinFolderDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiPromptbausteinPromptDC>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.Feature.AI.AiPromptbausteinPromptDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiPromptbausteinRoutineDC>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.Feature.AI.AiPromptbausteinRoutineDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiPromptbausteinRoutineStepDC>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.Feature.AI.AiPromptbausteinRoutineStepDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.Feature.AI.AiUserSettingDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.Compact.CompactEmployeeDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<BS.Shared.TableID, System.Collections.Generic.List<long>>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<long>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<long, BS.Shared.ValueListEntryType>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.Core.BeWoFault))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.Core.BeWoFaultType))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.AiDataContextType))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.AiModelSource))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.AiActionType))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.TableID))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.AiConversationMessageRole))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.ActivationTypeId))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.ValueListEntryType))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.AiRoutineType))]
|
||||
System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiConversationMessageDC> ExecuteAiConversationWithRoutineComplete(BS.Shared.AiActionType actionType, BS.Shared.DataContracts.Feature.AI.AiViewContextDC view_context, long routine);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/CheckContextSize", ReplyAction="http://tempuri.org/IAiEnhancedService/CheckContextSizeResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/CheckContextSizeBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.BeWoDataContract))]
|
||||
@@ -373,7 +409,12 @@ namespace BeWo.ServiceProxy
|
||||
{
|
||||
return base.Channel.ExecuteAiConversationWithRoutine(conversation, view_context, routine, step);
|
||||
}
|
||||
|
||||
|
||||
public System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiConversationMessageDC> ExecuteAiConversationWithRoutineComplete(BS.Shared.AiActionType actionType, BS.Shared.DataContracts.Feature.AI.AiViewContextDC view_context, long routine)
|
||||
{
|
||||
return base.Channel.ExecuteAiConversationWithRoutineComplete(actionType, view_context, routine);
|
||||
}
|
||||
|
||||
public bool CheckContextSize(BS.Shared.AiActionType actionType, BS.Shared.DataContracts.Feature.AI.AiViewContextDC view_context)
|
||||
{
|
||||
return base.Channel.CheckContextSize(actionType, view_context);
|
||||
|
||||
@@ -259,6 +259,65 @@ namespace BeWo.Service.Plugins
|
||||
return executePrompt(conversation, view_context, prompt.Oid.Value, routine_ent.RoutineType);
|
||||
}
|
||||
|
||||
public virtual AiConversationMessageDC[] ExecuteAiConversationWithRoutineComplete(AiActionType actionType, AiViewContextDC view_context, long routine)
|
||||
{
|
||||
var ai_config = GetAiConfig();
|
||||
|
||||
var routine_ent = DAOFactory.GenericDAO.LoadByID<AiPromptbausteinRoutine>(routine);
|
||||
|
||||
// Gesamter Chatverlauf über alle Schritte hinweg (analog zu ExecuteChain im ViewModel).
|
||||
var history = new List<AiConversationMessage>();
|
||||
|
||||
for (int step = 0; step < routine_ent.Steps.Count; step++)
|
||||
{
|
||||
var step_ent = routine_ent.Steps[step];
|
||||
var prompt = step_ent.PromptReference;
|
||||
|
||||
var custom_viewContext = new AiViewContextDC
|
||||
{
|
||||
References = view_context.References,
|
||||
Primary = view_context.Primary
|
||||
};
|
||||
|
||||
if (step > 0 && routine_ent.RoutineType == AiRoutineType.Chain)
|
||||
{
|
||||
custom_viewContext.Secondary = history.Last().Message;
|
||||
}
|
||||
else
|
||||
{
|
||||
custom_viewContext.Secondary = view_context.Secondary;
|
||||
}
|
||||
|
||||
var new_conv = createAiConversation(actionType, custom_viewContext, ai_config);
|
||||
var systemPrompt = addSystemPrompt(new_conv, custom_viewContext, ai_config, prompt);
|
||||
|
||||
if (routine_ent.RoutineType == AiRoutineType.Chain)
|
||||
{
|
||||
// Conversation = (S(n), U(n)) => A(n)
|
||||
}
|
||||
else if (routine_ent.RoutineType == AiRoutineType.Stack)
|
||||
{
|
||||
// Conversation = (S(n), U(0), A(0), U(1), ..., U(n-1), A(n-1), U(n)) => A(n)
|
||||
var messages_filtered = history.Where(m => m.Role != AiConversationMessageRole.System);
|
||||
|
||||
new_conv.Messages.AddRange(messages_filtered);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(routine_ent.RoutineType));
|
||||
}
|
||||
|
||||
// Server Request - wirft bei Fehlschlag eine Exception und bricht damit den gesamten Aufruf ab.
|
||||
sendNewMessage(new_conv, prompt.Prompt, false);
|
||||
|
||||
history.Add(systemPrompt);
|
||||
history.Add(new_conv.Messages.Last(x => x.Role == AiConversationMessageRole.User));
|
||||
history.Add(new_conv.Messages.Last(x => x.Role == AiConversationMessageRole.Assistent));
|
||||
}
|
||||
|
||||
return MapperFactory.AiConversationMessage.MapToNewDCs(history).ToArray();
|
||||
}
|
||||
|
||||
public virtual bool CheckContextSize(AiActionType actionType, AiViewContextDC view_context)
|
||||
{
|
||||
var modell_oid_value = GetAiConfig().SelectedModel.Oid.Value;
|
||||
|
||||
@@ -72,6 +72,10 @@ namespace BeWo.Service.ServiceContracts.Enhanced
|
||||
[OperationContract]
|
||||
AiConversationMessageDC[] ExecuteAiConversationWithRoutine(long conversation, AiViewContextDC view_context, long routine, int step);
|
||||
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
AiConversationMessageDC[] ExecuteAiConversationWithRoutineComplete(AiActionType actionType, AiViewContextDC view_context, long routine);
|
||||
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
//[RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)]
|
||||
|
||||
@@ -52,9 +52,12 @@ namespace BeWo.Service.ServiceImplementations.Enhanced
|
||||
public AiConversationMessageDC[] ExecuteAiConversationWithPrompt(long conversation, AiViewContextDC view_context, long prompt_oid)
|
||||
=> GetAiService().ExecuteAiConversationWithPrompt(conversation, view_context, prompt_oid);
|
||||
|
||||
public AiConversationMessageDC[] ExecuteAiConversationWithRoutine(long conversation, AiViewContextDC view_context, long routine, int step)
|
||||
public AiConversationMessageDC[] ExecuteAiConversationWithRoutine(long conversation, AiViewContextDC view_context, long routine, int step)
|
||||
=> GetAiService().ExecuteAiConversationWithRoutine(conversation, view_context, routine, step);
|
||||
|
||||
public AiConversationMessageDC[] ExecuteAiConversationWithRoutineComplete(AiActionType actionType, AiViewContextDC view_context, long routine)
|
||||
=> GetAiService().ExecuteAiConversationWithRoutineComplete(actionType, view_context, routine);
|
||||
|
||||
public bool CheckContextSize(AiActionType actionType, AiViewContextDC view_context)
|
||||
=> GetAiService().CheckContextSize(actionType, view_context);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user