Refactor: Anthropic model response proto update

- Refactor content response

- Update channel adaptor to support `claude_model`
- Remove `null` stop reasons from content responses
- Add logging for error responses
- Change content start, ping, and message delta types to return true
- Set stop reason to end turn when response does not include a stop reason
- Set content response stop reason to null
- Add error handling for unmarshalling stream responses
- Rename `Completion` to `Text` in type definitions and `StopReason` to `Delta.StopReason`
- Count tokens in the `Delta.Text` field of the response instead of `Completion`
- Remove `Model` from the full text response
- Trim \r from incoming data
This commit is contained in:
Laisky.Cai
2024-03-05 05:05:57 +00:00
parent c8713a0212
commit fdde066252
3 changed files with 53 additions and 11 deletions

View File

@@ -41,6 +41,8 @@ func (a *Adaptor) ConvertRequest(c *gin.Context, relayMode int, request *model.G
if request == nil {
return nil, errors.New("request is nil")
}
c.Set("claude_model", request.Model)
return ConvertRequest(*request), nil
}