Alanxtl commented on code in PR #847:
URL: https://github.com/apache/dubbo-go-samples/pull/847#discussion_r2108249897


##########
llm/go-server/cmd/server.go:
##########
@@ -43,30 +46,24 @@ import (
 var cfg *config.Config
 
 type ChatServer struct {
-       llms map[string]*ollama.LLM
+       llm *ollama.LLM
 }
 
 func NewChatServer() (*ChatServer, error) {
+       if cfg.ModelName == "" {
+               return nil, fmt.Errorf("MODEL_NAME environment variable is not 
set")
+       }

Review Comment:
   put this check in `config.go` instead of here



##########
llm/config/config.go:
##########
@@ -73,6 +73,22 @@ func Load(envFile string) (*Config, error) {
 
                config.OllamaModels = modelsList
 
+               modelName := os.Getenv("MODEL_NAME")
+               if modelName != "" {
+                       modelValid := false
+                       for _, m := range modelsList {
+                               if m == modelName {
+                                       modelValid = true
+                                       break
+                               }
+                       }
+                       if !modelValid {
+                               configErr = fmt.Errorf("specified model %s is 
not in the configured models list", modelName)
+                               return
+                       }
+                       config.ModelName = modelName
+               }

Review Comment:
   First check ```if modelName == ""```, then these code can be wrapped without 
wrapping in an `if` block to reduce circle complexity



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to