mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-09 04:50:37 +00:00
langchain[patch]: Add missing type annotations (#24889)
Adds missing type annotations in preparation for pydantic 2 upgrade.
This commit is contained in:
parent
30f18c7b02
commit
2019e31bc5
@ -1,6 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from typing import Union
|
from typing import Pattern, Union
|
||||||
|
|
||||||
from langchain_core.agents import AgentAction, AgentFinish
|
from langchain_core.agents import AgentAction, AgentFinish
|
||||||
from langchain_core.exceptions import OutputParserException
|
from langchain_core.exceptions import OutputParserException
|
||||||
@ -17,7 +17,7 @@ class ChatOutputParser(AgentOutputParser):
|
|||||||
format_instructions: str = FORMAT_INSTRUCTIONS
|
format_instructions: str = FORMAT_INSTRUCTIONS
|
||||||
"""Default formatting instructions"""
|
"""Default formatting instructions"""
|
||||||
|
|
||||||
pattern = re.compile(r"^.*?`{3}(?:json)?\n(.*?)`{3}.*?$", re.DOTALL)
|
pattern: Pattern = re.compile(r"^.*?`{3}(?:json)?\n(.*?)`{3}.*?$", re.DOTALL)
|
||||||
"""Regex pattern to parse the output."""
|
"""Regex pattern to parse the output."""
|
||||||
|
|
||||||
def get_format_instructions(self) -> str:
|
def get_format_instructions(self) -> str:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from typing import Union
|
from typing import Pattern, Union
|
||||||
|
|
||||||
from langchain_core.agents import AgentAction, AgentFinish
|
from langchain_core.agents import AgentAction, AgentFinish
|
||||||
from langchain_core.exceptions import OutputParserException
|
from langchain_core.exceptions import OutputParserException
|
||||||
@ -42,7 +42,7 @@ class ReActJsonSingleInputOutputParser(AgentOutputParser):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pattern = re.compile(r"^.*?`{3}(?:json)?\n?(.*?)`{3}.*?$", re.DOTALL)
|
pattern: Pattern = re.compile(r"^.*?`{3}(?:json)?\n?(.*?)`{3}.*?$", re.DOTALL)
|
||||||
"""Regex pattern to parse the output."""
|
"""Regex pattern to parse the output."""
|
||||||
|
|
||||||
def get_format_instructions(self) -> str:
|
def get_format_instructions(self) -> str:
|
||||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
from typing import Optional, Union
|
from typing import Optional, Pattern, Union
|
||||||
|
|
||||||
from langchain_core.agents import AgentAction, AgentFinish
|
from langchain_core.agents import AgentAction, AgentFinish
|
||||||
from langchain_core.exceptions import OutputParserException
|
from langchain_core.exceptions import OutputParserException
|
||||||
@ -23,7 +23,7 @@ class StructuredChatOutputParser(AgentOutputParser):
|
|||||||
format_instructions: str = FORMAT_INSTRUCTIONS
|
format_instructions: str = FORMAT_INSTRUCTIONS
|
||||||
"""Default formatting instructions"""
|
"""Default formatting instructions"""
|
||||||
|
|
||||||
pattern = re.compile(r"```(?:json\s+)?(\W.*?)```", re.DOTALL)
|
pattern: Pattern = re.compile(r"```(?:json\s+)?(\W.*?)```", re.DOTALL)
|
||||||
"""Regex pattern to parse the output."""
|
"""Regex pattern to parse the output."""
|
||||||
|
|
||||||
def get_format_instructions(self) -> str:
|
def get_format_instructions(self) -> str:
|
||||||
|
@ -16,7 +16,7 @@ from tests.unit_tests.llms.fake_llm import FakeLLM
|
|||||||
|
|
||||||
|
|
||||||
class DummyLLM(LLM):
|
class DummyLLM(LLM):
|
||||||
last_prompt = ""
|
last_prompt: str = ""
|
||||||
|
|
||||||
def __init__(self, **kwargs: Any):
|
def __init__(self, **kwargs: Any):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user