From 3fdf7fe045f6612f6301ea3d6bf272d292e33c88 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Fri, 16 Aug 2024 03:28:43 +0300 Subject: [PATCH] Improving single request and chat context prompts. --- llm/llm.go | 8 ++++---- llm/request_context.go | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/llm/llm.go b/llm/llm.go index 9372bf0..7732264 100644 --- a/llm/llm.go +++ b/llm/llm.go @@ -28,12 +28,12 @@ func NewConnector(baseUrl string, token string) *LlmConnector { } func (l *LlmConnector) HandleSingleRequest(text string, model string, requestContext RequestContext) (string, error) { - systemPrompt := "You're a bot in the Telegram chat. " + - "You're using a free model called \"" + model + "\". " + - "You see only messages addressed to you using commands due to privacy settings." + systemPrompt := "You're a bot in the Telegram chat.\n" + + "You're using a free model called \"" + model + "\".\n" + + "Currently you're not able to access chat history, so each message will be replied from a clean slate." if !requestContext.Empty { - systemPrompt += " " + requestContext.Prompt() + systemPrompt += "\n" + requestContext.Prompt() } req := openai.ChatCompletionRequest{ diff --git a/llm/request_context.go b/llm/request_context.go index fff4456..34fa144 100644 --- a/llm/request_context.go +++ b/llm/request_context.go @@ -39,15 +39,16 @@ func (c RequestContext) Prompt() string { prompt += "You're responding to inline query, so you're not in the chat right now. " } - prompt += "According to their profile, first name of the user who wrote you is \"" + c.User.FirstName + "\". " + prompt += "User profile:" + + "First name: \"" + c.User.FirstName + "\"\n" if c.User.Username != "" { - prompt += "Their username is @" + c.User.Username + ". " + prompt += "Username: @" + c.User.Username + ".\n" } if c.User.LastName != "" { - prompt += "Their last name is \"" + c.User.LastName + "\". " + prompt += "Last name: \"" + c.User.LastName + "\"\n" } if c.User.IsPremium { - prompt += "They have Telegram Premium subscription. " + prompt += "Telegram Premium subscription: active." } return prompt