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
相关推荐
晨欣2 天前
单卡 48GB 实测:Gemma 4 26B A4B、Gemma 4 31B、gpt-oss-20b 三模型部署与并发对比
google·openai·nvidia·vllm·llama.cpp·gpt-oss-20b·gemma4
belldeep5 天前
AI: ggml llama.cpp 与 BitNet 模型介绍
人工智能·llama.cpp·bitnet·gguf·ggml
YuanDaima204810 天前
[CrewAI] 第15课|构建一个多代理系统来实现自动化简历定制和面试准备
人工智能·python·面试·agent·crewai
love530love13 天前
【独家资源】Windows 本地部署微软 BitNet b1.58: Flash Attention + CUDA GPU 加速 (sm_86) + AVX2 优化 + 1.58bit 量化
人工智能·windows·microsoft·llama.cpp·bitnet·flash attention·bitlinear_cpp
七夜zippoe23 天前
AI Agent 框架选型指南:OpenClaw、LangChain、AutoGPT、CrewAI 深度对比
人工智能·langchain·autogpt·crewai·openclaw
love530love1 个月前
OpenClaw搭配LM Studio VS Ollama:Windows CUDA实战深度对比与完全配置指南
人工智能·windows·vllm·ollama·llama.cpp·lm studio·openclaw
晨欣1 个月前
llama.cpp 设计巧思:多模态模型拆分加载,按需使用视觉能力(配图由谷歌的Nano Banana模型倾情生成)
llm·谷歌·cursor·llama.cpp·gguf模型·gpt5.4
JohnCHsu1 个月前
性能干翻235B,单卡私有化部署OpenClaw
ai·agent·llama.cpp·openclaw
illuspas2 个月前
MI50运行GLM-4.7-Flash的速度测试
glm·llama.cpp·mi50
容沁风2 个月前
openclaw使用本地llama.cpp
llama.cpp·qwen3·openclaw