summaryrefslogtreecommitdiff
path: root/server.go
blob: 2e255597e4ad0483d85cc93fc50fe21c7cf4b0c4 (plain)
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
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
}