Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions examples/get-streaming.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
args:
- prompt: "Hello, world!"
method: POST
endpoint: http://localhost:8000/prompt
headers:
- Content-Type: text/event-stream
allow-headers:
- Content-Type
body: |
{
"prompt": "Hello, world!",
"schema": ""
}
18 changes: 3 additions & 15 deletions internal/output/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@ var Blue = "\033[34m"
var Magenta = "\033[35m"
var Cyan = "\033[36m"

// clear styling on files as it shows as raw chars
var FileStyle = &pretty.Style{
Key: [2]string{"", ""},
String: [2]string{"", ""},
Number: [2]string{"", ""},
True: [2]string{"", ""},
False: [2]string{"", ""},
Null: [2]string{"", ""},
Escape: [2]string{"", ""},
Brackets: [2]string{"", ""},
}

type Buffer struct {
buffer strings.Builder
raw bool // true if no styling needed
Expand Down Expand Up @@ -108,12 +96,12 @@ func (b *Buffer) Body(response *http.Response) error {
var prettyJSON []byte

if b.raw {
prettyJSON = pretty.Color([]byte(body), FileStyle)
prettyJSON = pretty.Pretty([]byte(body))
} else {
prettyJSON = pretty.Color([]byte(body), nil)
prettyJSON = pretty.Color(pretty.Pretty([]byte(body)), nil)
}

b.buffer.WriteString(string(prettyJSON[:]) + "\n")
b.buffer.WriteString(string(prettyJSON[:]))

return nil
}
2 changes: 1 addition & 1 deletion internal/output/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func TestResponseWithOnlyBody(t *testing.T) {
}

func TestResponseOnSave(t *testing.T) {
expectedOutput := "200 OK\nContent-Type: application/json\n" + string(pretty.Color([]byte("{\n \"userId\": 1\n}\n"), FileStyle)[:])
expectedOutput := "200 OK\nContent-Type: application/json\n" + string(pretty.Pretty([]byte("{\n \"userId\": 1\n}\n"))[:])

response := http.Response{
Status: "200 OK",
Expand Down