There are multiple, but similar demos on how to set up using RAG with llama on the internet. With following line (similar in each example),
vectorstore = Chroma.from_documents(documents=doc_splits, embedding=embeddings)
I get the following error:
ValueError: Error raised by inference endpoint: HTTPConnectionPool(host='localhost', port=11434):
Max retries exceeded with url: /api/embeddings
(Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000020C9FD056A0>:
Failed to establish a new connection: [WinError 10061]
No connection could be made because the target machine actively refused it'))
Another person reported something similar here I keep getting this value error when creating Ollama Embedding and the answer does not work.
My current code is as follows:
import os
os.environ["LANGCHAIN_TRACING_V2"] = "true"
os.environ["LANGCHAIN_ENDPOINT"] = "https://api.smith.langchain.com"
os.environ["LANGCHAIN_API_KEY"] = "mykey"
local_llm = "llama3"
from langchain_community.document_loaders import WebBaseLoader
from langchain_community.vectorstores import Chroma
from langchain_nomic.embeddings import NomicEmbeddings
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_community.embeddings import OllamaEmbeddings
urls = [
"https://lilianweng.github.io/posts/2023-06-23-agent/",
"https://lilianweng.github.io/posts/2023-03-15-prompt-engineering/",
"https://lilianweng.github.io/posts/2023-10-25-adv-attack-llm/",
]
docs = [WebBaseLoader(url).load() for url in urls]
docs_list = [item for sublist in docs for item in sublist]
text_splitter = RecursiveCharacterTextSplitter.from_tiktoken_encoder(
chunk_size=250, chunk_overlap=0
)
doc_splits = text_splitter.split_documents(docs_list)
embeddings = OllamaEmbeddings(model="llama3")
vectorstore = Chroma.from_documents(documents=doc_splits, embedding=embeddings)
# Add to vectorDB
#vectorstore = Chroma.from_documents(
# documents=doc_splits,
# collection_name="rag-chroma",
# embedding=#NomicEmbeddings(model="nomic-embed-text-v1.5", inference_mode="local"),
#)
retriever = vectorstore.as_retriever()
1