mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 18:50:33 +00:00
style(core,langchain-classic,openai): fix griffe warnings (#34074)
This commit is contained in:
@@ -903,23 +903,28 @@ class ChatPromptTemplate(BaseChatPromptTemplate):
|
|||||||
5. A string which is shorthand for `("human", template)`; e.g.,
|
5. A string which is shorthand for `("human", template)`; e.g.,
|
||||||
`"{user_input}"`
|
`"{user_input}"`
|
||||||
template_format: Format of the template.
|
template_format: Format of the template.
|
||||||
input_variables: A list of the names of the variables whose values are
|
**kwargs: Additional keyword arguments passed to `BasePromptTemplate`,
|
||||||
required as inputs to the prompt.
|
including (but not limited to):
|
||||||
optional_variables: A list of the names of the variables for placeholder
|
|
||||||
or MessagePlaceholder that are optional.
|
|
||||||
|
|
||||||
These variables are auto inferred from the prompt and user need not
|
- `input_variables`: A list of the names of the variables whose values
|
||||||
provide them.
|
are required as inputs to the prompt.
|
||||||
partial_variables: A dictionary of the partial variables the prompt
|
- `optional_variables`: A list of the names of the variables for
|
||||||
template carries.
|
placeholder or `MessagePlaceholder` that are optional.
|
||||||
|
|
||||||
Partial variables populate the template so that you don't need to pass
|
These variables are auto inferred from the prompt and user need not
|
||||||
them in every time you call the prompt.
|
provide them.
|
||||||
validate_template: Whether to validate the template.
|
|
||||||
input_types: A dictionary of the types of the variables the prompt template
|
|
||||||
expects.
|
|
||||||
|
|
||||||
If not provided, all variables are assumed to be strings.
|
- `partial_variables`: A dictionary of the partial variables the prompt
|
||||||
|
template carries.
|
||||||
|
|
||||||
|
Partial variables populate the template so that you don't need to
|
||||||
|
pass them in every time you call the prompt.
|
||||||
|
|
||||||
|
- `validate_template`: Whether to validate the template.
|
||||||
|
- `input_types`: A dictionary of the types of the variables the prompt
|
||||||
|
template expects.
|
||||||
|
|
||||||
|
If not provided, all variables are assumed to be strings.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
Instantiation from a list of message templates:
|
Instantiation from a list of message templates:
|
||||||
|
|||||||
4
libs/core/uv.lock
generated
4
libs/core/uv.lock
generated
@@ -1,5 +1,5 @@
|
|||||||
version = 1
|
version = 1
|
||||||
revision = 2
|
revision = 3
|
||||||
requires-python = ">=3.10.0, <4.0.0"
|
requires-python = ">=3.10.0, <4.0.0"
|
||||||
resolution-markers = [
|
resolution-markers = [
|
||||||
"python_full_version >= '3.14' and platform_python_implementation == 'PyPy'",
|
"python_full_version >= '3.14' and platform_python_implementation == 'PyPy'",
|
||||||
@@ -1053,7 +1053,7 @@ typing = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "langchain-tests"
|
name = "langchain-tests"
|
||||||
version = "1.0.1"
|
version = "1.0.2"
|
||||||
source = { directory = "../standard-tests" }
|
source = { directory = "../standard-tests" }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "httpx" },
|
{ name = "httpx" },
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class ProgressBarCallback(base_callbacks.BaseCallbackHandler):
|
|||||||
total: The total number of items to be processed.
|
total: The total number of items to be processed.
|
||||||
ncols: The character width of the progress bar.
|
ncols: The character width of the progress bar.
|
||||||
end_with: Last string to print after progress bar reaches end.
|
end_with: Last string to print after progress bar reaches end.
|
||||||
**kwargs: Additional keyword arguments.
|
|
||||||
"""
|
"""
|
||||||
self.total = total
|
self.total = total
|
||||||
self.ncols = ncols
|
self.ncols = ncols
|
||||||
|
|||||||
@@ -295,11 +295,7 @@ def _get_prompt(inputs: dict[str, Any]) -> str:
|
|||||||
|
|
||||||
|
|
||||||
class ChatModelInput(TypedDict):
|
class ChatModelInput(TypedDict):
|
||||||
"""Input for a chat model.
|
"""Input for a chat model."""
|
||||||
|
|
||||||
Args:
|
|
||||||
messages: List of chat messages.
|
|
||||||
"""
|
|
||||||
|
|
||||||
messages: list[BaseMessage]
|
messages: list[BaseMessage]
|
||||||
|
|
||||||
|
|||||||
@@ -108,8 +108,8 @@ class LLMStringRunMapper(StringRunMapper):
|
|||||||
The serialized output text from the first generation.
|
The serialized output text from the first generation.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValueError: If no generations are found in the outputs,
|
ValueError: If no generations are found in the outputs or if the generations
|
||||||
or if the generations are empty.
|
are empty.
|
||||||
"""
|
"""
|
||||||
if not outputs.get("generations"):
|
if not outputs.get("generations"):
|
||||||
msg = "Cannot evaluate LLM Run without generations."
|
msg = "Cannot evaluate LLM Run without generations."
|
||||||
@@ -436,8 +436,8 @@ class StringRunEvaluatorChain(Chain, RunEvaluator):
|
|||||||
The instantiated evaluation chain.
|
The instantiated evaluation chain.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
If the run type is not supported, or if the evaluator requires a
|
ValueError: If the run type is not supported, or if the evaluator requires a
|
||||||
reference from the dataset but the reference key is not provided.
|
reference from the dataset but the reference key is not provided.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# Configure how run inputs/predictions are passed to the evaluator
|
# Configure how run inputs/predictions are passed to the evaluator
|
||||||
|
|||||||
@@ -905,51 +905,6 @@ class AzureChatOpenAI(BaseChatOpenAI):
|
|||||||
!!! note
|
!!! note
|
||||||
`strict` can only be non-null if `method` is `'json_schema'`
|
`strict` can only be non-null if `method` is `'json_schema'`
|
||||||
or `'function_calling'`.
|
or `'function_calling'`.
|
||||||
tools:
|
|
||||||
A list of tool-like objects to bind to the chat model. Requires that:
|
|
||||||
|
|
||||||
- `method` is `'json_schema'` (default).
|
|
||||||
- `strict=True`
|
|
||||||
- `include_raw=True`
|
|
||||||
|
|
||||||
If a model elects to call a
|
|
||||||
tool, the resulting `AIMessage` in `'raw'` will include tool calls.
|
|
||||||
|
|
||||||
??? example
|
|
||||||
|
|
||||||
```python
|
|
||||||
from langchain.chat_models import init_chat_model
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
|
|
||||||
class ResponseSchema(BaseModel):
|
|
||||||
response: str
|
|
||||||
|
|
||||||
|
|
||||||
def get_weather(location: str) -> str:
|
|
||||||
\"\"\"Get weather at a location.\"\"\"
|
|
||||||
pass
|
|
||||||
|
|
||||||
model = init_chat_model("openai:gpt-4o-mini")
|
|
||||||
|
|
||||||
structured_model = model.with_structured_output(
|
|
||||||
ResponseSchema,
|
|
||||||
tools=[get_weather],
|
|
||||||
strict=True,
|
|
||||||
include_raw=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
structured_model.invoke("What's the weather in Boston?")
|
|
||||||
```
|
|
||||||
|
|
||||||
```python
|
|
||||||
{
|
|
||||||
"raw": AIMessage(content="", tool_calls=[...], ...),
|
|
||||||
"parsing_error": None,
|
|
||||||
"parsed": None,
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
kwargs: Additional keyword args are passed through to the model.
|
kwargs: Additional keyword args are passed through to the model.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|||||||
Reference in New Issue
Block a user