feat(summary): send complete articles within user budget (#39)
This commit is contained in:
@ -29,7 +29,7 @@ func newGemini(apiKey, model string) *geminiProvider {
|
||||
|
||||
func (p *geminiProvider) Name() string { return "gemini" }
|
||||
|
||||
func (p *geminiProvider) Summarize(ctx context.Context, prompt string, _ GenOptions) (string, error) {
|
||||
func (p *geminiProvider) Summarize(ctx context.Context, prompt string, opts GenOptions) (string, error) {
|
||||
url := fmt.Sprintf(
|
||||
"https://generativelanguage.googleapis.com/v1beta/models/%s:generateContent?key=%s",
|
||||
p.model, p.apiKey,
|
||||
@ -39,6 +39,9 @@ func (p *geminiProvider) Summarize(ctx context.Context, prompt string, _ GenOpti
|
||||
{"parts": []map[string]string{{"text": prompt}}},
|
||||
},
|
||||
}
|
||||
if opts.MaxOutputTokens > 0 {
|
||||
body["generationConfig"] = map[string]int{"maxOutputTokens": opts.MaxOutputTokens}
|
||||
}
|
||||
b, _ := json.Marshal(body)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(b))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user