-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain.go
More file actions
71 lines (60 loc) · 2.21 KB
/
Copy pathmain.go
File metadata and controls
71 lines (60 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"flag"
"fmt"
"github.com/dev2k6/command-code-proxy-server/internal/proxy"
"github.com/dev2k6/command-code-proxy-server/internal/server"
"github.com/dev2k6/command-code-proxy-server/internal/update"
)
const appVersion = "v1.0.8"
const repositoryURL = "https://github.com/dev2k6/command-code-proxy-server"
const debugLogging = false
func main() {
port := flag.String("port", "", "Port to run the server on (default: 55990)")
host := flag.String("host", "", "Host to bind to (default: 127.0.0.1)")
apiKey := flag.String("api-key", "", "API key for CommandCode (optional, can also be set via Authorization header)")
showVersion := flag.Bool("version", false, "Print version and exit")
flag.Parse()
if *showVersion {
fmt.Println(versionText())
return
}
proxy := proxy.NewProxy(*apiKey)
proxy.Debug = debugLogging
srv := server.NewServer(proxy)
srv.SetPort(*port)
srv.SetHost(*host)
printStartupInfo(srv)
srv.Start()
}
func versionText() string {
latest, hasUpdate, err := update.LatestVersion(appVersion)
if err != nil || !hasUpdate {
return appVersion
}
return fmt.Sprintf("%s (latest: %s)", appVersion, latest)
}
func printStartupInfo(srv *server.Server) {
fmt.Println("")
fmt.Println("========================================")
fmt.Println(" CommandCode Proxy Server")
fmt.Println("========================================")
fmt.Println("")
fmt.Printf(" Version: %s\n", versionText())
fmt.Printf(" Repository: %s\n", repositoryURL)
fmt.Printf(" Host: %s\n", srv.GetHost())
fmt.Printf(" Port: %s\n", srv.GetPort())
fmt.Println(" Base URL: https://api.commandcode.ai")
fmt.Println("")
fmt.Println(" Endpoints:")
fmt.Println(" POST /v1/chat/completions (OpenAI-compatible)")
fmt.Println(" POST /chat/completions (OpenAI-compatible alias)")
fmt.Println(" POST /v1/responses (OpenAI Responses-compatible)")
fmt.Println(" GET /v1/models (list models)")
fmt.Println(" GET /health (health check)")
fmt.Println("")
fmt.Printf(" Server running on http://%s:%s\n", srv.GetHost(), srv.GetPort())
fmt.Println("")
fmt.Println(" Press Ctrl+C to stop")
fmt.Println("========================================")
}