examples clean , code optimize

Signed-off-by: zhanluxianshen <zhanluxianshen@163.com>
This commit is contained in:
zhanluxianshen 2025-03-18 13:25:30 +08:00
parent 021dcf089d
commit 00fec899e9
No known key found for this signature in database
GPG key ID: A835166A5EBC2696
4 changed files with 22 additions and 5 deletions

View file

@ -13,6 +13,9 @@ go run example_name/main.go
- [generate/main.go](generate/main.go)
- [generate-streaming/main.go](generate-streaming/main.go)
## Generate - Generate text from a multimodal
- [multimodal/main.go](multimodal/main.go)
## Pull - Pull a model
- [pull-progress/main.go](pull-progress/main.go)

View file

@ -8,6 +8,11 @@ import (
"github.com/ollama/ollama/api"
)
var (
False = false
True = true
)
func main() {
client, err := api.ClientFromEnvironment()
if err != nil {
@ -18,6 +23,8 @@ func main() {
req := &api.GenerateRequest{
Model: "gemma2",
Prompt: "how many planets are there?",
// set streaming to false
Stream: &True,
}
ctx := context.Background()

View file

@ -8,6 +8,11 @@ import (
"github.com/ollama/ollama/api"
)
var (
False = false
True = true
)
func main() {
client, err := api.ClientFromEnvironment()
if err != nil {
@ -19,7 +24,7 @@ func main() {
Prompt: "how many planets are there?",
// set streaming to false
Stream: new(bool),
Stream: &False,
}
ctx := context.Background()

View file

@ -342,10 +342,12 @@ func RunHandler(cmd *cobra.Command, args []string) error {
if len(info.ProjectorInfo) != 0 {
opts.MultiModal = true
}
for k := range info.ModelInfo {
if strings.Contains(k, ".vision.") {
opts.MultiModal = true
break
if !opts.MultiModal {
for k := range info.ModelInfo {
if strings.Contains(k, ".vision.") {
opts.MultiModal = true
break
}
}
}