5a85070c22
Most of the examples needed updates of Readmes to show how to run them. Some of the requirements.txt files had extra content that wasn't needed, or missing altogether. Apparently some folks like to run npm start to run typescript, so a script was added to all typescript examples which hadn't been done before. Basically just a lot of cleanup. Signed-off-by: Matt Williams <m@technovangelist.com>
25 lines
No EOL
609 B
TypeScript
25 lines
No EOL
609 B
TypeScript
import { Ollama } from 'langchain/llms/ollama';
|
|
import * as readline from "readline";
|
|
|
|
async function main() {
|
|
const ollama = new Ollama({
|
|
model: 'mistral'
|
|
// other parameters can be found at https://js.langchain.com/docs/api/llms_ollama/classes/Ollama
|
|
});
|
|
|
|
const rl = readline.createInterface({
|
|
input: process.stdin,
|
|
output: process.stdout,
|
|
});
|
|
|
|
rl.question("What is your question: \n", async (user_input) => {
|
|
const stream = await ollama.stream(user_input);
|
|
|
|
for await (const chunk of stream) {
|
|
process.stdout.write(chunk);
|
|
}
|
|
rl.close();
|
|
})
|
|
}
|
|
|
|
main(); |