Refactored, added comprehensive testing.
All checks were successful
Release / release (push) Successful in 3m17s

This commit is contained in:
Jay
2025-10-26 23:23:43 -04:00
parent ec32b75267
commit 1936f055e2
61 changed files with 4678 additions and 769 deletions

36
api/payload.go Normal file
View File

@@ -0,0 +1,36 @@
package api
import "git.wisehodl.dev/jay/aicli/config"
// buildPayload constructs the JSON payload for the API request based on protocol.
func buildPayload(cfg config.ConfigData, model string, query string) map[string]interface{} {
if cfg.Protocol == config.ProtocolOllama {
payload := map[string]interface{}{
"model": model,
"prompt": query,
"stream": false,
}
if cfg.SystemPrompt != "" {
payload["system"] = cfg.SystemPrompt
}
return payload
}
// OpenAI protocol
messages := []map[string]string{}
if cfg.SystemPrompt != "" {
messages = append(messages, map[string]string{
"role": "system",
"content": cfg.SystemPrompt,
})
}
messages = append(messages, map[string]string{
"role": "user",
"content": query,
})
return map[string]interface{}{
"model": model,
"messages": messages,
}
}