mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-19 01:56:37 +08:00
refactor: Improve performance and reliability in text relay functionality
- Refactor relay-text controller to improve performance and readability - Update function signatures for better consistency - Optimize error handling for improved reliability
This commit is contained in:
parent
287376dd97
commit
da6d7874ee
@ -15,6 +15,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"gorm.io/gorm/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -443,6 +444,15 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
|
|||||||
}
|
}
|
||||||
}(c.Request.Context())
|
}(c.Request.Context())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ // more error info
|
||||||
|
if reqdata, err := json.Marshal(req); err != nil {
|
||||||
|
fmt.Printf("relay text error: %s\n", err.Error())
|
||||||
|
} else {
|
||||||
|
fmt.Printf("send req %q got error %d", reqdata, resp.StatusCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return relayErrorHandler(resp)
|
return relayErrorHandler(resp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user