From a2e9e6e273da14f827dd7c4e6288a29ab465d7e2 Mon Sep 17 00:00:00 2001 From: lehel Date: Tue, 30 Sep 2025 22:34:22 +0200 Subject: [PATCH] model --- llm.go | 7 +++++-- main.go | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/llm.go b/llm.go index 4836557..319c6e9 100644 --- a/llm.go +++ b/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) diff --git a/main.go b/main.go index 9f21f17..b4a0132 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,7 @@ func main() { var llm LLMClientAPI = NewLLMClient( os.Getenv("OPENAI_API_KEY"), os.Getenv("OPENAI_BASE_URL"), + os.Getenv("OPENAI_MODEL"), ) chatService := NewChatService(llm, &reasonDB) r := gin.Default()