feat: add csv output parser (#3483)
* Adds the CSV Output Parser --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
parent
948b150946
commit
8e50f2fdbb
36 changed files with 544 additions and 93 deletions
|
|
@ -0,0 +1,40 @@
|
|||
import os
|
||||
import pytest
|
||||
|
||||
from langflow.components.models.OpenAIModel import OpenAIModelComponent
|
||||
from langflow.components.output_parsers.CSVOutputParser import CSVOutputParserComponent
|
||||
from langflow.components.prompts.Prompt import PromptComponent
|
||||
from tests.integration.utils import ComponentInputHandle, run_single_component
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.api_key_required
|
||||
async def test_csv_output_parser_openai():
|
||||
format_instructions = ComponentInputHandle(
|
||||
clazz=CSVOutputParserComponent,
|
||||
inputs={},
|
||||
output_name="format_instructions",
|
||||
)
|
||||
output_parser_handle = ComponentInputHandle(
|
||||
clazz=CSVOutputParserComponent,
|
||||
inputs={},
|
||||
output_name="output_parser",
|
||||
)
|
||||
prompt_handler = ComponentInputHandle(
|
||||
clazz=PromptComponent,
|
||||
inputs={
|
||||
"template": "List the first five positive integers.\n\n{format_instructions}",
|
||||
"format_instructions": format_instructions,
|
||||
},
|
||||
output_name="prompt",
|
||||
)
|
||||
|
||||
outputs = await run_single_component(
|
||||
OpenAIModelComponent,
|
||||
inputs={
|
||||
"api_key": os.environ["OPENAI_API_KEY"],
|
||||
"output_parser": output_parser_handle,
|
||||
"input_value": prompt_handler,
|
||||
},
|
||||
)
|
||||
assert outputs["text_output"] == "1, 2, 3, 4, 5"
|
||||
Loading…
Add table
Add a link
Reference in a new issue