Skip to content

Commit

Permalink
Harrison/split schema dir (#7025)
Browse files Browse the repository at this point in the history
should be no functional changes

also keep __init__ exposing a lot for backwards compat

---------

Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
  • Loading branch information
3 people authored Jul 1, 2023
1 parent 556c425 commit 3bfe7cf
Show file tree
Hide file tree
Showing 86 changed files with 1,095 additions and 1,028 deletions.
2 changes: 1 addition & 1 deletion langchain/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
from langchain.schema import (
AgentAction,
AgentFinish,
BaseMessage,
BaseOutputParser,
OutputParserException,
)
from langchain.schema.messages import BaseMessage
from langchain.tools.base import BaseTool
from langchain.utilities.asyncio import asyncio_timeout

Expand Down
2 changes: 1 addition & 1 deletion langchain/agents/agent_toolkits/pandas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from langchain.callbacks.base import BaseCallbackManager
from langchain.chains.llm import LLMChain
from langchain.prompts.base import BasePromptTemplate
from langchain.schema import SystemMessage
from langchain.schema.messages import SystemMessage
from langchain.tools.python.tool import PythonAstREPLTool


Expand Down
2 changes: 1 addition & 1 deletion langchain/agents/agent_toolkits/python/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from langchain.base_language import BaseLanguageModel
from langchain.callbacks.base import BaseCallbackManager
from langchain.chains.llm import LLMChain
from langchain.schema import SystemMessage
from langchain.schema.messages import SystemMessage
from langchain.tools.python.tool import PythonREPLTool


Expand Down
2 changes: 1 addition & 1 deletion langchain/agents/agent_toolkits/sql/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
HumanMessagePromptTemplate,
MessagesPlaceholder,
)
from langchain.schema import AIMessage, SystemMessage
from langchain.schema.messages import AIMessage, SystemMessage


def create_sql_agent(
Expand Down
4 changes: 1 addition & 3 deletions langchain/agents/conversational_chat/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
)
from langchain.schema import (
AgentAction,
AIMessage,
BaseMessage,
BaseOutputParser,
HumanMessage,
)
from langchain.schema.messages import AIMessage, BaseMessage, HumanMessage
from langchain.tools.base import BaseTool


Expand Down
4 changes: 3 additions & 1 deletion langchain/agents/openai_functions_agent/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
from langchain.schema import (
AgentAction,
AgentFinish,
OutputParserException,
)
from langchain.schema.messages import (
AIMessage,
BaseMessage,
FunctionMessage,
OutputParserException,
SystemMessage,
)
from langchain.tools import BaseTool
Expand Down
4 changes: 3 additions & 1 deletion langchain/agents/openai_functions_multi_agent/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
from langchain.schema import (
AgentAction,
AgentFinish,
OutputParserException,
)
from langchain.schema.messages import (
AIMessage,
BaseMessage,
FunctionMessage,
OutputParserException,
SystemMessage,
)
from langchain.tools import BaseTool
Expand Down
3 changes: 2 additions & 1 deletion langchain/base_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

from langchain.callbacks.manager import Callbacks
from langchain.load.serializable import Serializable
from langchain.schema import BaseMessage, LLMResult, PromptValue, get_buffer_string
from langchain.schema import LLMResult, PromptValue
from langchain.schema.messages import BaseMessage, get_buffer_string


def _get_token_ids_default_method(text: str) -> List[int]:
Expand Down
5 changes: 4 additions & 1 deletion langchain/callbacks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
from typing import Any, Dict, List, Optional, Sequence, Union
from uuid import UUID

from langchain.schema import AgentAction, AgentFinish, BaseMessage, Document, LLMResult
from langchain.schema.agent import AgentAction, AgentFinish
from langchain.schema.document import Document
from langchain.schema.messages import BaseMessage
from langchain.schema.output import LLMResult


class RetrieverManagerMixin:
Expand Down
3 changes: 1 addition & 2 deletions langchain/callbacks/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@
from langchain.schema import (
AgentAction,
AgentFinish,
BaseMessage,
Document,
LLMResult,
get_buffer_string,
)
from langchain.schema.messages import BaseMessage, get_buffer_string

logger = logging.getLogger(__name__)
Callbacks = Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]
Expand Down
6 changes: 4 additions & 2 deletions langchain/callbacks/promptlayer_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

from langchain.callbacks.base import BaseCallbackHandler
from langchain.schema import (
ChatGeneration,
LLMResult,
)
from langchain.schema.messages import (
AIMessage,
BaseMessage,
ChatGeneration,
ChatMessage,
HumanMessage,
LLMResult,
SystemMessage,
)

