Skip to content

Commit

Permalink
chore: 调整日志输出
Browse files Browse the repository at this point in the history
  • Loading branch information
sangyuxiaowu committed Jul 28, 2024
1 parent 69715ec commit a3dd8e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/Services/LLmModelService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,27 @@ public async Task<ChatCompletionResponse> CreateChatCompletionAsync(ChatCompleti
var messagesContent = request.messages.Select(x => x.content).ToArray();
var prompt_context = string.Join("", messagesContent);
var completion_tokens = 0;

_logger.LogDebug("Prompt context: {prompt_context}", chatHistory.ChatHistory);

await foreach (var output in ex.InferAsync(chatHistory.ChatHistory, genParams))
{
_logger.LogDebug("Message: {output}", output);
_logger.LogTrace("Message: {output}", output);
result.Append(output);
completion_tokens++;
}
var prompt_tokens = ex.PromptTokens;

_logger.LogDebug("Prompt tokens: {prompt_tokens}, Completion tokens: {completion_tokens}", prompt_tokens, completion_tokens);
_logger.LogDebug("Completion result: {result}", result);

// 工具返回检测
if (chatHistory.IsToolPromptEnabled)
{
var tools = _toolPromptGenerator.GenerateToolCall(result.ToString(), _usedset.ToolPrompt.Index);
if (tools.Count > 0)
{
_logger.LogDebug("Tool calls: {tools}", tools.Select(x=>x.name));
return new ChatCompletionResponse
{
id = $"chatcmpl-{Guid.NewGuid():N}",
Expand Down
3 changes: 2 additions & 1 deletion src/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Microsoft.AspNetCore": "Warning",
"LLamaWorker": "Debug"
}
},
"AllowedHosts": "*",
Expand Down

0 comments on commit a3dd8e3

Please sign in to comment.