skip to Main Content

I am fresher in the prompt engineering. Suddenly, I am facing a problem in the HuggingFaceInstructEmbeddings. I am using langchain and GoogleGenerativeAI in vscode. My python version 3.10.0 and langchain version 0.1.2. Here is my code-

from langchain_google_genai import GoogleGenerativeAI   
from dotenv import load_dotenv 
import os
from langchain.chains import RetrievalQA
from langchain.document_loaders.csv_loader import CSVLoader    
from langchain_community.embeddings import HuggingFaceInstructEmbeddings
from langchain_community.vectorstores import FAISS

load_dotenv()
google_api_key= os.getenv('GOOGLE_API_KEY')
llm = GoogleGenerativeAI(model="models/text-bison-001", google_api_key=google_api_key, temperature = 0.7)

loader = CSVLoader(file_path="codebasics_faqs.csv", source_column="prompt")
docs = loader.load()

instructor_embeddings = HuggingFaceInstructEmbeddings(
    query_instruction="Represent the query for retrieval: "
)
vectordb = FAISS.from_documents(documents = docs, embeddings = instructor_embeddings)
retriever = vectordb.as_retriever()
rdocs = vectordb.get_relevent_documents("do I get a job gurantee?")
print(rdocs)

This code is showing the following error

File "c:UsersUSERDesktopprojecttut_langchaintut_googleplam.py", line 5, in <module>
    from langchain.document_loaders.csv_loader import CSVLoader
  File "D:Program FilesPython310libsite-packageslangchaindocument_loaderscsv_loader.py", line 1, in <module>
    from langchain_community.document_loaders.csv_loader import (
  File "D:Program FilesPython310libsite-packageslangchain_communitydocument_loaders__init__.py", line 163, in <module>    from langchain_community.document_loaders.pebblo import PebbloSafeLoader
  File "D:Program FilesPython310libsite-packageslangchain_communitydocument_loaderspebblo.py", line 5, in <module>    
    import pwd
ModuleNotFoundError: No module named 'pwd'

So, I don’t understand what should do now? And how to solve this issue.

2

Answers


  1. One solution to avoid the ModuleNotFoundError: No module named ‘pwd’ error is run your python app in a docker container, because pwd only run on unix environments

    Login or Signup to reply.
  2. The pwd module is specific to Unix systems and is not available on Windows.

    If you’re developing on a Windows machine, you could try to use a virtual machine or Docker.

    If your code allows, you could modify the langchain_community package to remove or replace the parts of the code that require the pwd module. However, this could be complex depending on the package’s code.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search