-
Notifications
You must be signed in to change notification settings - Fork 16k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
8 additions
and
10 deletions.
There are no files selected for viewing
10 changes: 5 additions & 5 deletions
10
...ain_core/language_models/output_format.py → ...core/language_models/structured_output.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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
from abc import ABC, abstractmethod | ||
from typing import Any, Generic, TypeVar | ||
from typing import Any, Dict, Generic, TypeVar, Union | ||
|
||
from langchain_core.language_models import LanguageModelInput | ||
from langchain_core.pydantic_v1 import BaseModel | ||
from langchain_core.runnables import Runnable | ||
|
||
_OutputSchema = TypeVar("_OutputSchema") | ||
_FormattedOutput = TypeVar("_FormattedOutput") | ||
|
||
|
||
class FormattedOutputMixin(Generic[_OutputSchema, _FormattedOutput], ABC): | ||
class StructuredOutputMixin(Generic[_OutputSchema], ABC): | ||
"""Mixin for language models that offer native output formatting.""" | ||
|
||
@abstractmethod | ||
def with_output_format( | ||
def with_structured_output( | ||
self, schema: _OutputSchema, **kwargs: Any | ||
) -> Runnable[LanguageModelInput, _FormattedOutput]: | ||
) -> Runnable[LanguageModelInput, Union[Dict, BaseModel]]: | ||
"""Implement this if there is a way of steering the model to generate responses that match a given schema.""" # noqa: E501 |
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