From ccd2b7b69c23016fc52ba2af8eff1d52a57076ce Mon Sep 17 00:00:00 2001 From: juzeon Date: Tue, 6 Feb 2024 15:24:28 +0800 Subject: [PATCH] make create conversation private --- sydney/conversation.go | 2 +- sydney/stream.go | 2 +- webapi/webapi.go | 32 -------------------------------- 3 files changed, 2 insertions(+), 34 deletions(-) diff --git a/sydney/conversation.go b/sydney/conversation.go index 58ab77f..decd245 100644 --- a/sydney/conversation.go +++ b/sydney/conversation.go @@ -10,7 +10,7 @@ import ( "time" ) -func (o *Sydney) CreateConversation() (CreateConversationResponse, error) { +func (o *Sydney) createConversation() (CreateConversationResponse, error) { client, err := util.MakeHTTPClient(o.proxy, 10*time.Second) if err != nil { return CreateConversationResponse{}, err diff --git a/sydney/stream.go b/sydney/stream.go index 9906c7b..0c3d8f3 100644 --- a/sydney/stream.go +++ b/sydney/stream.go @@ -293,7 +293,7 @@ func (o *Sydney) AskStream(options AskStreamOptions) (<-chan Message, error) { } func (o *Sydney) AskStreamRaw(options AskStreamOptions) (CreateConversationResponse, <-chan RawMessage, error) { slog.Info("AskStreamRaw called, creating conversation...") - conversation, err := o.CreateConversation() + conversation, err := o.createConversation() if err != nil { return CreateConversationResponse{}, nil, err } diff --git a/webapi/webapi.go b/webapi/webapi.go index 6aa8f62..2e53c9e 100644 --- a/webapi/webapi.go +++ b/webapi/webapi.go @@ -97,38 +97,6 @@ func main() { fmt.Fprint(w, "OK") }) - r.Post("/conversation/new", func(w http.ResponseWriter, r *http.Request) { - // parse request - var request CreateConversationRequest - - err := json.NewDecoder(r.Body).Decode(&request) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - cookies := util.Ternary(request.Cookies == "", defaultCookies, ParseCookies(request.Cookies)) - - // create conversation - conversation, err := sydney. - NewSydney(sydney.Options{ - Cookies: cookies, - Proxy: proxy, - }). - CreateConversation() - - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - // set headers - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - - // write response - json.NewEncoder(w).Encode(conversation) - }) - r.Post("/image/upload", func(w http.ResponseWriter, r *http.Request) { // parse request r.ParseMultipartForm(16 << 20)