Skip to content

Commit

Permalink
make create conversation private
Browse files Browse the repository at this point in the history
  • Loading branch information
juzeon committed Feb 6, 2024
1 parent 3991172 commit ccd2b7b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 34 deletions.
2 changes: 1 addition & 1 deletion sydney/conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sydney/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
32 changes: 0 additions & 32 deletions webapi/webapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ccd2b7b

Please sign in to comment.