feat(projekt-matching): seven Langflow wrapper components
This commit is contained in:
31
projekt-matching/components/pm_rules.py
Normal file
31
projekt-matching/components/pm_rules.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import sys
|
||||
|
||||
if "/app/langflow" not in sys.path:
|
||||
sys.path.insert(0, "/app/langflow")
|
||||
|
||||
from langflow.custom import Component
|
||||
from langflow.io import DataInput, MessageTextInput, Output
|
||||
from langflow.schema import Data
|
||||
|
||||
from projektmatch import stages
|
||||
from projektmatch.config import Cfg
|
||||
|
||||
|
||||
class PMRules(Component):
|
||||
display_name = "PM 4 Rules+Gate"
|
||||
description = ("Deterministisch: Misc-Regeln, Match-Berechnung, "
|
||||
"Beschreibungs-Markdown, Gate > Schwellwert")
|
||||
inputs = [
|
||||
DataInput(name="ctx", display_name="Context"),
|
||||
MessageTextInput(name="threshold", display_name="Threshold",
|
||||
value="PM_THRESHOLD", load_from_db=True,
|
||||
advanced=True),
|
||||
]
|
||||
outputs = [Output(name="out", display_name="Context", method="build_out")]
|
||||
|
||||
def build_out(self) -> Data:
|
||||
cfg = Cfg(threshold=int(self.threshold))
|
||||
ctx = stages.run_stage("rules", stages.stage_rules,
|
||||
dict(self.ctx.data), cfg)
|
||||
self.status = f"{ctx.get('decision')} ({ctx.get('mustMatch')} %)"
|
||||
return Data(data=ctx)
|
||||
Reference in New Issue
Block a user