微信扫码
添加专属顾问
我要投稿
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 requestsimport jsonimport gradio as grurl = "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.textdata = json.loads(response_txt)actual_response = data["response"]conversation_history.append(actual_response)return actual_responseelse: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. 在浏览器中打开
--THE END-- 
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2026-03-20
748GB内存、20P算力,英伟达把数据中心塞进了桌子底下,第一台已经送到Karpathy家里
2026-03-19
All in AI后,手机正在被“反噬”?
2026-03-19
EdgeClaw Box:在养虾潮的安全焦虑中,推开 OPC 时代的大门
2026-03-17
在 AI 替你干活之前,Violoop 先给它装一个物理刹车
2026-03-17
2个小时的英伟达 GTC 都在这了,但我好像再也兴奋不起来了?
2026-03-16
探展绿联:原生内嵌 MiniMax,OpenClaw 开箱即用,AI NAS 正在破圈
2026-03-10
小团队高效能:Android Studio 中的 Gemini 助 Ultrahuman 实现 15% 研发提速
2026-03-10
从Siri到字节AI手机,再到Xiaomi miclaw:你的AI管家来了
2026-01-29
2026-01-13
2025-12-28
2025-12-22
2025-12-31
2025-12-23
2025-12-21
2026-01-02
2025-12-23
2026-01-03