From 19da4c6b346a8d96b46f6b472e22c83868791cdb Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Tue, 12 Mar 2024 06:31:07 +0300 Subject: [PATCH] Request context prompt fixes and improvements. --- llm/request_context.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/llm/request_context.go b/llm/request_context.go index 4ba248b..b49d175 100644 --- a/llm/request_context.go +++ b/llm/request_context.go @@ -19,17 +19,22 @@ type ChatContext struct { } func (c RequestContext) Prompt() string { - prompt := "The chat you're in is called \"" + c.Chat.Title + "\". " + - "The type of chat is \"" + c.Chat.Type + "\". " + - "The chat description is \"" + c.Chat.Description + "\". " + prompt := "The type of chat you're in is \"" + c.Chat.Type + "\". " + + if c.Chat.Title != "" { + prompt += "Chat is called \"" + c.Chat.Title + "\". " + } + if c.Chat.Description != "" { + prompt += "Chat description is \"" + c.Chat.Description + "\". " + } + if c.User.Username != "" { - prompt += "The user who wrote you has username \"@" + c.Chat.Description + "\". " + prompt += "The user who wrote you has username \"@" + c.User.Username + "\". " } prompt += "Their first name is \"" + c.User.FirstName + "\". " if c.User.LastName != "" { prompt += "Their last name is \"" + c.User.LastName + "\". " } - if c.User.IsPremium { prompt += "They have Telegram Premium subscription. " } -- 2.43.5