Skip to content

Commit 2ff21c4

Browse files
committed
refator: rn jsonout to json
1 parent 8101d4e commit 2ff21c4

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

examples/outputs/json/main.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/bit8bytes/gogantic/outputs/json"
7+
)
8+
9+
type joke struct {
10+
Setup string `json:"setup"`
11+
Punchline string `json:"punchline"`
12+
}
13+
14+
func main() {
15+
parser := json.NewParser[joke]()
16+
joke, err := parser.Parse(`
17+
{
18+
"setup": "Why don't scientists trust atoms?",
19+
"punchline": "Because they make up everything!"
20+
}`)
21+
if err != nil {
22+
panic(err)
23+
}
24+
25+
fmt.Println("Setup: " + joke.Setup)
26+
fmt.Println("Punchline: " + joke.Punchline)
27+
28+
instructions := parser.Instructions()
29+
fmt.Println("LLM instructions: " + instructions)
30+
}

0 commit comments

Comments
 (0)