微信扫码
添加专属顾问
我要投稿
Gradio github:https://github.com/gradio-app/gradio
1. curl -fsSL https://ollama.com/install.sh | sh2. ollama pull llama3.1:8b
如果想了解详细的安装过程,请看此篇:
【干货】手把手教你搭建Ollama+OpenWebUI
source ~/miniconda3/bin/activateconda create -n charbot_1 python=3.12
完成后继续以下指令,在虚拟环境中安装Gradio 。
conda activate charbot_1pip install gradio
import requests
import json
import gradio as gr
url = "http://localhost:11434/api/generate"
headers = {
'Content-Type': 'application/json'
}
conversation_history = []
def generate_response(prompt):
conversation_history.append(prompt)
full_prompt = "\n".join(conversation_history)
data = {
"model": "llama3.1:8b",
"stream": False,
"prompt": full_prompt
}
response =requests.post(url, headers=headers, data=json.dumps(data))
if response.status_code == 200:
response_txt = response.text
data = json.loads(response_txt)
actual_response = data["response"]
conversation_history.append(actual_response)
return actual_response
else:
print("Error:", response.status_code, response.text)
iface = gr.Interface(
fn=generate_response,
inputs=["text"],
outputs=["text"]
)
if __name__ == "__main__":
iface.launch()
1. 先运行 ollama 把模型启动,在终端中运行
ollama run llama3.1:8B
2. 另开一个终端,进入python虚拟环境运行 charbot_1
python3 charbot_1
3. 在浏览器中打开
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2025-09-05
Rokid Glasses优化设想
2025-09-02
AI硬件的Aha Moment到了吗?
2025-09-02
AI录音卡片大比拼:一文讲懂谁更值得买
2025-09-02
为什么钉钉、360也要入局AI录音卡片?被种草之后一个反思:虽然很好用,但Rabbit R1的致命问题依旧存在
2025-08-28
一款让人欲罢不能的AI硬件
2025-08-25
我用飞书表格,实现门店的多屏的无人化管理
2025-08-25
钉钉发布首款 AI 硬件,CEO 首谈加班争议,「无招」的大招是给每个打工人配 AI 秘书
2025-08-23
前美团硬件负责人创业,做了一款项链式的「AI相机」|涌现NewThings
2025-07-08
2025-06-28
2025-07-04
2025-06-25
2025-07-03
2025-06-15
2025-07-07
2025-07-22
2025-07-08
2025-09-02
2025-09-02
2025-08-15
2025-07-08
2025-07-08
2025-05-27
2025-05-24
2025-05-17
2025-05-14