Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More LLM hello world examples: OpenAI Chat, Replicate, HuggingFace #716

Merged
merged 3 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ export const run = async () => {
const model = new Cohere({
temperature: 0.7,
verbose: true,
maxConcurrency: 1,
maxTokens: 20,
maxRetries: 5,
});
const res = await model.call(
"What would be a good company name a company that makes colorful socks?"
"Question: What would be a good company name a company that makes colorful socks?\nAnswer:"
);
console.log("hello", { res });
console.log({ res });
};
14 changes: 14 additions & 0 deletions examples/src/llms/hf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { HuggingFaceInference } from "langchain/llms/hf";

export const run = async () => {
const model = new HuggingFaceInference({
model: "gpt2",
temperature: 0.7,
verbose: true,
maxTokens: 50,
});
const res = await model.call(
"Question: What would be a good company name a company that makes colorful socks?\nAnswer:"
);
console.log({ res });
};
17 changes: 17 additions & 0 deletions examples/src/llms/openai-chat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { OpenAIChat } from "langchain/llms/openai";

export const run = async () => {
const model = new OpenAIChat({
prefixMessages: [
{
role: "system",
content: "You are a helpful assistant that answers in pirate language",
},
],
maxTokens: 50,
});
const res = await model.call(
"What would be a good company name a company that makes colorful socks?"
);
console.log({ res });
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ export const run = async () => {
modelName: "gpt-4",
temperature: 0.7,
verbose: true,
maxConcurrency: 1,
maxTokens: 1000,
maxRetries: 5,
});
const res = await model.call(
"What would be a good company name a company that makes colorful socks?"
"Question: What would be a good company name a company that makes colorful socks?\nAnswer:"
);
console.log("hello", { res });
console.log({ res });
};
12 changes: 12 additions & 0 deletions examples/src/llms/replicate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Replicate } from "langchain/llms/replicate";

export const run = async () => {
const model = new Replicate({
model:
"replicate/flan-t5-xl:3ae0799123a1fe11f8c89fd99632f843fc5f7a761630160521c4253149754523",
});
const res = await model.call(
"Question: What would be a good company name a company that makes colorful socks?\nAnswer:"
);
console.log({ res });
};