Skip to content

Commit f0ee148

Browse files
author
kqvanity
committed
fix: escape characters escaping
1 parent 4e4e571 commit f0ee148

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package main
22

33
func main() {
4-
4+
MongoRestClient()
55
}

mongo.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,8 @@ func (s *RestStreamCallback) OnReferences(r ReferencesMsg) {
250250
s.f.Flush()
251251
}
252252

253-
// FIXME: ai doesn't parse the output quite nicely with escape chars and whatnot
254253
func escapeJSON(s string) string {
255-
//if !strings.Contains(s, " ") {
256-
// //fmt.Println("contains", s)
257-
// return s
258-
//}
254+
s = strings.ReplaceAll(s, "\\n", "\n")
259255
b, _ := json.Marshal(s)
260256
return string(b[1 : len(b)-1])
261257
}
@@ -305,6 +301,7 @@ func MongoRestClient() {
305301
log.Fatal(err)
306302
}
307303
}
304+
308305
func cHandler(c *gin.Context) {
309306
var req OpenaiRequest
310307
flusher, ok := c.Writer.(http.Flusher)

0 commit comments

Comments
 (0)