mirror of
				https://github.com/songquanpeng/one-api.git
				synced 2025-11-04 15:53:42 +08:00 
			
		
		
		
	fix: better text phrasing
This commit is contained in:
		@@ -83,12 +83,18 @@ func testChannel(channel *model.Channel, request ChatRequest) error {
 | 
			
		||||
			common.SysError("invalid stream response: " + data)
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		if !strings.HasPrefix(data, "data:") {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		data = data[6:]
 | 
			
		||||
		if !strings.HasPrefix(data, "[DONE]") {
 | 
			
		||||
			var streamResponse ChatCompletionsStreamResponse
 | 
			
		||||
			err = json.Unmarshal([]byte(data), &streamResponse)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				common.SysError("error unmarshalling stream response: " + err.Error())
 | 
			
		||||
				// Prinnt the body in string
 | 
			
		||||
				buf := new(bytes.Buffer)
 | 
			
		||||
				buf.ReadFrom(resp.Body)
 | 
			
		||||
				common.SysError("error unmarshalling stream response: " + err.Error() + " " + buf.String())
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
			for _, choice := range streamResponse.Choices {
 | 
			
		||||
 
 | 
			
		||||
@@ -278,6 +278,9 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
 | 
			
		||||
					common.SysError("invalid stream response: " + data)
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
				if !strings.HasPrefix(data, "data:") {
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
				dataChan <- data
 | 
			
		||||
				data = data[6:]
 | 
			
		||||
				if !strings.HasPrefix(data, "[DONE]") {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user