mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-05 20:58:25 +00:00
Clean warnings: replace type with isinstance and fix syntax (#11219)
Clean warnings: replace type with `isinstance` and fix on notebook syntax syntax
This commit is contained in:
parent
ca5293bf54
commit
748a757306
@ -30,7 +30,6 @@
|
||||
"from langchain.utilities import SerpAPIWrapper\n",
|
||||
"from langchain.utilities import SQLDatabase\n",
|
||||
"from langchain_experimental.sql import SQLDatabaseChain\n",
|
||||
")\n",
|
||||
"from langchain.agents import initialize_agent, Tool\n",
|
||||
"from langchain.agents import AgentType\n",
|
||||
"from langchain.chat_models import ChatOpenAI\n",
|
||||
|
@ -50,7 +50,7 @@ class TimeWeightedVectorStoreRetriever(BaseRetriever):
|
||||
def _document_get_date(self, field: str, document: Document) -> datetime.datetime:
|
||||
"""Return the value of the date field of a document."""
|
||||
if field in document.metadata:
|
||||
if type(document.metadata[field]) == float:
|
||||
if isinstance(document.metadata[field], float):
|
||||
return datetime.datetime.fromtimestamp(document.metadata[field])
|
||||
return document.metadata[field]
|
||||
return datetime.datetime.now()
|
||||
|
@ -147,7 +147,7 @@ class SerpAPIWrapper(BaseModel):
|
||||
answer = {}
|
||||
for key, value in answer_box.items():
|
||||
if not isinstance(value, (list, dict)) and not (
|
||||
type(value) == str and value.startswith("http")
|
||||
isinstance(value, str) and value.startswith("http")
|
||||
):
|
||||
answer[key] = value
|
||||
return str(answer)
|
||||
@ -189,8 +189,8 @@ class SerpAPIWrapper(BaseModel):
|
||||
snippets.append(knowledge_graph["description"])
|
||||
for key, value in knowledge_graph.items():
|
||||
if (
|
||||
type(key) == str
|
||||
and type(value) == str
|
||||
isinstance(key, str)
|
||||
and isinstance(value, str)
|
||||
and key not in ["title", "description"]
|
||||
and not key.endswith("_stick")
|
||||
and not key.endswith("_link")
|
||||
|
@ -790,7 +790,7 @@ async def test_prompt() -> None:
|
||||
assert stream_log[0].ops[0]["value"]["logs"] == []
|
||||
assert stream_log[0].ops[0]["value"]["final_output"] is None
|
||||
assert stream_log[0].ops[0]["value"]["streamed_output"] == []
|
||||
assert type(stream_log[0].ops[0]["value"]["id"]) == str
|
||||
assert isinstance(stream_log[0].ops[0]["value"]["id"], str)
|
||||
|
||||
assert stream_log[1:] == [
|
||||
RunLogPatch(
|
||||
@ -1832,7 +1832,7 @@ async def test_map_astream() -> None:
|
||||
|
||||
assert final_state.state["final_output"] == final_value
|
||||
assert len(final_state.state["streamed_output"]) == len(streamed_chunks)
|
||||
assert type(final_state.state["id"]) == str
|
||||
assert isinstance(final_state.state["id"], str)
|
||||
assert len(final_state.ops) == len(streamed_ops)
|
||||
assert len(final_state.state["logs"]) == 5
|
||||
assert final_state.state["logs"][0]["name"] == "ChatPromptTemplate"
|
||||
|
Loading…
Reference in New Issue
Block a user