Feat: switch between completion and chat api

This commit is contained in:
Grail Finder
2025-02-01 16:32:36 +03:00
parent 336451340b
commit 84c94ecea3
8 changed files with 81 additions and 24 deletions

27
server.go Normal file
View File

@@ -0,0 +1,27 @@
package main
import (
"fmt"
"net/http"
)
// create server
// listen to the completion endpoint handler
func completion(w http.ResponseWriter, req *http.Request) {
// post request
body := req.Body
// get body as io.reader
// pass it to the /completion
go sendMsgToLLM(body)
out:
for {
select {
case chunk := <-chunkChan:
fmt.Println(chunk)
case <-streamDone:
break out
}
}
return
}