Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument 'bases' has incorrect type #8361

Closed
2 of 14 tasks
coreindustries opened this issue Jul 27, 2023 · 2 comments
Closed
2 of 14 tasks

Argument 'bases' has incorrect type #8361

coreindustries opened this issue Jul 27, 2023 · 2 comments
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@coreindustries
Copy link

coreindustries commented Jul 27, 2023

System Info

Mac, command line and jupyter notebook inside VSCode

Who can help?

No response

Information

  • The official example notebooks/scripts
  • My own modified scripts

Related Components

  • LLMs/Chat Models
  • Embedding Models
  • Prompts / Prompt Templates / Prompt Selectors
  • Output Parsers
  • Document Loaders
  • Vector Stores / Retrievers
  • Memory
  • Agents / Agent Executors
  • Tools / Toolkits
  • Chains
  • Callbacks/Tracing
  • Async

Reproduction

Create a new conda environment
Then

conda install -c conda-forge 'langchain'

pip install openai

Run sample code (can be in jupyter or terminal via a python file):

import os

openai_api_key = os.environ.get("OPENAI_API_KEY")

from langchain.llms import OpenAI
from langchain.chat_models import ChatOpenAI

llm = OpenAI()
chat_model = ChatOpenAI()

llm.predict("hi!")

Get the following error:

TypeError: Argument 'bases' has incorrect type (expected list, got tuple)

Full error output:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[2], line 5
      1 import os
      3 openai_api_key = os.environ.get("OPENAI_API_KEY")
----> 5 from langchain.llms import OpenAI
      6 from langchain.chat_models import ChatOpenAI
      8 llm = OpenAI()

