add langchain examples

This commit is contained in:
Jeffrey Morgan 2023-08-09 11:49:22 -07:00
parent 820f95c4c4
commit 55aa4aaf0f
10 changed files with 79 additions and 1 deletions

View file

@ -1,6 +1,6 @@
# Examples
This directory contains examples that can be created and run with `ollama`.
This directory contains different examples of using Ollama
To create a model:

View file

@ -0,0 +1,15 @@
# LangChain Web Summarization
This example summarizes a website
## Setup
```
pip install -r requirements.txt
```
## Run
```
python main.py
```

View file

@ -0,0 +1,12 @@
from langchain.llms import Ollama
from langchain.document_loaders import WebBaseLoader
from langchain.chains.summarize import load_summarize_chain
loader = WebBaseLoader("https://ollama.ai/blog/run-llama2-uncensored-locally")
docs = loader.load()
llm = Ollama(model="llama2")
chain = load_summarize_chain(llm, chain_type="stuff")
result = chain.run(docs)
print(result)

View file

@ -0,0 +1,2 @@
langchain==0.0.259
bs4==0.0.1

View file

@ -0,0 +1,15 @@
# LangChain Web Summarization
This example summarizes a website
## Setup
```
pip install -r requirements.txt
```
## Run
```
python main.py
```

View file

@ -0,0 +1,12 @@
from langchain.llms import Ollama
from langchain.document_loaders import WebBaseLoader
from langchain.chains.summarize import load_summarize_chain
loader = WebBaseLoader("https://ollama.ai/blog/run-llama2-uncensored-locally")
docs = loader.load()
llm = Ollama(model="llama2")
chain = load_summarize_chain(llm, chain_type="stuff")
result = chain.run(docs)
print(result)

View file

@ -0,0 +1,2 @@
langchain==0.0.259
bs4==0.0.1

View file

@ -0,0 +1,15 @@
# LangChain
This example is a basic "hello world" of using LangChain with Ollama.
## Setup
```
pip install -r requirements.txt
```
## Run
```
python main.py
```

View file

@ -0,0 +1,4 @@
from langchain.llms import Ollama
llm = Ollama(model="llama2")
res = llm.predict("hi!")
print (res)

View file

@ -0,0 +1 @@
langchain==0.0.259