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

ollama大模型API调用接口

ollama大模型调用:https://github.com/ollama/ollama/tree/main

from langchain_community.llms import Ollama

# 创建Ollama对象
ollama = Ollama(base_url='http://localhost:端口号', model="模型名称")

# 定义对话历史
conversation_history = [{"role": "user", "content": "你是谁"}]

# 发出第一次提问
response = ollama(conversation_history[-1]["content"])

# 打印回答
print(response)

# 更新对话历史
conversation_history.append({"role": "assistant", "content": response})

# 提出新问题并继续对话
conversation_history.append({"role": "user", "content": "你能告诉我人工智能是什么吗?"})
response2 = ollama(conversation_history[-1]["content"])

# 打印新的回答
print(response2)

# 更新对话历史
conversation_history.append({"role": "assistant", "content": response2})

界面效果:
在这里插入图片描述

参考

https://www.jiqizhixin.com/articles/2024-04-23-6
https://www.llamafactory.cn/ollama-docs/api.html
https://blog.csdn.net/2301_81940605/article/details/144659459?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_baidulandingword~default-0-144659459-blog-140815186.235v43pc_blog_bottom_relevance_base3&spm=1001.2101.3001.4242.1&utm_relevant_index=2
https://openatomworkshop.csdn.net/67483ab33a01316874da06fa.html?dp_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6Mzk2ODksImV4cCI6MTczNzI1OTUxMSwiaWF0IjoxNzM2NjU0NzExLCJ1c2VybmFtZSI6IndlaXhpbl80MTE5NDEyOSJ9.EDvFkqP8YvZRR3QKIKRVOS9LWVDvhmf-BefeE-jklGE&spm=1001.2101.3001.6650.4&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Eactivity-4-140267809-blog-140815186.235%5Ev43%5Epc_blog_bottom_relevance_base3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Eactivity-4-140267809-blog-140815186.235%5Ev43%5Epc_blog_bottom_relevance_base3&utm_relevant_index=7
https://gitcode.csdn.net/66c9b64ec618435984a1967a.html?dp_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6Mzk2ODksImV4cCI6MTczNzI1OTUxMSwiaWF0IjoxNzM2NjU0NzExLCJ1c2VybmFtZSI6IndlaXhpbl80MTE5NDEyOSJ9.EDvFkqP8YvZRR3QKIKRVOS9LWVDvhmf-BefeE-jklGE&spm=1001.2101.3001.6650.5&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Eactivity-5-137350055-blog-140815186.235%5Ev43%5Epc_blog_bottom_relevance_base3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Eactivity-5-137350055-blog-140815186.235%5Ev43%5Epc_blog_bottom_relevance_base3&utm_relevant_index=8
https://copilot.tencent.com/chat/?fromSource=gwzcw.9272003.9272003.9272003&utm_medium=cpc&utm_id=gwzcw.9272003.9272003.9272003
https://help.aliyun.com/zh/pai/use-cases/fine-tune-a-llama3-8b-model
https://blog.csdn.net/qq_55068938/article/details/140267809
https://blog.csdn.net/yzj5464/article/details/140815186?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_baidulandingword~default-4-140815186-blog-140267809.235v43pc_blog_bottom_relevance_base3&spm=1001.2101.3001.4242.3&utm_relevant_index=6


http://www.kler.cn/a/500459.html

相关文章:

  • // Error: line 1: XGen: Candidate guides have not been associated!
  • ubuntu22.04 的录屏软件有哪些?
  • Postman接口测试03|执行接口测试、全局变量和环境变量、接口关联、动态参数、断言
  • Web前端界面开发
  • 如何用SQL语句来查询表或索引的行存/列存存储方式|OceanBase 用户问题集锦
  • Spring Boot 和微服务:快速入门指南
  • acwing_3196_I‘m stuck
  • 每天40分玩转Django:问题解答(一)
  • 07-MQ高级
  • mac学习芋道源码记录
  • 性能优化案例:通过增加 shuffle 分区的数量来解决 PySpark 中的数据倾斜
  • 37_Lua运算符
  • Spring Boot 中实现 WebSocket 的方式
  • 并发设计模式 - 优雅终止线程
  • C# OpenCV机器视觉:OCR产品序列号识别
  • 《零基础Go语言算法实战》【题目 2-11】属性的权限
  • net-http-transport 引发的句柄数(协程)泄漏问题
  • 【cocos creator】【ts】事件派发系统
  • 负载均衡原理及算法
  • 是德科技M9010A PXIe 机箱+M9037A模块,台式应用的理想之选
  • iOS 解决两个tableView.嵌套滚动手势冲突
  • 《光学遥感图像中显著目标检测的多内容互补网络》2021-9
  • 深度学习-82-大语言模型LLM之基于langchain加载本地文档向量存储后检索