Use a Model with LangChain
A Model is an OpenAI-compatible chat model, so LangChain’s ChatOpenAI calls it. Set FACET_BASE_URL and FACET_API_KEY as in Call a Model.
Python
pip install langchain-openai
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="support-triage",
base_url=os.environ["FACET_BASE_URL"],
api_key=os.environ["FACET_API_KEY"],
)
print(llm.invoke("My card was charged twice").content)
JavaScript
npm install @langchain/openai
import { ChatOpenAI } from "@langchain/openai";
const llm = new ChatOpenAI({
model: "support-triage",
apiKey: process.env.FACET_API_KEY,
configuration: { baseURL: process.env.FACET_BASE_URL },
});
const reply = await llm.invoke("My card was charged twice");
console.log(reply.content);
In a chain
Use the Model where you used a frontier model for this one step, and pass it the input alone. Send only the input. Facet adds the Model’s Instructions to every call, so leave out your own system prompt. A prompt template that adds a system message works against that.
Next steps
- Call a Model: every parameter and header a call takes
- Return structured output: get answers as fields or JSON