-
hey folks!
both of them call openai functions at the end my questions are:
[
{
"name": "_OutputFormatter",
"description": "Output formatter. Should always be used to format your response to the user.",
"parameters": {
"title": "_OutputFormatter",
"description": "Output formatter. Should always be used to format your response to the user.",
"type": "object",
"properties": {
"output": {
... actual function definition
}
},
"required": [
"output"
]
}
}
] thanks :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
🤖 Hello! Let's go through your questions one by one:
I hope this helps! Let me know if you have any other questions. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
ended up writing my custom version: from typing import Type
from langchain.chains import LLMChain
from langchain.chains.openai_functions import create_openai_fn_chain
from langchain.output_parsers.openai_functions import PydanticOutputFunctionsParser
from langchain.pydantic_v1 import BaseModel
def create_structured_output_chain_custom(
output_schema: Type[BaseModel],
llm,
prompt,
*,
output_key: str = "function",
output_parser=None,
**kwargs,
) -> LLMChain:
output_parser = output_parser or PydanticOutputFunctionsParser(pydantic_schema=output_schema)
return create_openai_fn_chain(
[output_schema],
llm,
prompt,
output_key=output_key,
output_parser=output_parser,
**kwargs,
) |
Beta Was this translation helpful? Give feedback.
🤖
Hello!
Let's go through your questions one by one:
The
create_extraction_chain_pydantic
andcreate_structured_output_chain
functions in LangChain both serve to structure the output of language models, but they do so in slightly different ways.The
create_extraction_chain_pydantic
function is used to create a chain that extracts information from a passage using a Pydantic schema. It takes in a Pydantic schema, a language model, a prompt, and a verbosity flag. The function then creates a chain that can be used to extract information from a passage based on the provided Pydantic schema. You can find more details about this function in the extraction.py file.On the other hand, the
create…