Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions netlify/edge-functions/langchain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ChatOpenAI } from "https://esm.sh/langchain/chat_models/openai";
import {
HumanChatMessage,
SystemChatMessage,
} from "https://esm.sh/langchain/schema";

export default async function handler() {
const chat = new ChatOpenAI({ temperature: 0 });
const response = await chat.call([
new SystemChatMessage(
"You are a helpful assistant that translates English to French."
),
new HumanChatMessage("Translate: I love programming."),
]);
console.log(response.text);
return new Response(response.text, {
headers: {
"Content-Type": "text/plain",
},
});
}
export const config = {
path: "/api/langchain",
};