当前位置: 首页 > 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..."
}'
http://www.dtcms.com/a/48489.html

相关文章:

  • 飞机大战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
  • JUnit 版本影响 Bean 找不到
  • 计算机视觉算法比较
  • Html5学习教程,从入门到精通,HTML5 列表语法知识点及案例代码(11)
  • 准备好了数据集之后,如何在ubuntu22.04上训练一个yolov8模型。
  • [Lc_Notes] hash去重 | find | string逐字符处理 | 栈溢出
  • 解决Docker拉取镜像超时错误,docker: Error response from daemon:
  • SpringBoot快速入门
  • Debian基于Hexo搭建个人博客
  • 最新版AI大模型面试八股文
  • 菜鸟之路Day21一一网络编程