model
This commit is contained in:
parent
b63ae2ba43
commit
a2e9e6e273
7
llm.go
7
llm.go
|
|
@ -16,13 +16,15 @@ import (
|
|||
type LLMClient struct {
|
||||
APIKey string
|
||||
BaseURL string
|
||||
Model string
|
||||
}
|
||||
|
||||
// NewLLMClient constructs a new LLMClient with the given API key and base URL
|
||||
func NewLLMClient(apiKey, baseURL string) *LLMClient {
|
||||
func NewLLMClient(apiKey, baseURL string, model string) *LLMClient {
|
||||
return &LLMClient{
|
||||
APIKey: apiKey,
|
||||
BaseURL: baseURL,
|
||||
Model: model,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -110,13 +112,14 @@ func (llm *LLMClient) openAICompletion(ctx context.Context, prompt string, forma
|
|||
}
|
||||
logrus.WithFields(logrus.Fields{"api_url": apiURL, "prompt": prompt, "format": format}).Info("[LLM] openAICompletion POST")
|
||||
body := map[string]interface{}{
|
||||
"model": "qwen3:latest",
|
||||
"model": llm.Model, // "qwen3:latest",
|
||||
"messages": []map[string]string{{"role": "user", "content": prompt}},
|
||||
"stream": false,
|
||||
"format": format,
|
||||
}
|
||||
jsonBody, _ := json.Marshal(body)
|
||||
req, _ := http.NewRequestWithContext(ctx, "POST", apiURL, bytes.NewBuffer(jsonBody))
|
||||
req.Header.Set("Authorization", "Bearer "+llm.APIKey)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
|
|
|
|||
Loading…
Reference in New Issue