当前位置: 首页 > news >正文

【原创】Ollama Test API For Linux/MacOS/Unix

安装Json解析工具

Linux/Unix

sudo apt-get install jq -y

MacOS

brew install jq -y

设置环境变量

export IP="192.168.250.229"
export PORT="8080"
export MODEL="deepseek-r1:7b"

检查Ollama版本

curl http://"$IP":"$PORT"/api/version 

查看Ollama中的模型

curl http://"$IP":"$PORT"/api/tags | jq

为Ollama拉取模型

curl http://"$IP":"$PORT"/api/pull -d '{"model":"'"$MODEL"'"}' 

为Ollama加载模型

curl http://"$IP":"$PORT"/api/chat -d '{
  "model": "'"$MODEL"'",
  "messages": []
}'

让模型响应一下

curl http://"$IP":"$PORT"/api/generate -d '{
  "model": "'"$MODEL"'",
  "prompt":"Why is the sky blue?"
}'

和大模型聊一句(流式处理)

curl http://"$IP":"$PORT"/api/chat -d '{
  "model": "'"$MODEL"'",
  "messages": [
    {
      "role": "user",
      "content": "hello"
    }
  ]
}'

再聊一句(无流式处理)

curl http://"$IP":"$PORT"/api/chat -d '{
  "model": "'"$MODEL"'",
  "messages": [
    {
      "role": "user",
      "content": "hello"
    }
  ],
  "stream": false
}'

当前正在运行的模型

curl http://"$IP":"$PORT"/api/ps | jq

卸载模型

curl http://"$IP":"$PORT"/api/chat -d '{
  "model": "'"$MODEL"'",
  "messages": [],
  "keep_alive": 0
}'

显示模型信息

curl http://"$IP":"$PORT"/api/show -d '{
  "model": "'"$MODEL"'"
}' | jq

删除模型

curl -X DELETE http://"$IP":"$PORT"/api/delete -d '{
  "model": "'"$MODEL"'"
}' 

生成嵌入

curl http://"$IP":"$PORT"/api/embed -d '{
  "model": "nomic-embed-text",
  "input": "Why is the sky blue?"
}'
curl http://"$IP":"$PORT"/api/embeddings -d '{
  "model": "nomic-embed-text",
  "prompt": "Here is an article about llamas..."
}'

相关文章:

  • 飞机大战lua迷你世界脚本
  • 并发编程(线程基础)面试题及原理
  • 老榕树的Java专题:SQL 视图:提升数据处理效率的实用工具
  • IO基础知识和练习
  • 学习路程十二 langchain核心Agent
  • C#释放内存空间的方法
  • Free Auto Clicker - 在任意位置自动重复鼠标点击
  • xss笔记与打靶(更新中)
  • Masscan下载Linux安装
  • Powershell批量压缩并上载CSV数据文件到Box企业云盘
  • 基于Matlab的多目标粒子群优化
  • csrf与ssrf学习笔记
  • 使用WebSocket进行通信的图形用户界面应用程序
  • 004build在设计页面上的使用
  • 长时间目标跟踪算法(3)-GlobalTrack:A Simple and Strong Baseline for Long-termTracking
  • 【蓝桥杯单片机】第十二届省赛
  • 计算机毕业设计SpringBoot+Vue.js航空机票预定系统(源码+文档+PPT+讲解)
  • 信息技术知识赛系统设计与实现(代码+数据库+LW)
  • Metasploit multi/handler 模块高级选项解析
  • 如何在MacOS 10.15上安装Docker Desktop
  • 《缶翁的世界》首发:看吴昌硕等湖州籍书画家的影响
  • 视频丨歼-10CE首次实战大放异彩
  • 特朗普公开“怼”库克:苹果不应在印度生产手机
  • 中国情怀:时代记录与家国镜相|澎湃·镜相第三届非虚构写作大赛暨七猫第六届百万奖金现实题材征文大赛征稿启事
  • 美官方将使用华为芯片视作违反美出口管制行为,外交部回应
  • 《求是》杂志发表习近平总书记重要文章《锲而不舍落实中央八项规定精神,以优良党风引领社风民风》