feat: 新增支持Prompt
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Dm.util;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using OpenAI.Chat;
|
using OpenAI.Chat;
|
||||||
@@ -43,6 +44,10 @@ public class OpenApiService : ApplicationService
|
|||||||
|
|
||||||
var userId = await _tokenManager.GetUserIdAsync(GetTokenByHttpContext(httpContext));
|
var userId = await _tokenManager.GetUserIdAsync(GetTokenByHttpContext(httpContext));
|
||||||
var history = new List<ChatMessage>();
|
var history = new List<ChatMessage>();
|
||||||
|
if (!string.IsNullOrWhiteSpace(input.Prompt))
|
||||||
|
{
|
||||||
|
history.add(ChatMessage.CreateSystemMessage(input.Prompt));
|
||||||
|
}
|
||||||
foreach (var aiChatContextDto in input.Messages)
|
foreach (var aiChatContextDto in input.Messages)
|
||||||
{
|
{
|
||||||
if (aiChatContextDto.Role == "assistant")
|
if (aiChatContextDto.Role == "assistant")
|
||||||
|
|||||||
Reference in New Issue
Block a user