You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Documentation description
Just a relevant example of how to use with node-llama-cpp
Steps include installing node-llama-cpp
installing langchain/community
and here's relevant code:
import { CopilotBackend, LangChainAdapter } from "@copilotkit/backend";
import { ChatLlamaCpp } from "@langchain/community/chat_models/llama_cpp"
const modelPath = ""
const contextLength = 8192
export async function POST(req: Request): Promise<Response> {
const copilotKit = new CopilotBackend();
return await copilotKit.response(
req,
new LangChainAdapter(async (forwardedProps) => {
const model = new ChatLlamaCpp({
modelPath: modelPath,
contextSize: contextLength,
batchSize: contextLength, //weird bug with node-llama-cpp where if batchSize isn't big enough it just crashes.
});
return model.stream(
forwardedProps.messages,
{ tools: forwardedProps.tools }
);
})
);
}
So I'm still currently testing around with this, it might not be fully functional as the LlamaCpp custom Llm form langchain has trouble with tools. Could someone familiar with the matter explain to me where in the code to look to see the downstream effects of failing tool uses.
But it can be a bit challenging to come in there cold. It's a complex part of the codebase (and will actually get more complex in the near as we repurpose the underlying function calling capability to do more and more..).
It might be easiest to test empirically, having 2 identical examples and switching only node-llama-cpp and observing the differences.
I actually think this should live more than just in documentation, but in ready-made adapter factories / instances.
I'd love to collaborate / pair program with you to help you make this first addition of its kind of you are interested. And I can also help you get oriented with tool calls if you want to dig deeper.
I'd love the opportunity to pair program an implementation of some contribution to this project. However I'm not sure this issue would be my first choice. I'll reach out on discord though.
Submitted docs contribution in PR #3359:\nhttps://github.com//pull/3359\n\nWhat was added:\n- New backend guide for using Copilot Runtime with node-llama-cpp via LangChainAdapter.\n- End-to-end setup (dependencies, env, runtime endpoint, frontend runtimeUrl).\n- Added backend nav entry and cross-link from LLM adapters docs.
The backend API referenced here (CopilotBackend, LangChainAdapter from @copilotkit/backend) has been deprecated. The recommended path forward is AG-UI (Agent-User Interaction protocol). See the AG-UI migration guide for the current approach. Closing as outdated.
Activity
mme commentedon Feb 23, 2024
@TimeLordRaps that's awesome, thanks for figuring this out!
Would you mind contributing this to our documentation?
TimeLordRaps commentedon Feb 24, 2024
So I'm still currently testing around with this, it might not be fully functional as the LlamaCpp custom Llm form langchain has trouble with tools. Could someone familiar with the matter explain to me where in the code to look to see the downstream effects of failing tool uses.
ataibarkai commentedon Feb 25, 2024
@TimeLordRaps at a high level the code lives here and here.
But it can be a bit challenging to come in there cold. It's a complex part of the codebase (and will actually get more complex in the near as we repurpose the underlying function calling capability to do more and more..).
It might be easiest to test empirically, having 2 identical examples and switching only
node-llama-cppand observing the differences.I actually think this should live more than just in documentation, but in ready-made
adapterfactories / instances.I'd love to collaborate / pair program with you to help you make this first addition of its kind of you are interested. And I can also help you get oriented with tool calls if you want to dig deeper.
btw, cool username
TimeLordRaps commentedon Feb 25, 2024
I'd love the opportunity to pair program an implementation of some contribution to this project. However I'm not sure this issue would be my first choice. I'll reach out on discord though.
mme commentedon Mar 14, 2024
This would make a great first issue: Add the code to the langchain docs to explain how to use other LLMs.
mitre88 commentedon Mar 4, 2026
Submitted docs contribution in PR #3359:\nhttps://github.com//pull/3359\n\nWhat was added:\n- New backend guide for using Copilot Runtime with node-llama-cpp via LangChainAdapter.\n- End-to-end setup (dependencies, env, runtime endpoint, frontend runtimeUrl).\n- Added backend nav entry and cross-link from LLM adapters docs.
TimeLordRaps commentedon Mar 8, 2026
Thanks for the memories.
jpr5 commentedon Apr 12, 2026
The backend API referenced here (
CopilotBackend,LangChainAdapterfrom@copilotkit/backend) has been deprecated. The recommended path forward is AG-UI (Agent-User Interaction protocol). See the AG-UI migration guide for the current approach. Closing as outdated.fix: stale useCoAgent node name, silent content-part drops, and the L…