跳转至

模型生成

源码

main.go

package main

import (
    "bytes"
    "fmt"
    "io"
    "log"
    "net/http"
    "os"
)

func main() {
    body := []byte(`{"model":"mistral"}`)
    resp, err := http.Post("http://localhost:11434/api/generate", "application/json", bytes.NewBuffer(body))

    if err != nil {
        fmt.Print(err.Error())
        os.Exit(1)
    }

    defer resp.Body.Close()

    responseData, err := io.ReadAll(resp.Body)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(string(responseData))

}

仓库地址

go-http-generate