Compare commits
3 Commits
v0.2.4-alp
...
v0.2.5-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
246b981e23 | ||
|
|
2edd52e851 | ||
|
|
e123c66bc7 |
@@ -9,6 +9,9 @@ import (
|
||||
)
|
||||
|
||||
func SendEmail(subject string, receiver string, content string) error {
|
||||
if SMTPFrom == "" { // for compatibility
|
||||
SMTPFrom = SMTPAccount
|
||||
}
|
||||
encodedSubject := fmt.Sprintf("=?UTF-8?B?%s?=", base64.StdEncoding.EncodeToString([]byte(subject)))
|
||||
mail := []byte(fmt.Sprintf("To: %s\r\n"+
|
||||
"From: %s<%s>\r\n"+
|
||||
|
||||
@@ -94,10 +94,12 @@ func relayHelper(c *gin.Context) error {
|
||||
if channelType == common.ChannelTypeAzure {
|
||||
// https://learn.microsoft.com/en-us/azure/cognitive-services/openai/chatgpt-quickstart?pivots=rest-api&tabs=command-line#rest-api
|
||||
query := c.Request.URL.Query()
|
||||
if query.Get("api-version") == "" {
|
||||
apiVersion := c.GetString("api_version")
|
||||
requestURL = fmt.Sprintf("%s?api-version=%s", requestURL, apiVersion)
|
||||
apiVersion := query.Get("api-version")
|
||||
if apiVersion == "" {
|
||||
apiVersion = c.GetString("api_version")
|
||||
}
|
||||
requestURL := strings.Split(requestURL, "?")[0]
|
||||
requestURL = fmt.Sprintf("%s?api-version=%s", requestURL, apiVersion)
|
||||
baseURL = c.GetString("base_url")
|
||||
task := strings.TrimPrefix(requestURL, "/v1/")
|
||||
model_ := textRequest.Model
|
||||
@@ -186,7 +188,7 @@ func relayHelper(c *gin.Context) error {
|
||||
data := scanner.Text()
|
||||
dataChan <- data
|
||||
data = data[6:]
|
||||
if data != "[DONE]" {
|
||||
if !strings.HasPrefix(data, "[DONE]") {
|
||||
var streamResponse StreamResponse
|
||||
err = json.Unmarshal([]byte(data), &streamResponse)
|
||||
if err != nil {
|
||||
@@ -207,6 +209,9 @@ func relayHelper(c *gin.Context) error {
|
||||
c.Stream(func(w io.Writer) bool {
|
||||
select {
|
||||
case data := <-dataChan:
|
||||
if strings.HasPrefix(data, "data: [DONE]") {
|
||||
data = "data: [DONE]"
|
||||
}
|
||||
c.Render(-1, common.CustomEvent{Data: data})
|
||||
return true
|
||||
case <-stopChan:
|
||||
|
||||
@@ -60,9 +60,6 @@ func InitOptionMap() {
|
||||
common.SysError("Failed to update option map: " + err.Error())
|
||||
}
|
||||
}
|
||||
if common.SMTPFrom == "" { // for compatibility
|
||||
common.SMTPFrom = common.SMTPAccount
|
||||
}
|
||||
}
|
||||
|
||||
func UpdateOption(key string, value string) error {
|
||||
|
||||
Reference in New Issue
Block a user