Windows下ollama + local_LLM + 自编的Agent

Windows下ollama + local_LLM + 自编的Agent
Download Ollama on Windows 到这里直接下载安装 OllamaSetup.exe , 不要irm方式 后面虽然可以任何身份安装但还是右键的 以管理员身份他自动安装找目录建立PATH C:\Users\Administrators----\AppData\Roaming\Microsoft\Windows\Start Menu\Programs , 中间有问答设置上下文的长度等暂时不管后续改设置代码中应该也行这样的窗口出现不用管启动后自动运行后台Task manager可以见进程Ollama第一次在powershell中Ollama serve可以启动 服务检测是否启动(base) PS C:\Users\Administrator----ollama --versionollama listollama version is 0.32.1NAME ID SIZE MODIFIEDqwen2.5:7b 845dbda0ea48 4.7 GB 3 days ago (没pull前这里是没有的)ollama不要用conda方式安装因为比较“installer直接安装“conda的没优化好。后开始进Conda ENV必须 建立新ENV、python版本不能低了。(base) PS C:\Users\Administrator----conda create -n ollama_agent python3.11 -y(base) PS C:\Users\Administrator----conda activate ollama_agent(ollama_agent) pip install langchain langchain-core langchain-ollama langchain-community ollama pydantic pydantic-core openai jupyter notebook 应该一次过注意网络不要乱跑限制其活动LLM pull安装(base)ollama pull qwen2.5:7b 这里不用在ENV下可以任意terminal 去安装大模型代码测试如果是ollama自启动的进程关了terminal单独的独立的窗口启动服务Ollama serve(base) PS C:\Users\Administrator----Ollama serve检测是否显示 sourceroutes.go:2004 msgListening on 127.0.0.1:11434 (version 0.32.1)应答后窗口会显示客户端访问后的 运行记录彩色的一些状态标识编程测试没涉及读写文件文件操作测试 (单独的 llmagent目录下放这些代码)这里代码中通过 WORKSPACE_DIR Path(./sandbox_workspace).resolve() 自动建立目录后读写文件在这个沙盒中超过自动报警。my_ai_project/│├── main_agent_script.py -- You save and run your Python code here└── sandbox_workspace/ -- Automatically created by the script!├── calculator.py -- Code written by the AI agent goes here 创建的 一条问答下└── analytics.py -- Other agent files go here 读后再复写的 第2条问答下