fix los buguos
This commit is contained in:
+2
-1
@@ -38,7 +38,8 @@ func (client Client) GenerateContent(content []*genai.Content) (*genai.GenerateC
|
|||||||
client.model,
|
client.model,
|
||||||
content,
|
content,
|
||||||
&genai.GenerateContentConfig{
|
&genai.GenerateContentConfig{
|
||||||
Temperature: &temp,
|
Temperature: &temp,
|
||||||
|
MaxOutputTokens: 800,
|
||||||
SystemInstruction: &genai.Content{
|
SystemInstruction: &genai.Content{
|
||||||
Role: "system",
|
Role: "system",
|
||||||
Parts: []*genai.Part{
|
Parts: []*genai.Part{
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import (
|
|||||||
|
|
||||||
const MAX_HISTORY = 50
|
const MAX_HISTORY = 50
|
||||||
|
|
||||||
|
const DISCORD_MAX_CHAR = 4000
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SPAM_PERIOD = 5 * time.Minute
|
SPAM_PERIOD = 5 * time.Minute
|
||||||
MESSAGES_PER_PERIOD = 10
|
MESSAGES_PER_PERIOD = 10
|
||||||
@@ -118,11 +120,19 @@ func cleanMessage(p string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func sendResponse(s *discordgo.Session, channelID string, response string) {
|
func sendResponse(s *discordgo.Session, channelID string, response string) {
|
||||||
if _, err := s.ChannelMessageSend(channelID, response); err != nil {
|
if _, err := s.ChannelMessageSend(channelID, truncateIfNeeded(response)); err != nil {
|
||||||
log.Printf("\nfailed to send the response [%s] to the discord channel [%s]", response, err.Error())
|
log.Printf("\nfailed to send the response [%s] to the discord channel [%s]", response, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func truncateIfNeeded(response string) string {
|
||||||
|
if len(response) > DISCORD_MAX_CHAR {
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%s %s", response[:3990], "[...]")
|
||||||
|
}
|
||||||
|
|
||||||
func containHal(users []*discordgo.User, userID string) bool {
|
func containHal(users []*discordgo.User, userID string) bool {
|
||||||
for _, u := range users {
|
for _, u := range users {
|
||||||
if u.ID == userID {
|
if u.ID == userID {
|
||||||
|
|||||||
Reference in New Issue
Block a user