Feat: guess limit

This commit is contained in:
Grail Finder
2025-06-14 11:37:42 +03:00
parent bddaa912de
commit fa25679624
8 changed files with 97 additions and 64 deletions

View File

@ -2,6 +2,7 @@ package llmapi
import (
"encoding/json"
"errors"
"fmt"
"log/slog"
"strings"
@ -29,7 +30,7 @@ func (p *deepSeekParser) ParseBytes(body []byte) (map[string]any, error) {
}
if len(dsResp.Choices) == 0 {
p.log.Error("empty choices", "dsResp", dsResp)
err := fmt.Errorf("empty choices in dsResp")
err := errors.New("empty choices in dsResp")
return nil, err
}
text := dsResp.Choices[0].Text
@ -37,7 +38,7 @@ func (p *deepSeekParser) ParseBytes(body []byte) (map[string]any, error) {
ri := strings.LastIndex(text, "}")
if li < 0 || ri < 1 {
p.log.Error("not a json", "msg", text)
err := fmt.Errorf("fn: ParseBytes, not a json")
err := fmt.Errorf("fn: ParseBytes, not a json; data: %s", text)
return nil, err
}
sj := text[li : ri+1]
@ -67,7 +68,7 @@ func (p *lcpRespParser) ParseBytes(body []byte) (map[string]any, error) {
}
if len(resp.Choices) == 0 {
p.log.Error("empty choices", "resp", resp)
err := fmt.Errorf("empty choices in resp")
err := errors.New("empty choices in resp")
return nil, err
}
text := resp.Choices[0].Message.Content
@ -75,7 +76,7 @@ func (p *lcpRespParser) ParseBytes(body []byte) (map[string]any, error) {
ri := strings.LastIndex(text, "}")
if li < 0 || ri < 1 {
p.log.Error("not a json", "msg", text)
err := fmt.Errorf("fn: ParseBytes, not a json")
err := fmt.Errorf("fn: ParseBytes, not a json; data: %s", text)
return nil, err
}
sj := text[li : ri+1]