Copilot commented on code in PR #847:
URL: https://github.com/apache/dubbo-go-samples/pull/847#discussion_r2108213072
##########
llm/config/config.go:
##########
@@ -73,6 +73,22 @@ func Load(envFile string) (*Config, error) {
config.OllamaModels = modelsList
+ modelName := os.Getenv("MODEL_NAME")
Review Comment:
[nitpick] If `MODEL_NAME` is not set, the server will error out. Consider
defaulting to the first configured model in `OllamaModels` to avoid requiring
an extra env var.
##########
llm/go-server/cmd/server.go:
##########
@@ -145,43 +124,51 @@ func (s *ChatServer) Chat(ctx context.Context, req
*chat.ChatRequest, stream cha
}
return stream.Send(&chat.ChatResponse{
Content: string(chunk),
- Model: modelName,
+ Model: cfg.ModelName,
})
}),
)
if err != nil {
- log.Printf("GenerateContent failed with model %s: %v\n",
modelName, err)
- return fmt.Errorf("GenerateContent failed with model %s: %v",
modelName, err)
+ log.Printf("GenerateContent failed with model %s: %v\n",
cfg.ModelName, err)
+ return fmt.Errorf("GenerateContent failed with model %s: %v",
cfg.ModelName, err)
}
+ logger.Infof("GenerateContent successfully with model: %s",
cfg.ModelName)
+
return nil
}
func main() {
-
var err error
cfg, err = config.GetConfig()
if err != nil {
fmt.Printf("Error loading config: %v\n", err)
return
}
- ins, err := dubbo.NewInstance(
- dubbo.WithRegistry(
+ portStr := os.Getenv("SERVER_PORT")
+ if portStr == "" {
+ fmt.Printf("Error: SERVER_PORT environment variable is not
set\n")
+ return
+ }
+
+ port, err := strconv.Atoi(portStr)
+ if err != nil {
+ fmt.Printf("Error converting SERVER_PORT to int: %v\n", err)
+ return
+ }
+
+ srv, err := server.NewServer(
Review Comment:
After creating the server instance, you need to call a start or serve method
(e.g., `srv.Start()` or similar) to begin listening, otherwise the process will
exit immediately.
##########
llm/start_servers.sh:
##########
@@ -0,0 +1,87 @@
+#!/bin/bash
+
+# Check if .env file exists
+if [ ! -f .env ]; then
+ echo "Error: .env file not found"
+ exit 1
+fi
+
+# Default values
+START_PORT=20020
+INSTANCES_PER_MODEL=2
+
+# Parse command line arguments
+while [[ $# -gt 0 ]]; do
+ case $1 in
+ --instances)
+ INSTANCES_PER_MODEL=$2
+ shift 2
+ ;;
+ --start-port)
+ START_PORT=$2
+ shift 2
+ ;;
+ *)
+ echo "Unknown parameter: $1"
+ exit 1
+ ;;
+ esac
+done
+
+# Function to read value from .env file and clean it
+get_env_value() {
+ local key=$1
+ # Read the line containing the key, extract everything after the first =
+ local value=$(grep "^[[:space:]]*$key[[:space:]]*=" .env | sed
's/^[^=]*=[[:space:]]*//')
+ # Remove leading/trailing whitespace and quotes
+ value=$(echo "$value" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
-e 's/^["\x27]//' -e 's/["\x27]$//')
+ echo "$value"
+}
+
+# Get models from .env file
+OLLAMA_MODELS=$(get_env_value "OLLAMA_MODELS")
+
+# Check if OLLAMA_MODELS is empty
+if [ -z "$OLLAMA_MODELS" ]; then
+ echo "Error: OLLAMA_MODELS not found in .env file"
+ echo "Please make sure .env file contains a line like: OLLAMA_MODELS =
llava:7b, qwen2.5:7b"
Review Comment:
[nitpick] The example format here uses spaces around `=`, but `.env.example`
and parsing accept no-space syntax (`KEY=VALUE`). Align the example with actual
usage or clarify that both are supported.
```suggestion
echo "Please make sure .env file contains a line like:
OLLAMA_MODELS=llava:7b,qwen2.5:7b"
```
##########
llm/go-client/cmd/client.go:
##########
@@ -146,17 +148,24 @@ func main() {
currentCtxID = createContext()
+ // #TODO support selecting model
Review Comment:
[nitpick] Use the standard `// TODO:` format for comments so IDEs and
linters recognize it (e.g., `// TODO: support selecting model`).
```suggestion
// TODO: support selecting model
```
--
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]