Expand Down
2 changes: 1 addition & 1 deletion langchain/callbacks/tracers/langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
TracerSession,
)
from langchain.env import get_runtime_environment
from langchain.schema import BaseMessage, messages_to_dict
from langchain.schema.messages import BaseMessage, messages_to_dict

logger = logging.getLogger(__name__)
_LOGGED = set()
Expand Down
2 changes: 1 addition & 1 deletion langchain/callbacks/tracers/langchain_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
TracerSessionV1,
TracerSessionV1Base,
)
from langchain.schema import get_buffer_string
from langchain.schema.messages import get_buffer_string
from langchain.utils import raise_for_status_with_text


Expand Down
3 changes: 2 additions & 1 deletion langchain/chains/conversational_retrieval/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
from langchain.chains.llm import LLMChain
from langchain.chains.question_answering import load_qa_chain
from langchain.prompts.base import BasePromptTemplate
from langchain.schema import BaseMessage, BaseRetriever, Document
from langchain.schema import BaseRetriever, Document
from langchain.schema.messages import BaseMessage
from langchain.vectorstores.base import VectorStore

# Depending on the memory type and configuration, the chat history format may differ.
Expand Down
2 changes: 1 addition & 1 deletion langchain/chains/openai_functions/citation_fuzzy_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
PydanticOutputFunctionsParser,
)
from langchain.prompts.chat import ChatPromptTemplate, HumanMessagePromptTemplate
from langchain.schema import HumanMessage, SystemMessage
from langchain.schema.messages import HumanMessage, SystemMessage


class FactWithEvidence(BaseModel):
Expand Down
3 changes: 2 additions & 1 deletion langchain/chains/openai_functions/qa_with_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
)
from langchain.prompts import PromptTemplate
from langchain.prompts.chat import ChatPromptTemplate, HumanMessagePromptTemplate
from langchain.schema import BaseLLMOutputParser, HumanMessage, SystemMessage
from langchain.schema import BaseLLMOutputParser
from langchain.schema.messages import HumanMessage, SystemMessage


class AnswerWithSources(BaseModel):
Expand Down
6 changes: 4 additions & 2 deletions langchain/chat_models/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
from langchain.chat_models.base import BaseChatModel
from langchain.llms.anthropic import _AnthropicCommon
from langchain.schema import (
ChatGeneration,
ChatResult,
)
from langchain.schema.messages import (
AIMessage,
BaseMessage,
ChatGeneration,
ChatMessage,
ChatResult,
HumanMessage,
SystemMessage,
)
Expand Down
4 changes: 1 addition & 3 deletions langchain/chat_models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@
)
from langchain.load.dump import dumpd, dumps
from langchain.schema import (
AIMessage,
BaseMessage,
ChatGeneration,
ChatResult,
HumanMessage,
LLMResult,
PromptValue,
RunInfo,
)
from langchain.schema.messages import AIMessage, BaseMessage, HumanMessage


def _get_verbosity() -> bool:
Expand Down
2 changes: 1 addition & 1 deletion langchain/chat_models/fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from langchain.callbacks.manager import CallbackManagerForLLMRun
from langchain.chat_models.base import SimpleChatModel
from langchain.schema import BaseMessage
from langchain.schema.messages import BaseMessage


class FakeListChatModel(SimpleChatModel):
Expand Down
6 changes: 4 additions & 2 deletions langchain/chat_models/google_palm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
)
from langchain.chat_models.base import BaseChatModel
from langchain.schema import (
ChatGeneration,
ChatResult,
)
from langchain.schema.messages import (
AIMessage,
BaseMessage,
ChatGeneration,
ChatMessage,
ChatResult,
HumanMessage,
SystemMessage,
)
Expand Down
6 changes: 4 additions & 2 deletions langchain/chat_models/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
)
from langchain.chat_models.base import BaseChatModel
from langchain.schema import (
ChatGeneration,
ChatResult,
)
from langchain.schema.messages import (
AIMessage,
BaseMessage,
ChatGeneration,
ChatMessage,
ChatResult,
FunctionMessage,
HumanMessage,
SystemMessage,
Expand Down
3 changes: 2 additions & 1 deletion langchain/chat_models/promptlayer_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
CallbackManagerForLLMRun,
)
from langchain.chat_models import ChatOpenAI
from langchain.schema import BaseMessage, ChatResult
from langchain.schema import ChatResult
from langchain.schema.messages import BaseMessage


