diff --git a/examples/src/llm_cohere_concurrency.ts b/examples/src/llms/cohere.ts similarity index 63% rename from examples/src/llm_cohere_concurrency.ts rename to examples/src/llms/cohere.ts index e6c3b954f74d..41226cc86a0c 100644 --- a/examples/src/llm_cohere_concurrency.ts +++ b/examples/src/llms/cohere.ts @@ -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 }); }; diff --git a/examples/src/llms/hf.ts b/examples/src/llms/hf.ts new file mode 100644 index 000000000000..36164818326f --- /dev/null +++ b/examples/src/llms/hf.ts @@ -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 }); +}; diff --git a/examples/src/llms/openai-chat.ts b/examples/src/llms/openai-chat.ts new file mode 100644 index 000000000000..3e536a683e0c --- /dev/null +++ b/examples/src/llms/openai-chat.ts @@ -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 }); +}; diff --git a/examples/src/llm_openai_concurrency.ts b/examples/src/llms/openai.ts similarity index 66% rename from examples/src/llm_openai_concurrency.ts rename to examples/src/llms/openai.ts index 4499b658c85e..817e5b9154c9 100644 --- a/examples/src/llm_openai_concurrency.ts +++ b/examples/src/llms/openai.ts @@ -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 }); }; diff --git a/examples/src/llms/replicate.ts b/examples/src/llms/replicate.ts new file mode 100644 index 000000000000..cce3b6c02af5 --- /dev/null +++ b/examples/src/llms/replicate.ts @@ -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 }); +};