-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
langchain[patch]: Update some agent tool kits to handle community imp…
…ort as optional (#21157) A few things that were not caught by the migration script
- Loading branch information
Showing
8 changed files
with
251 additions
and
42 deletions.
There are no files selected for viewing
22 changes: 21 additions & 1 deletion
22
libs/langchain/langchain/agents/agent_toolkits/amadeus/toolkit.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
from langchain_community.agent_toolkits.amadeus.toolkit import AmadeusToolkit | ||
from typing import TYPE_CHECKING, Any | ||
|
||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.agent_toolkits.amadeus.toolkit import AmadeusToolkit | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"AmadeusToolkit": "langchain_community.agent_toolkits.amadeus.toolkit" | ||
} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = ["AmadeusToolkit"] |
23 changes: 22 additions & 1 deletion
23
libs/langchain/langchain/agents/agent_toolkits/json/prompt.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
from langchain_community.agent_toolkits.json.prompt import JSON_PREFIX, JSON_SUFFIX | ||
from typing import TYPE_CHECKING, Any | ||
|
||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.agent_toolkits.json.prompt import JSON_PREFIX, JSON_SUFFIX | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"JSON_PREFIX": "langchain_community.agent_toolkits.json.prompt", | ||
"JSON_SUFFIX": "langchain_community.agent_toolkits.json.prompt", | ||
} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = ["JSON_PREFIX", "JSON_SUFFIX"] |
102 changes: 83 additions & 19 deletions
102
libs/langchain/langchain/agents/agent_toolkits/openapi/planner_prompt.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 27 additions & 5 deletions
32
libs/langchain/langchain/agents/agent_toolkits/openapi/prompt.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,29 @@ | ||
from langchain_community.agent_toolkits.openapi.prompt import ( | ||
DESCRIPTION, | ||
OPENAPI_PREFIX, | ||
OPENAPI_SUFFIX, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.agent_toolkits.openapi.prompt import ( | ||
DESCRIPTION, | ||
OPENAPI_PREFIX, | ||
OPENAPI_SUFFIX, | ||
) | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"DESCRIPTION": "langchain_community.agent_toolkits.openapi.prompt", | ||
"OPENAPI_PREFIX": "langchain_community.agent_toolkits.openapi.prompt", | ||
"OPENAPI_SUFFIX": "langchain_community.agent_toolkits.openapi.prompt", | ||
} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = ["OPENAPI_PREFIX", "OPENAPI_SUFFIX", "DESCRIPTION"] |
35 changes: 29 additions & 6 deletions
35
libs/langchain/langchain/agents/agent_toolkits/powerbi/prompt.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 25 additions & 1 deletion
26
libs/langchain/langchain/agents/agent_toolkits/spark_sql/prompt.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,27 @@ | ||
from langchain_community.agent_toolkits.spark_sql.prompt import SQL_PREFIX, SQL_SUFFIX | ||
from typing import TYPE_CHECKING, Any | ||
|
||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.agent_toolkits.spark_sql.prompt import ( | ||
SQL_PREFIX, | ||
SQL_SUFFIX, | ||
) | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"SQL_PREFIX": "langchain_community.agent_toolkits.spark_sql.prompt", | ||
"SQL_SUFFIX": "langchain_community.agent_toolkits.spark_sql.prompt", | ||
} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = ["SQL_PREFIX", "SQL_SUFFIX"] |
32 changes: 27 additions & 5 deletions
32
libs/langchain/langchain/agents/agent_toolkits/sql/prompt.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,29 @@ | ||
from langchain_community.agent_toolkits.sql.prompt import ( | ||
SQL_FUNCTIONS_SUFFIX, | ||
SQL_PREFIX, | ||
SQL_SUFFIX, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.agent_toolkits.sql.prompt import ( | ||
SQL_FUNCTIONS_SUFFIX, | ||
SQL_PREFIX, | ||
SQL_SUFFIX, | ||
) | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"SQL_PREFIX": "langchain_community.agent_toolkits.sql.prompt", | ||
"SQL_SUFFIX": "langchain_community.agent_toolkits.sql.prompt", | ||
"SQL_FUNCTIONS_SUFFIX": "langchain_community.agent_toolkits.sql.prompt", | ||
} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = ["SQL_PREFIX", "SQL_SUFFIX", "SQL_FUNCTIONS_SUFFIX"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters