forked from langchain-ai/langchain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
community[major], core[patch], langchain[patch], experimental[patch]:…
… Create langchain-community (langchain-ai#14463) Moved the following modules to new package langchain-community in a backwards compatible fashion: ``` mv langchain/langchain/adapters community/langchain_community mv langchain/langchain/callbacks community/langchain_community/callbacks mv langchain/langchain/chat_loaders community/langchain_community mv langchain/langchain/chat_models community/langchain_community mv langchain/langchain/document_loaders community/langchain_community mv langchain/langchain/docstore community/langchain_community mv langchain/langchain/document_transformers community/langchain_community mv langchain/langchain/embeddings community/langchain_community mv langchain/langchain/graphs community/langchain_community mv langchain/langchain/llms community/langchain_community mv langchain/langchain/memory/chat_message_histories community/langchain_community mv langchain/langchain/retrievers community/langchain_community mv langchain/langchain/storage community/langchain_community mv langchain/langchain/tools community/langchain_community mv langchain/langchain/utilities community/langchain_community mv langchain/langchain/vectorstores community/langchain_community mv langchain/langchain/agents/agent_toolkits community/langchain_community mv langchain/langchain/cache.py community/langchain_community mv langchain/langchain/adapters community/langchain_community mv langchain/langchain/callbacks community/langchain_community/callbacks mv langchain/langchain/chat_loaders community/langchain_community mv langchain/langchain/chat_models community/langchain_community mv langchain/langchain/document_loaders community/langchain_community mv langchain/langchain/docstore community/langchain_community mv langchain/langchain/document_transformers community/langchain_community mv langchain/langchain/embeddings community/langchain_community mv langchain/langchain/graphs community/langchain_community mv langchain/langchain/llms community/langchain_community mv langchain/langchain/memory/chat_message_histories community/langchain_community mv langchain/langchain/retrievers community/langchain_community mv langchain/langchain/storage community/langchain_community mv langchain/langchain/tools community/langchain_community mv langchain/langchain/utilities community/langchain_community mv langchain/langchain/vectorstores community/langchain_community mv langchain/langchain/agents/agent_toolkits community/langchain_community mv langchain/langchain/cache.py community/langchain_community ``` Moved the following to core ``` mv langchain/langchain/utils/json_schema.py core/langchain_core/utils mv langchain/langchain/utils/html.py core/langchain_core/utils mv langchain/langchain/utils/strings.py core/langchain_core/utils cat langchain/langchain/utils/env.py >> core/langchain_core/utils/env.py rm langchain/langchain/utils/env.py ``` See .scripts/community_split/script_integrations.sh for all changes
- Loading branch information
Showing
2,616 changed files
with
187,004 additions
and
152,317 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
"libs/core", | ||
"libs/langchain", | ||
"libs/experimental", | ||
"libs/community", | ||
} | ||
|
||
if __name__ == "__main__": | ||
|
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
name: libs/core Release | ||
|
||
on: | ||
workflow_dispatch: # Allows to trigger the workflow manually in GitHub UI | ||
|
||
jobs: | ||
release: | ||
uses: | ||
./.github/workflows/_release.yml | ||
with: | ||
working-directory: libs/core | ||
secrets: inherit |
9 changes: 9 additions & 0 deletions
9
.scripts/community_split/libs/community/langchain_community/__init__.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"""Main entrypoint into package.""" | ||
from importlib import metadata | ||
|
||
try: | ||
__version__ = metadata.version(__package__) | ||
except metadata.PackageNotFoundError: | ||
# Case where package metadata is not available. | ||
__version__ = "" | ||
del metadata # optional, avoids polluting the results of dir(__package__) |
79 changes: 79 additions & 0 deletions
79
.scripts/community_split/libs/community/langchain_community/agent_toolkits/__init__.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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
"""Agent toolkits contain integrations with various resources and services. | ||
LangChain has a large ecosystem of integrations with various external resources | ||
like local and remote file systems, APIs and databases. | ||
These integrations allow developers to create versatile applications that combine the | ||
power of LLMs with the ability to access, interact with and manipulate external | ||
resources. | ||
When developing an application, developers should inspect the capabilities and | ||
permissions of the tools that underlie the given agent toolkit, and determine | ||
whether permissions of the given toolkit are appropriate for the application. | ||
See [Security](https://python.langchain.com/docs/security) for more information. | ||
""" | ||
from langchain_community.agent_toolkits.ainetwork.toolkit import AINetworkToolkit | ||
from langchain_community.agent_toolkits.amadeus.toolkit import AmadeusToolkit | ||
from langchain_community.agent_toolkits.azure_cognitive_services import ( | ||
AzureCognitiveServicesToolkit, | ||
) | ||
from langchain_community.agent_toolkits.conversational_retrieval.openai_functions import ( # noqa: E501 | ||
create_conversational_retrieval_agent, | ||
) | ||
from langchain_community.agent_toolkits.file_management.toolkit import ( | ||
FileManagementToolkit, | ||
) | ||
from langchain_community.agent_toolkits.gmail.toolkit import GmailToolkit | ||
from langchain_community.agent_toolkits.jira.toolkit import JiraToolkit | ||
from langchain_community.agent_toolkits.json.base import create_json_agent | ||
from langchain_community.agent_toolkits.json.toolkit import JsonToolkit | ||
from langchain_community.agent_toolkits.multion.toolkit import MultionToolkit | ||
from langchain_community.agent_toolkits.nasa.toolkit import NasaToolkit | ||
from langchain_community.agent_toolkits.nla.toolkit import NLAToolkit | ||
from langchain_community.agent_toolkits.office365.toolkit import O365Toolkit | ||
from langchain_community.agent_toolkits.openapi.base import create_openapi_agent | ||
from langchain_community.agent_toolkits.openapi.toolkit import OpenAPIToolkit | ||
from langchain_community.agent_toolkits.playwright.toolkit import ( | ||
PlayWrightBrowserToolkit, | ||
) | ||
from langchain_community.agent_toolkits.powerbi.base import create_pbi_agent | ||
from langchain_community.agent_toolkits.powerbi.chat_base import create_pbi_chat_agent | ||
from langchain_community.agent_toolkits.powerbi.toolkit import PowerBIToolkit | ||
from langchain_community.agent_toolkits.slack.toolkit import SlackToolkit | ||
from langchain_community.agent_toolkits.spark_sql.base import create_spark_sql_agent | ||
from langchain_community.agent_toolkits.spark_sql.toolkit import SparkSQLToolkit | ||
from langchain_community.agent_toolkits.sql.base import create_sql_agent | ||
from langchain_community.agent_toolkits.sql.toolkit import SQLDatabaseToolkit | ||
from langchain_community.agent_toolkits.steam.toolkit import SteamToolkit | ||
from langchain_community.agent_toolkits.zapier.toolkit import ZapierToolkit | ||
|
||
|
||
__all__ = [ | ||
"AINetworkToolkit", | ||
"AmadeusToolkit", | ||
"AzureCognitiveServicesToolkit", | ||
"FileManagementToolkit", | ||
"GmailToolkit", | ||
"JiraToolkit", | ||
"JsonToolkit", | ||
"MultionToolkit", | ||
"NasaToolkit", | ||
"NLAToolkit", | ||
"O365Toolkit", | ||
"OpenAPIToolkit", | ||
"PlayWrightBrowserToolkit", | ||
"PowerBIToolkit", | ||
"SlackToolkit", | ||
"SteamToolkit", | ||
"SQLDatabaseToolkit", | ||
"SparkSQLToolkit", | ||
"ZapierToolkit", | ||
"create_json_agent", | ||
"create_openapi_agent", | ||
"create_pbi_agent", | ||
"create_pbi_chat_agent", | ||
"create_spark_sql_agent", | ||
"create_sql_agent", | ||
"create_conversational_retrieval_agent", | ||
] |
88 changes: 88 additions & 0 deletions
88
...community/langchain_community/agent_toolkits/conversational_retrieval/openai_functions.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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Any, List, Optional, TYPE_CHECKING | ||
|
||
from langchain_core.language_models import BaseLanguageModel | ||
from langchain_core.memory import BaseMemory | ||
from langchain_core.messages import SystemMessage | ||
from langchain_core.prompts.chat import MessagesPlaceholder | ||
from langchain_core.tools import BaseTool | ||
|
||
if TYPE_CHECKING: | ||
from langchain.agents.agent import AgentExecutor | ||
|
||
|
||
def _get_default_system_message() -> SystemMessage: | ||
return SystemMessage( | ||
content=( | ||
"Do your best to answer the questions. " | ||
"Feel free to use any tools available to look up " | ||
"relevant information, only if necessary" | ||
) | ||
) | ||
|
||
def create_conversational_retrieval_agent( | ||
llm: BaseLanguageModel, | ||
tools: List[BaseTool], | ||
remember_intermediate_steps: bool = True, | ||
memory_key: str = "chat_history", | ||
system_message: Optional[SystemMessage] = None, | ||
verbose: bool = False, | ||
max_token_limit: int = 2000, | ||
**kwargs: Any, | ||
) -> AgentExecutor: | ||
"""A convenience method for creating a conversational retrieval agent. | ||
Args: | ||
llm: The language model to use, should be ChatOpenAI | ||
tools: A list of tools the agent has access to | ||
remember_intermediate_steps: Whether the agent should remember intermediate | ||
steps or not. Intermediate steps refer to prior action/observation | ||
pairs from previous questions. The benefit of remembering these is if | ||
there is relevant information in there, the agent can use it to answer | ||
follow up questions. The downside is it will take up more tokens. | ||
memory_key: The name of the memory key in the prompt. | ||
system_message: The system message to use. By default, a basic one will | ||
be used. | ||
verbose: Whether or not the final AgentExecutor should be verbose or not, | ||
defaults to False. | ||
max_token_limit: The max number of tokens to keep around in memory. | ||
Defaults to 2000. | ||
Returns: | ||
An agent executor initialized appropriately | ||
""" | ||
from langchain.agents.agent import AgentExecutor | ||
from langchain.agents.openai_functions_agent.agent_token_buffer_memory import ( | ||
AgentTokenBufferMemory, | ||
) | ||
from langchain.agents.openai_functions_agent.base import OpenAIFunctionsAgent | ||
from langchain.memory.token_buffer import ConversationTokenBufferMemory | ||
|
||
if remember_intermediate_steps: | ||
memory: BaseMemory = AgentTokenBufferMemory( | ||
memory_key=memory_key, llm=llm, max_token_limit=max_token_limit | ||
) | ||
else: | ||
memory = ConversationTokenBufferMemory( | ||
memory_key=memory_key, | ||
return_messages=True, | ||
output_key="output", | ||
llm=llm, | ||
max_token_limit=max_token_limit, | ||
) | ||
|
||
_system_message = system_message or _get_default_system_message() | ||
prompt = OpenAIFunctionsAgent.create_prompt( | ||
system_message=_system_message, | ||
extra_prompt_messages=[MessagesPlaceholder(variable_name=memory_key)], | ||
) | ||
agent = OpenAIFunctionsAgent(llm=llm, tools=tools, prompt=prompt) | ||
return AgentExecutor( | ||
agent=agent, | ||
tools=tools, | ||
memory=memory, | ||
verbose=verbose, | ||
return_intermediate_steps=remember_intermediate_steps, | ||
**kwargs, | ||
) |
Oops, something went wrong.