Feat: rp mode
This commit is contained in:
24
parser.go
24
parser.go
@@ -105,7 +105,7 @@ func NewOpenRouterParser(log *slog.Logger) *openRouterParser {
|
||||
|
||||
func (p *openRouterParser) ParseBytes(body []byte) (string, error) {
|
||||
// parsing logic here
|
||||
resp := models.OpenRouterResp{}
|
||||
resp := models.DSResp{}
|
||||
if err := json.Unmarshal(body, &resp); err != nil {
|
||||
p.log.Error("failed to unmarshal", "error", err)
|
||||
return "", err
|
||||
@@ -115,33 +115,25 @@ func (p *openRouterParser) ParseBytes(body []byte) (string, error) {
|
||||
err := errors.New("empty choices in resp")
|
||||
return "", err
|
||||
}
|
||||
text := resp.Choices[0].Message.Content
|
||||
text := resp.Choices[0].Text
|
||||
return text, nil
|
||||
}
|
||||
|
||||
func (p *openRouterParser) MakePayload(prompt string) io.Reader {
|
||||
// Models to rotate through
|
||||
models := []string{
|
||||
"google/gemini-2.0-flash-exp:free",
|
||||
"deepseek/deepseek-chat-v3-0324:free",
|
||||
"mistralai/mistral-small-3.2-24b-instruct:free",
|
||||
"qwen/qwen3-14b:free",
|
||||
"deepseek/deepseek-r1:free",
|
||||
"google/gemma-3-27b-it:free",
|
||||
"meta-llama/llama-3.3-70b-instruct:free",
|
||||
"google/gemini-flash-1.5",
|
||||
"deepseek/deepseek-coder",
|
||||
"mistralai/mistral-7b-instruct",
|
||||
"qwen/qwen-72b-chat",
|
||||
"meta-llama/llama-3-8b-instruct",
|
||||
}
|
||||
// Get next model index using atomic addition for thread safety
|
||||
p.modelIndex++
|
||||
model := models[int(p.modelIndex)%len(models)]
|
||||
strPayload := fmt.Sprintf(`{
|
||||
"model": "%s",
|
||||
"max_tokens": 300,
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "%s"
|
||||
}
|
||||
]
|
||||
"prompt": "%s"
|
||||
}`, model, prompt)
|
||||
p.log.Debug("made openrouter payload", "model", model, "payload", strPayload)
|
||||
return strings.NewReader(strPayload)
|
||||
|
Reference in New Issue
Block a user