Back to packages list

Vals using langchain/schema

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { getModelBuilder } from "https://esm.town/v/bluemsn/getModelBuilder";
export const modelSampleChatCall = (async () => {
const builder = await getModelBuilder({
type: "chat",
provider: "openai",
});
const model = await builder();
const { SystemMessage, HumanMessage } = await import("npm:langchain/schema");
const data = await model.call([
new SystemMessage(
"You are a helpful assistant that translates English to Chinese.",
),
new HumanMessage("Translate: I love programming."),
]);
return data?.content;
})();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { getModelBuilder } from "https://esm.town/v/webup/getModelBuilder";
export const modelSampleChatGenerate = (async () => {
const builder = await getModelBuilder({
type: "chat",
provider: "openai",
});
const model = await builder();
const { SystemMessage, HumanMessage } = await import("npm:langchain/schema");
return await model.generate([
[
new SystemMessage(
"You are a helpful assistant that translates English to Chinese.",
),
new HumanMessage(
"Translate this sentence from English to Chinese. I love programming.",
),
],
[
new SystemMessage(
"You are a helpful assistant that translates English to Chinese.",
),
new HumanMessage(
"Translate this sentence from English to Chinese. I love artificial intelligence.",
),
],
]);
})();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { getModelBuilder } from "https://esm.town/v/webup/getModelBuilder";
export const modelSampleChatCall = (async () => {
const builder = await getModelBuilder({
type: "chat",
provider: "openai",
});
const model = await builder();
const { SystemMessage, HumanMessage } = await import("npm:langchain/schema");
const data = await model.call([
new SystemMessage(
"You are a helpful assistant that translates English to Chinese.",
),
new HumanMessage("Translate: I love programming."),
]);
return data?.content;
})();
1
Next