ollama show 命令执行的一般流程

 

// 命令行(cmd/cmd.go)以 showCmd 为例。
showCmd
    // 1.注册自己的 Handler
    showHandler {

        // 2.通过使用自己的 GO Client(api/client.go) 
        req := api.ShowRequest{Name: args[0]}
        resp, err := client.Show(cmd.Context(), &req)

            // 3.最终调用的服务器 http API(server/routes.go)
            c.do(ctx, http.MethodPost, "/api/show", req, &resp)
                ShowModelHandler {
                  类似 $OLLAMA_MODELS/manifests/7b 文件包含了元信息及blob的digest名字
                  类似 $OLLAMA_MODELS/blobs/sha256-xxxxxxxxx 为具体的各个类型文件,包括 model、lincense 等
                }
    }

 

附:模型相关文件的信息。

$OLLAMA_MODELS/manifests/7b

    {
        "model_format": "gguf",
        "model_family": "qwen2",
        "model_families": [
            "qwen2"
        ],
        "model_type": "7.6B",
        "file_type": "Q4_0",
        "architecture": "amd64",
        "os": "linux",
        "rootfs": {
            "type": "layers",
            "diff_ids": [
                "sha256:43f7a214e5329f672bb05404cfba1913cbb70fdaa1a17497224e1925046b0ed5",
                "sha256:62fbfd9ed093d6e5ac83190c86eec5369317919f4b149598d2dbb38900e9faef",
                "sha256:c156170b718ec29139d3653d40ed1986fd92fb7e0959b5c71f3c48f62e6636f4",
                "sha256:f02dd72bb2423204352eabc5637b44d79d17f109fdb510a7c51455892aa2d216"
            ]
        }
    }

$OLLAMA_MODELS/blobs/sha256-xxxxxxxxx

    {
      "schemaVersion": 2,
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "config": {
        "mediaType": "application/vnd.docker.container.image.v1+json",
        "digest": "sha256:648f809ced2bdb9f26780f2f1cd9b4787804a4796b256ac5c7da05f4fa1729e6",
        "size": 485
      },
      "layers": [
        {
          "mediaType": "application/vnd.ollama.image.model",
          "digest": "sha256:43f7a214e5329f672bb05404cfba1913cbb70fdaa1a17497224e1925046b0ed5",
          "size": 4431388192
        },
        {
          "mediaType": "application/vnd.ollama.image.template",
          "digest": "sha256:62fbfd9ed093d6e5ac83190c86eec5369317919f4b149598d2dbb38900e9faef",
          "size": 182
        },
        {
          "mediaType": "application/vnd.ollama.image.license",
          "digest": "sha256:c156170b718ec29139d3653d40ed1986fd92fb7e0959b5c71f3c48f62e6636f4",
          "size": 11344
        },
        {
          "mediaType": "application/vnd.ollama.image.params",
          "digest": "sha256:f02dd72bb2423204352eabc5637b44d79d17f109fdb510a7c51455892aa2d216",
          "size": 59
        }
      ]
    }

 

Link:https://www.cnblogs.com/farwish/p/18286829

posted on 2024-07-06 01:03  ercom  阅读(95)  评论(0编辑  收藏  举报