Define haystack components with pydantic models
Project description
haystack-pydantic
A thin wrapper around haystack Component and Pipeline for typing (outputs) with Pydantic models
from haystack_pydantic import Pipeline
from haystack_pydantic import component
from pydantic import BaseModel
class TestOutput(BaseModel):
output1: str
output2: str
@component
class TestComponent:
# define pydantic model as output type (instead of the `output_types` decorator)
def run(self, input1: str, input2: str) -> TestOutput:
return TestOutput(output1=input1, output2=input2) # return the pydantic model
# use the component standalone
test_component = TestComponent()
test_component.run("input1", "input2") # TestOutput(output1="input1", output2="input2")
# use the component within a pipeline
pipeline = Pipeline()
pipeline.add_component("test_component", test_component)
pipeline.run(data={"input1": "input1", "input2": "input2"}) # {"test_component": TestOutput(output1="input1", output2="input2")}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file haystack_pydantic-0.1.0.tar.gz.
File metadata
- Download URL: haystack_pydantic-0.1.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.10.0 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
372f508c811cdbd88ed3b42f87ff1134c5c0e25ef4897802c0c59364b55bc585
|
|
| MD5 |
485c9b722a48eeb7b6e4e0bf41561fc0
|
|
| BLAKE2b-256 |
61fddd8c0372641bc55aae314dd41411b1534b05db9532fa4ddf88983817cd7a
|
File details
Details for the file haystack_pydantic-0.1.0-py3-none-any.whl.
File metadata
- Download URL: haystack_pydantic-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.10.0 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f70db77f064ecebc5adddd23af360d249041f2fd1aa37a9ef71ca62757cbf2d9
|
|
| MD5 |
beb41c1fe80cf60ff929e768fa5c6889
|
|
| BLAKE2b-256 |
2af7ba7262a6ed5468ccd0b7a4b616d3f197286b4f3ee074d5b750797f9e60b9
|