telegram-ollama-reply-bot/llm/request_context.go
Alexey Skobkin dc5ad2c580
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Implementing request context and adding it to /hey command processing.
2024-03-12 06:12:25 +03:00

39 lines
869 B
Go

package llm
type RequestContext struct {
User UserContext
Chat ChatContext
}
type UserContext struct {
Username string
FirstName string
LastName string
IsPremium bool
}
type ChatContext struct {
Title string
Description string
Type string
}
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 + "\". "
if c.User.Username != "" {
prompt += "The user who wrote you has username \"@" + c.Chat.Description + "\". "
}
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. "
}
return prompt
}