Skip to content

Commit

Permalink
proper escaping of json in curl
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Jun 11, 2024
1 parent 5483560 commit 39396f2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ export const OpenAIChatCompletion: ChatCompletionHandler = async (

trace.detailsFenced(
`✉️ fetch`,
`curl ${url} \\
`curl -X POST ${url} \\
-H "Content-Type: application/json" \\
${Object.entries(cfg.curlHeaders || {})
.map(([k, v]) => `-H "${k}: ${v}" \\`)
.join("\n")}
-d '${JSON.stringify(postReq, null, 2)}'
-d '${JSON.stringify(postReq).replace(/'/g, "'\\''")}'
`,
"bash"
)
Expand Down

0 comments on commit 39396f2

Please sign in to comment.