"vscode:/vscode.git/clone" did not exist on "8b4371f70fb5e791f4467a30375ef226bc5186a9"
Commit fc6b49be authored by Matt Williams's avatar Matt Williams
Browse files

add ts alternate to python langchain simplegen


Signed-off-by: default avatarMatt Williams <m@technovangelist.com>
parent 615f7d1d
# LangChain
This example is a basic "hello world" of using LangChain with Ollama using NodeJS and Typescript.
## Setup
```
npm install
```
## Run
```
ts-node main.ts
```
Running this example will print the response for "hello":
```
Hello! It's nice to meet you. hopefully you are having a great day! Is there something I can help you with or would you like to chat?
```
import { Ollama} from 'langchain/llms/ollama';
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 stream = await ollama.stream("Hello");
for await (const chunk of stream) {
process.stdout.write(chunk);
}
}
main();
\ No newline at end of file
{
"devDependencies": {
"typescript": "^5.2.2"
},
"dependencies": {
"langchain": "^0.0.165"
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment