Skip to content

Commit cce99d7

Browse files
fixed more lint issues
1 parent 9186081 commit cce99d7

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

langchain_minds/tools.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""AIMind tool."""
22

33
import os
4-
from typing import Any, Dict, List, Optional, Text
4+
from typing import Any, Dict, List, Optional, Text, Union
55

66
import openai
77
from langchain_core.callbacks import (
@@ -16,12 +16,17 @@
1616

1717

1818
class AIMindEnvVar:
19-
def __init__(self, name, is_secret=False):
19+
"""
20+
The loader for environment variables used by the AIMindTool.
21+
"""
22+
23+
value: Union[Text, SecretStr]
24+
25+
def __init__(self, name: Text, is_secret: bool = False) -> None:
2026
if is_secret:
2127
self.value = convert_to_secret_str(os.environ[name])
2228
else:
2329
self.value = os.environ[name]
24-
self.is_secret = is_secret
2530

2631

2732
class AIMindDataSource(BaseModel):
@@ -100,10 +105,12 @@ def __init__(self, **data: Any) -> None:
100105

101106
# Convert the parameters set as environment variables to the actual values.
102107
connection_data = {}
103-
for key, value in self.connection_data.items():
108+
for key, value in (self.connection_data or {}).items():
104109
if isinstance(value, AIMindEnvVar):
105110
connection_data[key] = (
106-
value.value.get_secret_value() if value.is_secret else value.value
111+
value.value.get_secret_value()
112+
if isinstance(value.value, SecretStr)
113+
else value.value
107114
)
108115
else:
109116
connection_data[key] = value
@@ -188,7 +195,7 @@ def __init__(self, **data: Any) -> None:
188195
mind = minds_client.minds.create(name=self.name)
189196

190197
# Add the data sources to the Mind.
191-
for data_source in self.datasources:
198+
for data_source in self.datasources or []:
192199
mind.add_datasource(data_source.name)
193200

194201
def run(self, query: Text) -> Text:

0 commit comments

Comments
 (0)