LangServe actions
Connect your CopilotKit application to LangChain chains hosted as separate services using LangServe.
Find your CopilotRuntime
The starting point for this section is the CopilotRuntime you set up during quickstart (the CopilotKit backend endpoint).
For a refresher, see Self-Hosting (or alternatively, revisit the quickstart).
First, find your CopilotRuntime instance in your code. You can simply search your codebase for CopilotRuntime.
If you followed the quickstart, it'll be where you set up the /api/copilotkit endpoint.
Modify CopilotRuntime to include LangServe integration
Once you've located your CopilotRuntime, you can add LangServe integration by returning an array of LangServe function sources in the langserve property.
Note that the input and output types of the chain will be automatically fetched from LangServe -- no need to specify them manually!
Here's how to implement LangServe integration:
const runtime = new CopilotRuntime({
// ... existing configuration
langserve: [
{
chainUrl: "http://my-langserve.chain",
name: "performResearch",
description: "Performs research on a given topic.",
},
],
});
// ... rest of your route definitionTest your implementation
After adding the LangServe integration, test it by asking the copilot to perform research on a topic. Observe how it connects to the external LangServe chain and returns the results.
