@@ -18,15 +18,16 @@ func Test_chat_001(t *testing.T) {
1818 }
1919
2020 // Pull the model
21- if err := client .PullModel (context .TODO (), "qwen:0.5b" , ollama .WithPullStatus (func (status * ollama.PullStatus ) {
21+ model , err := client .PullModel (context .TODO (), "qwen:0.5b" , ollama .WithPullStatus (func (status * ollama.PullStatus ) {
2222 t .Log (status )
23- })); err != nil {
23+ }))
24+ if err != nil {
2425 t .FailNow ()
2526 }
2627
2728 t .Run ("ChatStream" , func (t * testing.T ) {
2829 assert := assert .New (t )
29- response , err := client .Chat (context .TODO (), "qwen:0.5b" , client . UserPrompt ("why is the sky blue?" ), ollama .WithChatStream (func (stream * ollama.Response ) {
30+ response , err := client .Chat (context .TODO (), model . MustUserPrompt ("why is the sky blue?" ), ollama .WithStream (func (stream * ollama.Response ) {
3031 t .Log (stream )
3132 }))
3233 if ! assert .NoError (err ) {
@@ -37,7 +38,7 @@ func Test_chat_001(t *testing.T) {
3738
3839 t .Run ("ChatNoStream" , func (t * testing.T ) {
3940 assert := assert .New (t )
40- response , err := client .Chat (context .TODO (), "qwen:0.5b" , client . UserPrompt ("why is the sky green?" ))
41+ response , err := client .Chat (context .TODO (), model . MustUserPrompt ("why is the sky green?" ))
4142 if ! assert .NoError (err ) {
4243 t .FailNow ()
4344 }
@@ -52,16 +53,17 @@ func Test_chat_002(t *testing.T) {
5253 }
5354
5455 // Pull the model
55- if err := client .PullModel (context .TODO (), "llama3.2:1b" , ollama .WithPullStatus (func (status * ollama.PullStatus ) {
56+ model , err := client .PullModel (context .TODO (), "llama3.2:1b" , ollama .WithPullStatus (func (status * ollama.PullStatus ) {
5657 t .Log (status )
57- })); err != nil {
58+ }))
59+ if err != nil {
5860 t .FailNow ()
5961 }
6062
6163 t .Run ("Tools" , func (t * testing.T ) {
6264 assert := assert .New (t )
63- response , err := client .Chat (context .TODO (), "llama3.2:1b" ,
64- client . UserPrompt ("what is the weather in berlin?" ),
65+ response , err := client .Chat (context .TODO (),
66+ model . MustUserPrompt ("what is the weather in berlin?" ),
6567 ollama .WithTool (ollama .MustTool ("get_weather" , "Return weather conditions in a location" , struct {
6668 Location string `help:"Location to get weather for" required:""`
6769 }{})),
@@ -79,16 +81,15 @@ func Test_chat_003(t *testing.T) {
7981 t .FailNow ()
8082 }
8183
82- // Delete model
83- client .DeleteModel (context .TODO (), "llava" )
84-
8584 // Pull the model
86- if err := client .PullModel (context .TODO (), "llava" , ollama .WithPullStatus (func (status * ollama.PullStatus ) {
85+ model , err := client .PullModel (context .TODO (), "llava" , ollama .WithPullStatus (func (status * ollama.PullStatus ) {
8786 t .Log (status )
88- })); err != nil {
87+ }))
88+ if err != nil {
8989 t .FailNow ()
9090 }
9191
92+ // Explain the content of an image
9293 t .Run ("Image" , func (t * testing.T ) {
9394 assert := assert .New (t )
9495
@@ -98,8 +99,8 @@ func Test_chat_003(t *testing.T) {
9899 }
99100 defer f .Close ()
100101
101- response , err := client .Chat (context .TODO (), "llava" ,
102- client . UserPrompt ( "where was this photo taken? " , ollama .WithData (f )),
102+ response , err := client .Chat (context .TODO (),
103+ model . MustUserPrompt ( "describe this photo to me " , ollama .WithData (f )),
103104 )
104105 if ! assert .NoError (err ) {
105106 t .FailNow ()
0 commit comments