mirror of
https://github.com/hwchase17/langchain
synced 2024-11-18 09:25:54 +00:00
ed58eeb9c5
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
69 lines
1.8 KiB
Python
69 lines
1.8 KiB
Python
from typing import List, Optional, Type
|
|
|
|
from langchain_core.callbacks import CallbackManagerForToolRun
|
|
from langchain_core.pydantic_v1 import BaseModel, Field
|
|
|
|
from langchain_community.tools.office365.base import O365BaseTool
|
|
|
|
|
|
class CreateDraftMessageSchema(BaseModel):
|
|
"""Input for SendMessageTool."""
|
|
|
|
body: str = Field(
|
|
...,
|
|
description="The message body to include in the draft.",
|
|
)
|
|
to: List[str] = Field(
|
|
...,
|
|
description="The list of recipients.",
|
|
)
|
|
subject: str = Field(
|
|
...,
|
|
description="The subject of the message.",
|
|
)
|
|
cc: Optional[List[str]] = Field(
|
|
None,
|
|
description="The list of CC recipients.",
|
|
)
|
|
bcc: Optional[List[str]] = Field(
|
|
None,
|
|
description="The list of BCC recipients.",
|
|
)
|
|
|
|
|
|
class O365CreateDraftMessage(O365BaseTool):
|
|
"""Tool for creating a draft email in Office 365."""
|
|
|
|
name: str = "create_email_draft"
|
|
description: str = (
|
|
"Use this tool to create a draft email with the provided message fields."
|
|
)
|
|
args_schema: Type[CreateDraftMessageSchema] = CreateDraftMessageSchema
|
|
|
|
def _run(
|
|
self,
|
|
body: str,
|
|
to: List[str],
|
|
subject: str,
|
|
cc: Optional[List[str]] = None,
|
|
bcc: Optional[List[str]] = None,
|
|
run_manager: Optional[CallbackManagerForToolRun] = None,
|
|
) -> str:
|
|
# Get mailbox object
|
|
mailbox = self.account.mailbox()
|
|
message = mailbox.new_message()
|
|
|
|
# Assign message values
|
|
message.body = body
|
|
message.subject = subject
|
|
message.to.add(to)
|
|
if cc is not None:
|
|
message.cc.add(cc)
|
|
if bcc is not None:
|
|
message.bcc.add(bcc)
|
|
|
|
message.save_draft()
|
|
|
|
output = "Draft created: " + str(message)
|
|
return output
|