Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update header key to avoid using underscores #48

Merged
merged 2 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/content.en/docs/references/api/assistant.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ curl -XGET http://localhost:2900/chat/csk30fjq50k7l4akku9g/_history

```shell
//request
curl -H'WEBSOCKET_SESSION_ID: csk88l3q50kb4hr5unn0' -H 'Content-Type: application/json' -XPOST http://localhost:2900/chat/csk30fjq50k7l4akku9g/_send -d '{"message":"Hello"}'
curl -H'WEBSOCKET-SESSION-ID: csk88l3q50kb4hr5unn0' -H 'Content-Type: application/json' -XPOST http://localhost:2900/chat/csk30fjq50k7l4akku9g/_send -d '{"message":"Hello"}'

//response
[{
Expand All @@ -86,7 +86,7 @@ curl -H'WEBSOCKET_SESSION_ID: csk88l3q50kb4hr5unn0' -H 'Content-Type: applicat
}]
```

Tips: `WEBSOCKET_SESSION_ID` should be replaced with the actual WebSocket session ID. You will receive a message each time you connect to the Coco AI WebSocket server. For example: `ws://localhost:2900/ws` or `wss://localhost:2900/ws` if TLS is enabled.
Tips: `WEBSOCKET-SESSION-ID` should be replaced with the actual WebSocket session ID. You will receive a message each time you connect to the Coco AI WebSocket server. For example: `ws://localhost:2900/ws` or `wss://localhost:2900/ws` if TLS is enabled.

![](/img/websocket-on-connect.jpg?raw=true)

Expand Down
2 changes: 2 additions & 0 deletions docs/content.en/docs/release-notes/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ Information about release notes of Coco Server is provided here.
### Bug fix

### Improvements
- Update header key to avoid using underscores #48

8 changes: 7 additions & 1 deletion modules/assistant/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ func (h APIHandler) cancelReplyMessage(w http.ResponseWriter, req *http.Request,

func (h APIHandler) sendChatMessage(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {

webSocketID:=req.Header.Get("WEBSOCKET_SESSION_ID")
webSocketID:=req.Header.Get("WEBSOCKET-SESSION-ID")

log.Info(req.Header)

sessionID := ps.MustGetParameter("session_id")
var request MessageRequest
Expand Down Expand Up @@ -191,6 +193,8 @@ func (h APIHandler) sendChatMessage(w http.ResponseWriter, req *http.Request, ps
taskID:=task.RunWithinGroup("assistant-session", func(taskCtx context.Context) error {
//timeout for 30 seconds

log.Debugf("place a assistant background job for session: %v, websocket: %v ",sessionID,webSocketID)

//TODO
//1. retrieve related documents from background server
//2. summary previous history chat as context
Expand Down Expand Up @@ -271,6 +275,8 @@ func (h APIHandler) sendChatMessage(w http.ResponseWriter, req *http.Request, ps
return nil
})
inflightMessages.Store(sessionID,taskID)
}else{
log.Debugf("no websocket: %v found for session: %v ",webSocketID,sessionID)
}

err = h.WriteJSON(w, response, 200)
Expand Down
Loading