diff --git a/go.mod b/go.mod index 31fdf43..05ca703 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cubatic45/copi -go 1.21.6 +go 1.22.0 require ( github.com/mitchellh/go-homedir v1.1.0 diff --git a/main.go b/main.go index 252ea2c..f2a1cf1 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,8 @@ func main() { fmt.Printf("copilotToken: %s\n", copilotToken) fmt.Printf("copilotTokenURL: %s\n", copilotTokenURL) Init() - http.HandleFunc("/", handleProxy) - http.ListenAndServe(":8081", nil) + mux := http.NewServeMux() + mux.HandleFunc("GET /v1/models", handleModel) + mux.HandleFunc("POST /v1/chat/completions", handleProxy) + http.ListenAndServe(":8081", mux) } diff --git a/model.go b/model.go new file mode 100644 index 0000000..47f1807 --- /dev/null +++ b/model.go @@ -0,0 +1,7 @@ +package main + +import "net/http" + +func handleModel(w http.ResponseWriter, r *http.Request) { + w.Write([]byte(`{"object":"list","data":[{"id":"gpt-3.5-turbo","object":"model","created":1677610602,"owned_by":"openai"},{"id":"gpt-4","object":"model","created":1677610602,"owned_by":"openai"}]}`)) +}