Skip to content

Commit a38f895

Browse files
committed
Rename process->run for Components for consistency with Pipeline
1 parent dfe6d9d commit a38f895

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/neo4j_genai/components/kg_builder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88

99
class DocumentChunker(Component):
10-
async def process(self, text: str) -> dict[str, Any]:
10+
async def run(self, text: str) -> dict[str, Any]:
1111
return {"chunks": [t.strip() for t in text.split(".") if t.strip()]}
1212

1313

1414
class SchemaBuilder(Component):
15-
async def process(self, schema: dict[str, Any]) -> dict[str, Any]:
15+
async def run(self, schema: dict[str, Any]) -> dict[str, Any]:
1616
return {"schema": schema}
1717

1818

@@ -25,7 +25,7 @@ async def _process_chunk(self, chunk: str, schema: str) -> dict[str, Any]:
2525
}
2626
}
2727

28-
async def process(self, chunks: list[str], schema: str) -> dict[str, Any]:
28+
async def run(self, chunks: list[str], schema: str) -> dict[str, Any]:
2929
tasks = [self._process_chunk(chunk, schema) for chunk in chunks]
3030
result = await asyncio.gather(*tasks)
3131
merged_result: dict[str, Any] = {"data": {"entities": [], "relations": []}}
@@ -36,7 +36,7 @@ async def process(self, chunks: list[str], schema: str) -> dict[str, Any]:
3636

3737

3838
class Writer(Component):
39-
async def process(
39+
async def run(
4040
self, entities: dict[str, Any], relations: dict[str, Any]
4141
) -> dict[str, Any]:
4242
return {

src/neo4j_genai/components/rag.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,25 @@ def search(self, *args: Any, **kwargs: Any) -> RetrieverResult:
1616
]
1717
)
1818

19-
async def process(self, query: str) -> dict[str, Any]:
19+
async def run(self, query: str) -> dict[str, Any]:
2020
res = self.search(query)
2121
return {"context": "\n".join(c.content for c in res.items)}
2222

2323

2424
class PromptTemplate(Component):
25-
async def process(self, query: str, context: list[str]) -> dict[str, Any]:
25+
async def run(self, query: str, context: list[str]) -> dict[str, Any]:
2626
return {"prompt": f"my prompt using '{context}', query '{query}'"}
2727

2828

2929
class LLM(Component):
30-
async def process(self, prompt: str) -> dict[str, Any]:
30+
async def run(self, prompt: str) -> dict[str, Any]:
3131
return {"answer": f"some text based on '{prompt}'"}
3232

3333

3434
if __name__ == "__main__":
35+
# retriever = Retriever()
36+
# print(asyncio.run(retriever.run("my context item 1")))
37+
3538
pipe = Pipeline()
3639
pipe.add_component("retrieve", Retriever())
3740
pipe.add_component("augment", PromptTemplate())

src/neo4j_genai/core/pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class RunResult(BaseModel):
4949

5050

5151
class Component:
52-
async def process(self, *args: Any, **kwargs: Any) -> dict[str, Any]:
52+
async def run(self, *args: Any, **kwargs: Any) -> dict[str, Any]:
5353
return {}
5454

5555

@@ -63,7 +63,7 @@ def __init__(self, name: str, component: Component, pipeline: "Pipeline"):
6363
async def execute(self, **kwargs: Any) -> RunResult:
6464
logger.debug(f"Running component {self.name} with {kwargs}")
6565
self.status = RunStatus.RUNNING
66-
res = await self.component.process(**kwargs)
66+
res = await self.component.run(**kwargs)
6767
self.status = RunStatus.DONE
6868
return RunResult(
6969
status=self.status,

0 commit comments

Comments
 (0)