AttributeError: 'CustomTool' object has no attribute 'fields_set'
Labels: name: auto:bug, name: area: models, name: pydantic

### System Info

python=`3.11`
langchain=`0.0.314`
pydantic=`2.3.0`
pydantic_core=`2.6.3`

### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [x] 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
- [X] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

From the documentation, I can create a fake tool that works as follows:

```python
# Define the tool
class FakeSearchTool(BaseTool):
    name: str | None = "custom_search"
    description: str | None = "useful for when you need to answer questions about current events"

    def _run(
        self, query: str
    ) -> str:
        """Use the tool."""
        print("Query:", query)
        return "Used the tool, and got the answer!"

    async def _arun(
        self, query: str
    ) -> str:
        """Use the tool asynchronously."""
        raise NotImplementedError("custom_search does not support async")
    
# Test if the tool is working
search_tool = FakeSearchTool()
print(search_tool("What is my answer?"))
```

> Query: What is my answer?
> Used the tool, and got the answer!

My case however requires me to give an initial configuration object to every tool, something like this:

```python
from langchain.tools.base import BaseTool

# Create the config class
class Config:
    def __init__(self, init_arg1: str, init_arg2: str):
        self.init_arg1 = init_arg1
        self.init_arg2 = init_arg2

# Create the tool
class FakeSearchTool(BaseTool):
    name: str | None = "custom_search"
    description: str | None = "useful for when you need to answer questions about current events"
    config: Config

    def __init__(self, config: Config):
        self.config = config

    def _run(
        self, query: str
    ) -> str:
        """Use the tool."""
        print("Query:", query)
        print("Obtained config:", self.config.init_arg1, self.config.init_arg2)
        return "Used the tool, and got the answer using the config!"

    async def _arun(
        self, query: str
    ) -> str:
        """Use the tool asynchronously."""
        raise NotImplementedError("custom_search does not support async")
    
# Test if the tool is working
search_tool = FakeSearchTool(
    config=Config(init_arg1="arg1", init_arg2="arg2")
)
print(search_tool("What is my answer?"))
```

However, this does not work and return the following error:
> AttributeError: 'FakeSearchTool' object has no attribute '__fields_set__'

<details>
  <summary>Stack Trace</summary>

```
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/ai-service/notebooks/agent-with-elasticsearch-tool.ipynb Cell 18 line 2
     20         """Use the tool asynchronously."""
     21         raise NotImplementedError("custom_search does not support async")
---> 23 search_tool = FakeSearchTool(
     24     config=Config(init_arg1="arg1", init_arg2="arg2")
     25 )
     26 print(search_tool("What is my answer?"))

/ai-service/notebooks/agent-with-elasticsearch-tool.ipynb Cell 18 line 7
      6 def __init__(self, config: Config):
----> 7     self.config = config

File ~/.pyenv/versions/3.11.5/envs/ai-service/lib/python3.11/site-packages/pydantic/v1/main.py:405, in BaseModel.__setattr__(self, name, value)
    402 else:
    403     self.__dict__[name] = value
--> 405 self.__fields_set__.add(name)

AttributeError: 'FakeSearchTool' object has no attribute '__fields_set__'
```

</details>

### Expected behavior

I expect to get the following output out of the tool:

> Query: What is my answer?
> Obtained config: arg1 arg2
> Used the tool, and got the answer using the config!