Hello all,
I am learning how to code and I am trying to run the class 1 it in Replit. I tried many things such as uninstalling and installing again, even downgrading the python version. The final error seems to be this one:
typeerror: issubclass() arg 1 must be a class
For some reason it doesn’t work at all. The code has the first 32 lines of the training and is hosted here: LangChain_Play - Replit
The code:
import os
import openai
import sys
sys.path.append('../..')
from dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv()) # read local .env file
openai.api_key = os.environ['openai']
#### Import PDFs:
from langchain.document_loaders import PyPDFLoader
loader = PyPDFLoader("docs/cs229_lectures/MachineLearning-Lecture01.pdf") #loaded this specific doc
pages = loader.load()
len(pages) #number of pages
page = pages[0]
print(page.page_content[0:500])
page.metadata
## Youtube
from langchain.document_loaders.generic import GenericLoader
from langchain.document_loaders.parsers import OpenAIWhisperParser
from langchain.document_loaders.blob_loaders.youtube_audio import YoutubeAudioLoader
url="https://www.youtube.com/watch?v=jGwO_UgTS7I"
save_dir="docs/youtube/"
loader = GenericLoader(
YoutubeAudioLoader([url],save_dir),
OpenAIWhisperParser()
)
docs = loader.load()
docs[0].page_content[0:500]
Does someone passed through the same challenge? The full message I receive in the console is the following:
Traceback (most recent call last):
File "main.py", line 12, in <module>
from langchain.document_loaders import PyPDFLoader
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/langchain/__init__.py", line 6, in <module>
from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/langchain/agents/__init__.py", line 2, in <module>
from langchain.agents.agent import (
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/langchain/agents/agent.py", line 16, in <module>
from langchain.agents.tools import InvalidTool
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/langchain/agents/tools.py", line 8, in <module>
from langchain.tools.base import BaseTool, Tool, tool
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/langchain/tools/__init__.py", line 3, in <module>
from langchain.tools.arxiv.tool import ArxivQueryRun
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/langchain/tools/arxiv/tool.py", line 12, in <module>
from langchain.utilities.arxiv import ArxivAPIWrapper
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/langchain/utilities/__init__.py", line 3, in <module>
from langchain.utilities.apify import ApifyWrapper
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/langchain/utilities/apify.py", line 5, in <module>
from langchain.document_loaders import ApifyDatasetLoader
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/langchain/document_loaders/__init__.py", line 43, in <module>
from langchain.document_loaders.embaas import EmbaasBlobLoader, EmbaasLoader
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/langchain/document_loaders/embaas.py", line 54, in <module>
class BaseEmbaasLoader(BaseModel):
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/pydantic/main.py", line 299, in __new__
fields[ann_name] = ModelField.infer(
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/pydantic/fields.py", line 411, in infer
return cls(
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/pydantic/fields.py", line 342, in __init__
self.prepare()
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/pydantic/fields.py", line 456, in prepare
self.populate_validators()
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/pydantic/fields.py", line 670, in populate_validators
*(get_validators() if get_validators else list(find_validators(self.type_, self.model_config))),
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/pydantic/validators.py", line 688, in find_validators
yield make_typeddict_validator(type_, config)
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/pydantic/validators.py", line 582, in make_typeddict_validator
TypedDictModel = create_model_from_typeddict(typeddict_cls, __config__=config)
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/pydantic/annotated_types.py", line 35, in create_model_from_typeddict
return create_model(typeddict_cls.__name__, **kwargs, **field_definitions)
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/pydantic/main.py", line 990, in create_model
return type(__model_name, (__base__,), namespace)
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/pydantic/main.py", line 299, in __new__
fields[ann_name] = ModelField.infer(
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/pydantic/fields.py", line 411, in infer
return cls(
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/pydantic/fields.py", line 342, in __init__
self.prepare()
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/pydantic/fields.py", line 451, in prepare
self._type_analysis()
File "/home/runner/LangChainPlay/venv/lib/python3.10/site-packages/pydantic/fields.py", line 550, in _type_analysis
if issubclass(origin, Tuple): # type: ignore
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/typing.py", line 1158, in __subclasscheck__
return issubclass(cls, self.__origin__)
TypeError: issubclass() arg 1 must be a class
Thank you, really appreciate your help.