主页 > IT业界  > 

【原创】OllamaTestAPIForLinux/MacOS/Unix

【原创】OllamaTestAPIForLinux/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..." }'
标签:

【原创】OllamaTestAPIForLinux/MacOS/Unix由讯客互联IT业界栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“【原创】OllamaTestAPIForLinux/MacOS/Unix