Compare commits

..

No commits in common. "7d9d08fbff0c9922a904bb333f8b06d39e992ecb" and "e6351725e3c9da692cd9a0b11a4acc35e4cd801a" have entirely different histories.

4 changed files with 10 additions and 11 deletions

View file

@ -144,7 +144,7 @@ func (b *Bot) processMention(message *telego.Message) {
requestContext := b.createLlmRequestContextFromMessage(message) requestContext := b.createLlmRequestContextFromMessage(message)
userMessageData := tgUserMessageToMessageData(message, true) userMessageData := tgUserMessageToMessageData(message)
llmReply, err := b.llm.HandleChatMessage( llmReply, err := b.llm.HandleChatMessage(
messageDataToLlmMessage(userMessageData), messageDataToLlmMessage(userMessageData),

View file

@ -56,7 +56,7 @@ func (b *Bot) saveChatMessageToHistory(message *telego.Message) {
b.history[chatId] = NewMessageHistory(HistoryLength) b.history[chatId] = NewMessageHistory(HistoryLength)
} }
msgData := tgUserMessageToMessageData(message, false) msgData := tgUserMessageToMessageData(message)
b.history[chatId].Push(msgData) b.history[chatId].Push(msgData)
} }
@ -99,17 +99,16 @@ func (b *Bot) saveBotReplyToHistory(replyTo *telego.Message, text string) {
b.history[chatId].Push(msgData) b.history[chatId].Push(msgData)
} }
func tgUserMessageToMessageData(message *telego.Message, isUserRequest bool) MessageData { func tgUserMessageToMessageData(message *telego.Message) MessageData {
msgData := MessageData{ msgData := MessageData{
Name: message.From.FirstName, Name: message.From.FirstName,
Username: message.From.Username, Username: message.From.Username,
Text: message.Text, Text: message.Text,
IsMe: false, IsMe: false,
IsUserRequest: isUserRequest,
} }
if message.ReplyToMessage != nil { if message.ReplyToMessage != nil {
replyData := tgUserMessageToMessageData(message.ReplyToMessage, false) replyData := tgUserMessageToMessageData(message.ReplyToMessage)
msgData.ReplyTo = &replyData msgData.ReplyTo = &replyData
} }

View file

@ -36,7 +36,7 @@ func (l *LlmConnector) HandleChatMessage(userMessage ChatMessage, model string,
historyLength := len(requestContext.Chat.History) historyLength := len(requestContext.Chat.History)
if historyLength > 0 { if historyLength > 0 {
systemPrompt += "\nYou have access to last " + strconv.Itoa(historyLength) + " messages in this chat." systemPrompt += "\nYou have access to last " + strconv.Itoa(historyLength) + "messages in this chat."
} }
req := openai.ChatCompletionRequest{ req := openai.ChatCompletionRequest{

View file

@ -56,7 +56,7 @@ func (c RequestContext) Prompt() string {
prompt += "Chat description is \"" + c.Chat.Description + "\". " prompt += "Chat description is \"" + c.Chat.Description + "\". "
} }
prompt += "\nProfile of the user who mentioned you in the chat:\n" + prompt += "\nProfile of the user who mentioned you in the chat:" +
"First name: \"" + c.User.FirstName + "\"\n" "First name: \"" + c.User.FirstName + "\"\n"
if c.User.Username != "" { if c.User.Username != "" {
prompt += "Username: @" + c.User.Username + ".\n" prompt += "Username: @" + c.User.Username + ".\n"