File [~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/__init__.py:6](https://file+.vscode-resource.vscode-cdn.net/Users/coreyszopinski/Documents/projects/core/experiments-transformers/nlp/langchain/~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/__init__.py:6)
      3 from importlib import metadata
      4 from typing import Optional
----> 6 from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain
      7 from langchain.cache import BaseCache
      8 from langchain.chains import (
      9     ConversationChain,
     10     LLMBashChain,
   (...)
     18     VectorDBQAWithSourcesChain,
     19 )

File [~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/agents/__init__.py:2](https://file+.vscode-resource.vscode-cdn.net/Users/coreyszopinski/Documents/projects/core/experiments-transformers/nlp/langchain/~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/agents/__init__.py:2)
      1 """Interface for agents."""
----> 2 from langchain.agents.agent import (
      3     Agent,
      4     AgentExecutor,
      5     AgentOutputParser,
      6     BaseMultiActionAgent,
      7     BaseSingleActionAgent,
      8     LLMSingleActionAgent,
      9 )
     10 from langchain.agents.agent_toolkits import (
     11     create_csv_agent,
     12     create_json_agent,
   (...)
     22     create_xorbits_agent,
     23 )
     24 from langchain.agents.agent_types import AgentType

File [~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/agents/agent.py:16](https://file+.vscode-resource.vscode-cdn.net/Users/coreyszopinski/Documents/projects/core/experiments-transformers/nlp/langchain/~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/agents/agent.py:16)
     13 from pydantic import BaseModel, root_validator
     15 from langchain.agents.agent_types import AgentType
---> 16 from langchain.agents.tools import InvalidTool
     17 from langchain.callbacks.base import BaseCallbackManager
     18 from langchain.callbacks.manager import (
     19     AsyncCallbackManagerForChainRun,
     20     AsyncCallbackManagerForToolRun,
   (...)
     23     Callbacks,
     24 )

File [~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/agents/tools.py:4](https://file+.vscode-resource.vscode-cdn.net/Users/coreyszopinski/Documents/projects/core/experiments-transformers/nlp/langchain/~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/agents/tools.py:4)
      1 """Interface for tools."""
      2 from typing import Optional
----> 4 from langchain.callbacks.manager import (
      5     AsyncCallbackManagerForToolRun,
      6     CallbackManagerForToolRun,
      7 )
      8 from langchain.tools.base import BaseTool, Tool, tool
     11 class InvalidTool(BaseTool):

File [~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/callbacks/__init__.py:3](https://file+.vscode-resource.vscode-cdn.net/Users/coreyszopinski/Documents/projects/core/experiments-transformers/nlp/langchain/~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/callbacks/__init__.py:3)
      1 """Callback handlers that allow listening to events in LangChain."""
----> 3 from langchain.callbacks.aim_callback import AimCallbackHandler
      4 from langchain.callbacks.argilla_callback import ArgillaCallbackHandler
      5 from langchain.callbacks.arize_callback import ArizeCallbackHandler

File [~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/callbacks/aim_callback.py:4](https://file+.vscode-resource.vscode-cdn.net/Users/coreyszopinski/Documents/projects/core/experiments-transformers/nlp/langchain/~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/callbacks/aim_callback.py:4)
      1 from copy import deepcopy
      2 from typing import Any, Dict, List, Optional, Union
----> 4 from langchain.callbacks.base import BaseCallbackHandler
      5 from langchain.schema import AgentAction, AgentFinish, LLMResult
      8 def import_aim() -> Any:

File [~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/callbacks/base.py:7](https://file+.vscode-resource.vscode-cdn.net/Users/coreyszopinski/Documents/projects/core/experiments-transformers/nlp/langchain/~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/callbacks/base.py:7)
      4 from typing import Any, Dict, List, Optional, Sequence, Union
      5 from uuid import UUID
----> 7 from langchain.schema.agent import AgentAction, AgentFinish
      8 from langchain.schema.document import Document
      9 from langchain.schema.messages import BaseMessage

File [~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/schema/__init__.py:2](https://file+.vscode-resource.vscode-cdn.net/Users/coreyszopinski/Documents/projects/core/experiments-transformers/nlp/langchain/~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/schema/__init__.py:2)
      1 from langchain.schema.agent import AgentAction, AgentFinish
----> 2 from langchain.schema.document import BaseDocumentTransformer, Document
      3 from langchain.schema.language_model import BaseLanguageModel
      4 from langchain.schema.memory import BaseChatMessageHistory, BaseMemory

File [~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/schema/document.py:11](https://file+.vscode-resource.vscode-cdn.net/Users/coreyszopinski/Documents/projects/core/experiments-transformers/nlp/langchain/~/anaconda3/envs/core_ml/lib/python3.11/site-packages/langchain/schema/document.py:11)
      6 from pydantic import Field
      8 from langchain.load.serializable import Serializable
---> 11 class Document(Serializable):
     12     """Class for storing a piece of text and associated metadata."""
     14     page_content: str

File [~/anaconda3/envs/core_ml/lib/python3.11/site-packages/pydantic/main.py:186](https://file+.vscode-resource.vscode-cdn.net/Users/coreyszopinski/Documents/projects/core/experiments-transformers/nlp/langchain/~/anaconda3/envs/core_ml/lib/python3.11/site-packages/pydantic/main.py:186), in pydantic.main.ModelMetaclass.__new__()

TypeError: Argument 'bases' has incorrect type (expected list, got tuple)

Expected behavior

Expected sample code to run without errors.

@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Jul 27, 2023
@peterroelants
Copy link

peterroelants commented Jul 28, 2023

Is the version of pydantic installed from conda version 1.10.12 if so, Update your environment and make sure that the full pydantic package name ends with _1.

We had a similar issue:

  • pydantic-1.10.12-py311h459d7ec_0 released 1 day and 17 hours ago gave a similar issue to yours
  • pydantic-1.10.12-py311h459d7ec_1 14 hours and 8 minutes ago did work in our case

Looking at the time of your issue you got caught in between (so did we).

I'm not sure but it looks to me like the pydantic build system pushed a broken package, realized after a day and did a quick fix without bumping the actual version number.

@dosubot
Copy link

dosubot bot commented Oct 27, 2023

Hi, @coreindustries! I'm Dosu, and I'm helping the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

Based on my understanding, the issue titled "Argument 'bases' has incorrect type" is about a TypeError that occurs when running sample code. It seems that the error message indicates that the argument 'bases' has an incorrect type, expecting a list but receiving a tuple. User peterroelants suggests updating the environment and ensuring that the full pydantic package name ends with _1 as a potential solution. They explain that there was a similar issue with the pydantic package and a quick fix was released.

If this issue is still relevant to the latest version of the LangChain repository, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days.

Thank you for your understanding and contribution to the LangChain project!

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Oct 27, 2023
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 3, 2023
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants