llama.cpp作为crewAI的模型后端

环境与版本

  • win10,Python 3.13.7

  • 库版本

    crewai1.5.0
    crewai-tools1.5.0

    langchain-classic1.0.0
    langchain-community0.4.1

    langchain-core1.0.5
    langchain-openai1.0.3

    langchain-text-splitters==1.0.0

  • llama.cpp 下载最新win版本

测试代码

python 复制代码
# test_crewai_minimal.py
import os
from langchain_openai import ChatOpenAI
from crewai import Agent, Task, Crew
from langchain_core.globals import set_debug
set_debug(True)

os.environ["OPENAI_API_BASE"] = "http://127.0.0.1:8080/v1"
os.environ["OPENAI_API_KEY"] = "not-needed"

local_llm = ChatOpenAI(
    model_name="local-model",
    openai_api_base="http://127.0.0.1:8080/v1",
    openai_api_key="not-needed",
    temperature=0.7,
    request_timeout=30,
)

# 3. 创建一个简单的 Agent,并显式指定 LLM
general_agent = Agent(
    role='Simple Agent',
    goal='Just answer a simple question',
    backstory='You are a helpful assistant.',
    verbose=True,
    llm=local_llm # <--- 显式指定
)

# 4. 创建一个简单的 Task
simple_task = Task(
    description="What is the capital of France? Just give the name of the city.",
    expected_output="The name of the city.",
    agent=general_agent
)

# 5. 创建 Crew 并执行
crew = Crew(
    agents=[general_agent],
    tasks=[simple_task],
    verbose=True
)

print("Starting the minimal CrewAI test...")
result = crew.kickoff()
print("\n--- Final Result ---")
print(result)

llama.cpp运行命令:

powershell 复制代码
llama-server -m e:\llama\Qwen3VL-8B-Instruct-Q4_K_M.gguf --no-mmproj-offload --no-warmup --jinja -t 8 -c 4096 -b 1

没有GPU显卡,纯CPU。

正常结果:

llama.cpp后端会有请求和相应:

修改ompletion.py

路径:D:\Python\Lib\site-packages\crewai\llms\providers\openai\completion.py

python 复制代码
"base_url": os.environ["OPENAI_API_BASE"] if self.base_url is None else self.base_url
相关推荐
RuoyiOffice1 天前
llama.cpp + SpringBoot3:本地部署 Qwen3.8,接入 AgentOS 企业办公智能体
spring boot·springboot3·llama.cpp·spring ai·qwen3.8·agentos
AI_Gump5 天前
模型篇|llama.cpp 推理引擎深度解读:从一人练手到 LLM 端侧的事实标准
llama·llama.cpp
张张123y5 天前
2026 Agent 框架怎么选?拆 3 层底层逻辑(运行循环 / 记忆 / 工具协议)+ 一张决策表
linux·ubuntu·microsoft·langgraph·mcp·crewai·agent 框架
智码看视界8 天前
开源大模型追踪:TurboQuant量化指南:128K上下文不再爆显存,KV缓存3-bit免重训
google·开源大模型·llama.cpp·显存优化·长上下文推理·turboquant·本地部署 开源大模型
神奇的代码在哪里12 天前
没有独显也能跑多模态:MiniCPM-V 4.7-1B 本地 OCR 实测(附源码)
ocr·多模态大模型·llama.cpp·gguf·minicpm-v
容沁风13 天前
llama.cpp浏览器访问404
win10·llama.cpp·web-ui
n1121222 天前
4G 显存老显卡怎么跑模型:llama.cpp 加 GGUF 配置
llama·llama.cpp·本地大模型·gguf
半甜柠檬25 天前
llama.cpp 部署 Qwen3.8-27B:无独显轻薄本实测
大模型·qwen·量化·本地部署·llama.cpp
智码看视界1 个月前
开源大模型前沿:Baichuan 5 :单卡 H100 跑国产,长上下文 + 中文 Agentic 硬刚海外同档
开源·中文·llama.cpp·百川智能·国产大模型·baichuan 5
阆遤1 个月前
llama.cpp 0.4.0-dev 本地编译指南
ai·编译·llama.cpp