2024-03-12 03:12:25 +00:00
|
|
|
package llm
|
|
|
|
|
|
|
|
type RequestContext struct {
|
2024-03-12 22:18:01 +00:00
|
|
|
Empty bool
|
|
|
|
Inline bool
|
|
|
|
User UserContext
|
|
|
|
Chat ChatContext
|
2024-03-12 03:12:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
2024-03-12 22:18:01 +00:00
|
|
|
if c.Empty {
|
|
|
|
return ""
|
2024-03-12 03:31:07 +00:00
|
|
|
}
|
2024-03-12 22:18:01 +00:00
|
|
|
|
|
|
|
prompt := ""
|
|
|
|
if !c.Inline {
|
|
|
|
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 + "\". "
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
prompt += "You're responding to inline query, so you're not in the chat right now. "
|
2024-03-12 03:31:07 +00:00
|
|
|
}
|
|
|
|
|
2024-03-12 03:47:48 +00:00
|
|
|
prompt += "According to their profile, first name of the user who wrote you is \"" + c.User.FirstName + "\". "
|
2024-03-12 03:12:25 +00:00
|
|
|
if c.User.Username != "" {
|
2024-03-12 03:47:48 +00:00
|
|
|
prompt += "Their username is @" + c.User.Username + ". "
|
2024-03-12 03:12:25 +00:00
|
|
|
}
|
|
|
|
if c.User.LastName != "" {
|
|
|
|
prompt += "Their last name is \"" + c.User.LastName + "\". "
|
|
|
|
}
|
|
|
|
if c.User.IsPremium {
|
|
|
|
prompt += "They have Telegram Premium subscription. "
|
|
|
|
}
|
|
|
|
|
|
|
|
return prompt
|
|
|
|
}
|