"src/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "2c1ed50fc57f154768364e4506d7bab9daebf83d"
Commit 8fa3f366 authored by Arne Müller's avatar Arne Müller
Browse files

Removed newline trimming and used buffer directly in POST request.

parent ee94693b
...@@ -545,18 +545,15 @@ func (llm *llama) Predict(ctx context.Context, prevContext []int, prompt string, ...@@ -545,18 +545,15 @@ func (llm *llama) Predict(ctx context.Context, prevContext []int, prompt string,
} }
// Handling JSON marshaling with special characters unescaped. // Handling JSON marshaling with special characters unescaped.
buf := &bytes.Buffer{} buffer := &bytes.Buffer{}
enc := json.NewEncoder(buf) enc := json.NewEncoder(buffer)
enc.SetEscapeHTML(false) enc.SetEscapeHTML(false)
if err := enc.Encode(predReq); err != nil { if err := enc.Encode(predReq); err != nil {
return fmt.Errorf("failed to marshal data: %v", err) return fmt.Errorf("failed to marshal data: %v", err)
} }
// Remove trailing newline added by Encode. req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, buffer)
data := buf.Bytes()[:buf.Len()-1]
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, bytes.NewBuffer(data))
if err != nil { if err != nil {
return fmt.Errorf("error creating POST request: %v", err) return fmt.Errorf("error creating POST request: %v", err)
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment