mirror of https://github.com/velour/catbase.git
llm: add system prompt and fix vars
This commit is contained in:
parent
4c6ef492ad
commit
0dfefe297f
|
@ -26,10 +26,10 @@ func (p *LLMPlugin) geminiConnect() error {
|
||||||
|
|
||||||
func (p *LLMPlugin) gemini(msg string) (chatEntry, error) {
|
func (p *LLMPlugin) gemini(msg string) (chatEntry, error) {
|
||||||
model := p.geminiClient.GenerativeModel("gemini-1.5-flash")
|
model := p.geminiClient.GenerativeModel("gemini-1.5-flash")
|
||||||
model.SetMaxOutputTokens(int32(p.c.GetInt("GEMINI_MAX_TOKENS", 100)))
|
model.SetMaxOutputTokens(int32(p.c.GetInt("gemini.maxtokens", 100)))
|
||||||
model.SetTopP(float32(p.c.GetFloat64("GEMINI_TOP_P", 0.95)))
|
model.SetTopP(float32(p.c.GetFloat64("gemini.topp", 0.95)))
|
||||||
model.SetTopK(int32(p.c.GetInt("GEMINI_TOP_K", 20)))
|
model.SetTopK(int32(p.c.GetInt("gemini.topk", 20)))
|
||||||
model.SetTemperature(float32(p.c.GetFloat64("GEMINI_TEMP", 0.9)))
|
model.SetTemperature(float32(p.c.GetFloat64("gemini.temp", 0.9)))
|
||||||
|
|
||||||
model.SafetySettings = []*genai.SafetySetting{
|
model.SafetySettings = []*genai.SafetySetting{
|
||||||
{genai.HarmCategoryHarassment, genai.HarmBlockNone},
|
{genai.HarmCategoryHarassment, genai.HarmBlockNone},
|
||||||
|
@ -38,6 +38,12 @@ func (p *LLMPlugin) gemini(msg string) (chatEntry, error) {
|
||||||
{genai.HarmCategoryDangerousContent, genai.HarmBlockNone},
|
{genai.HarmCategoryDangerousContent, genai.HarmBlockNone},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if prompt := p.c.Get("gemini.systemprompt", ""); prompt != "" {
|
||||||
|
model.SystemInstruction = &genai.Content{
|
||||||
|
Parts: []genai.Part{genai.Text(prompt)},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cs := model.StartChat()
|
cs := model.StartChat()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
|
@ -69,11 +69,7 @@ func (p *LLMPlugin) register() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *LLMPlugin) setPromptMessage(r bot.Request) bool {
|
func (p *LLMPlugin) setPromptMessage(r bot.Request) bool {
|
||||||
prompt := r.Values["text"]
|
p.c.Set("gemini.systemprompt", r.Values["text"])
|
||||||
if err := p.setPrompt(prompt); err != nil {
|
|
||||||
resp := fmt.Sprintf("Error: %s", err)
|
|
||||||
p.b.Send(r.Conn, bot.Message, r.Msg.Channel, resp)
|
|
||||||
}
|
|
||||||
p.b.Send(r.Conn, bot.Message, r.Msg.Channel, fmt.Sprintf(`Okay. I set the prompt to: "%s"`, prompt))
|
p.b.Send(r.Conn, bot.Message, r.Msg.Channel, fmt.Sprintf(`Okay. I set the prompt to: "%s"`, prompt))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue