in llm/go-client/cmd/client.go [54:117]
func handleCommand(cmd string) (resp string) {
cmd = strings.TrimSpace(cmd)
resp = ""
switch {
case cmd == "/?" || cmd == "/help":
resp += "Available commands:\n"
resp += "/? help - Show this help\n"
resp += "/list - List all contexts\n"
resp += "/cd <context> - Switch context\n"
resp += "/new - Create new context\n"
resp += "/models - List available models\n"
resp += "/model <name> - Switch to specified model"
return resp
case cmd == "/list":
fmt.Printf("Stored contexts (max %d):\n", maxContextCount)
for _, ctxID := range contextOrder {
resp += fmt.Sprintf("- %s\n", ctxID)
}
resp = strings.TrimSuffix(resp, "\n")
return resp
case strings.HasPrefix(cmd, "/cd "):
target := strings.TrimPrefix(cmd, "/cd ")
if ctx, exists := contexts[target]; exists {
currentCtxID = ctx.ID
resp += fmt.Sprintf("Switched to context: %s", target)
} else {
resp += "Context not found"
}
return resp
case cmd == "/new":
newID := createContext()
currentCtxID = newID
resp += fmt.Sprintf("Created new context: %s", newID)
return resp
case cmd == "/models":
resp += "Available models:"
for _, model := range availableModels {
marker := " "
if model == currentModel {
marker = "*"
}
resp += fmt.Sprintf("\n%s %s", marker, model)
}
return resp
case strings.HasPrefix(cmd, "/model "):
modelName := strings.TrimPrefix(cmd, "/model ")
modelFound := false
for _, model := range availableModels {
if model == modelName {
currentModel = model
modelFound = true
break
}
}
if modelFound {
resp += fmt.Sprintf("Switched to model: %s", modelName)
} else {
resp += fmt.Sprintf("Model '%s' not found. Use /models to see available models.", modelName)
}
return resp
default:
return "Invalid command, use /? for help"
}
}