class PromptLayerChatOpenAI(ChatOpenAI):
Expand Down
6 changes: 4 additions & 2 deletions langchain/chat_models/vertexai.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
from langchain.chat_models.base import BaseChatModel
from langchain.llms.vertexai import _VertexAICommon, is_codey_model
from langchain.schema import (
AIMessage,
BaseMessage,
ChatGeneration,
ChatResult,
)
from langchain.schema.messages import (
AIMessage,
BaseMessage,
HumanMessage,
SystemMessage,
)
Expand Down
6 changes: 4 additions & 2 deletions langchain/client/runner_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
from langchain.chat_models.base import BaseChatModel
from langchain.llms.base import BaseLLM
from langchain.schema import (
BaseMessage,
ChatResult,
HumanMessage,
LLMResult,
)
from langchain.schema.messages import (
BaseMessage,
HumanMessage,
get_buffer_string,
messages_from_dict,
)
Expand Down
4 changes: 1 addition & 3 deletions langchain/evaluation/agents/trajectory_eval_prompt.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Prompt for trajectory evaluation chain."""
# flake8: noqa
from langchain.schema import AIMessage
from langchain.schema import HumanMessage
from langchain.schema import SystemMessage
from langchain.schema.messages import HumanMessage, AIMessage, SystemMessage

from langchain.prompts.chat import (
ChatPromptTemplate,
Expand Down
4 changes: 1 addition & 3 deletions langchain/experimental/autonomous_agents/autogpt/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
)
from langchain.memory import ChatMessageHistory
from langchain.schema import (
AIMessage,
BaseChatMessageHistory,
Document,
HumanMessage,
SystemMessage,
)
from langchain.schema.messages import AIMessage, HumanMessage, SystemMessage
from langchain.tools.base import BaseTool
from langchain.tools.human.tool import HumanInputRun
from langchain.vectorstores.base import VectorStoreRetriever
Expand Down
2 changes: 1 addition & 1 deletion langchain/experimental/autonomous_agents/autogpt/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from langchain.prompts.chat import (
BaseChatPromptTemplate,
)
from langchain.schema import BaseMessage, HumanMessage, SystemMessage
from langchain.schema.messages import BaseMessage, HumanMessage, SystemMessage
from langchain.tools.base import BaseTool
from langchain.vectorstores.base import VectorStoreRetriever

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Step,
)
from langchain.prompts import ChatPromptTemplate, HumanMessagePromptTemplate
from langchain.schema import SystemMessage
from langchain.schema.messages import SystemMessage

SYSTEM_PROMPT = (
"Let's first understand the problem and devise a plan to solve the problem."
Expand Down
4 changes: 1 addition & 3 deletions langchain/llms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
)
from langchain.load.dump import dumpd
from langchain.schema import (
AIMessage,
BaseMessage,
Generation,
LLMResult,
PromptValue,
RunInfo,
get_buffer_string,
)
from langchain.schema.messages import AIMessage, BaseMessage, get_buffer_string


def _get_verbosity() -> bool:
Expand Down
2 changes: 1 addition & 1 deletion langchain/memory/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from langchain.memory.chat_memory import BaseChatMemory, BaseMemory
from langchain.memory.utils import get_prompt_input_key
from langchain.schema import get_buffer_string
from langchain.schema.messages import get_buffer_string


class ConversationBufferMemory(BaseChatMemory):
Expand Down
2 changes: 1 addition & 1 deletion langchain/memory/buffer_window.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any, Dict, List

from langchain.memory.chat_memory import BaseChatMemory
from langchain.schema import BaseMessage, get_buffer_string
from langchain.schema.messages import BaseMessage, get_buffer_string


class ConversationBufferWindowMemory(BaseChatMemory):
Expand Down
4 changes: 1 addition & 3 deletions langchain/memory/chat_message_histories/cassandra.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@

from langchain.schema import (
BaseChatMessageHistory,
BaseMessage,
_message_to_dict,
messages_from_dict,
)
from langchain.schema.messages import BaseMessage, _message_to_dict, messages_from_dict

DEFAULT_TABLE_NAME = "message_store"
DEFAULT_TTL_SECONDS = None
Expand Down
4 changes: 1 addition & 3 deletions langchain/memory/chat_message_histories/cosmos_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@

from langchain.schema import (
BaseChatMessageHistory,
BaseMessage,
messages_from_dict,
messages_to_dict,
)
from langchain.schema.messages import BaseMessage, messages_from_dict, messages_to_dict

logger = logging.getLogger(__name__)

Expand Down
Loading

0 comments on commit 3bfe7cf

Please sign in to comment.