Skip to content

Commit 3eb7099

Browse files
committed
Updated README.md and example
1 parent c5f8bd9 commit 3eb7099

File tree

2 files changed

+78
-5
lines changed

2 files changed

+78
-5
lines changed

README.md

+31-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
The **GoLamify** Go package provides an easy way to integrate Go projects with **Ollama**.
44

5+
## ✨ Features
6+
7+
1. **Generate Responses from Ollama Models** – Easily generate responses using a variety of Ollama models.
8+
2. **Default Response Streaming** – Real-time response streaming for immediate output.
9+
3. **Full Parameter Support** – Customize model behavior with full API parameter support.
10+
4. **No Model Pulling Needed** – Access models without manual pre-pulling.
11+
5. **Clear Error Handling** – Simple, concise error handling for easy debugging.
12+
6. **More** – Comming soon.
13+
514
## 🚀 Getting Started
615

716
### Installation
@@ -27,6 +36,7 @@ package main
2736

2837
import (
2938
"fmt"
39+
3040
"github.com/prasad89/golamify/pkg/golamify"
3141
)
3242

@@ -37,13 +47,29 @@ func main() {
3747
return
3848
}
3949

40-
resp, err := golamify.Generate(client, "llama3.2", "Why is the sky blue?")
41-
if err != nil {
42-
fmt.Println("Error generating response:", err)
43-
return
50+
payload := golamify.GeneratePayload{
51+
Model: "llama3.2:1b",
52+
Prompt: "Why is the sky blue?",
4453
}
4554

46-
fmt.Println("Response:", resp.Response)
55+
responseChannel, errorChannel := golamify.Generate(client, &payload)
56+
57+
for {
58+
select {
59+
case response, ok := <-responseChannel:
60+
if !ok {
61+
return
62+
}
63+
fmt.Print(response["response"])
64+
65+
case err, ok := <-errorChannel:
66+
if ok && err != nil {
67+
fmt.Println("Error:", err)
68+
} else if !ok {
69+
return
70+
}
71+
}
72+
}
4773
}
4874
```
4975

examples/generate/main.go

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"time"
6+
7+
"github.com/prasad89/golamify/pkg/golamify"
8+
)
9+
10+
func main() {
11+
// Optional config; pass nil for defaults
12+
config := golamify.Config{
13+
OllamaHost: "http://localhost:11434",
14+
Timeout: 30 * time.Second,
15+
}
16+
17+
client, err := golamify.NewClient(&config)
18+
if err != nil {
19+
fmt.Println("Error creating client:", err)
20+
return
21+
}
22+
23+
// Required parameters for Generate; others optional
24+
payload := golamify.GeneratePayload{
25+
Model: "llama3.2:1b",
26+
Prompt: "Why is the sky blue?",
27+
}
28+
29+
responseChannel, errorChannel := golamify.Generate(client, &payload)
30+
31+
for {
32+
select {
33+
case response, ok := <-responseChannel:
34+
if !ok {
35+
return
36+
}
37+
fmt.Print(response["response"])
38+
39+
case err, ok := <-errorChannel:
40+
if ok && err != nil {
41+
fmt.Println("Error:", err)
42+
} else if !ok {
43+
return
44+
}
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)