开发喵星球

Ollama API调用之本地模型操作

Ollama API调用之本地模型操作

查看本地模型列表

GET /api/tags

列出本地可用的模型。

示例

请求

curl http://localhost:11434/api/tags

响应

返回一个JSON对象。

{
  "models": [
    {
      "name": "codellama:13b",
      "modified_at": "2023-11-04T14:56:49.277302595-07:00",
      "size": 7365960935,
      "digest": "9f438cb9cd581fc025612d27f7c1a6669ff83a8bb0ed86c94fcf4c5440555697",
      "details": {
        "format": "gguf",
        "family": "llama",
        "families": null,
        "parameter_size": "13B",
        "quantization_level": "Q4_0"
      }
    },
    {
      "name": "llama3:latest",
      "modified_at": "2023-12-07T09:32:18.757212583-08:00",
      "size": 3825819519,
      "digest": "fe938a131f40e6f6d40083c9f0f430a515233eb2edaa6d72eb85c50d64f2300e",
      "details": {
        "format": "gguf",
        "family": "llama",
        "families": null,
        "parameter_size": "7B",
        "quantization_level": "Q4_0"
      }
    }
  ]
}

显示模型信息

POST /api/show

显示关于模型的信息,包括详细信息、模型文件、模板、参数、许可证和系统提示符。

参数

name :显示模型的名字

示例

请求

curl http://localhost:11434/api/show -d '{
  "name": "llama3"
}'

响应

{
  "modelfile": "# Modelfile generated by \"ollama show\"\n# To build a new Modelfile based on this one, replace the FROM line with:\n# FROM llava:latest\n\nFROM /Users/matt/.ollama/models/blobs/sha256:200765e1283640ffbd013184bf496e261032fa75b99498a9613be4e94d63ad52\nTEMPLATE \"\"\"{{ .System }}\nUSER: {{ .Prompt }}\nASSISTANT: \"\"\"\nPARAMETER num_ctx 4096\nPARAMETER stop \"\u003c/s\u003e\"\nPARAMETER stop \"USER:\"\nPARAMETER stop \"ASSISTANT:\"",
  "parameters": "num_ctx                        4096\nstop                           \u003c/s\u003e\nstop                           USER:\nstop                           ASSISTANT:",
  "template": "{{ .System }}\nUSER: {{ .Prompt }}\nASSISTANT: ",
  "details": {
    "format": "gguf",
    "family": "llama",
    "families": ["llama", "clip"],
    "parameter_size": "7B",
    "quantization_level": "Q4_0"
  }
}

复制模型

POST /api/copy

复制一个模型。从现有模型中使用另一个名称创建模型。

示例

请求

curl http://localhost:11434/api/copy -d '{
  "source": "llama3",
  "destination": "llama3-backup"
}'

响应

如果成功返回200 OK,如果源模型不存在返回404 Not Found。

删除模型

DELETE /api/delete

删除模型及其数据。

示例

请求

curl -X DELETE http://localhost:11434/api/delete -d '{
  "name": "llama3:13b"
}'

响应

如果成功返回200 OK,如果要删除的模型不存在返回404 Not Found。

   
分类:玩技术 作者:荡荡, 浩浩 发表于:2024-05-20 14:06:04 阅读量:166
<<   >>


powered by kaifamiao