Files
semantic-kernel/python/semantic_kernel/text/function_extension.py
T
Jerome Tremblay 971d2b668b Python: Text partitioning module (#450)
### Motivation and Context
Porting the text partitioning module to python
(Reopening of PR #427 )

### Description

- This is adding the Text partitioning module in
`semantic_kernel/semantic_functions/semantic_text_partitioner.py`
and the function_extention in
`semantic_kernel/semantic_functions/function_extension.py`
- Compared to the C# version the files were added directly into the
`semantic_functions` directory instead of the
`semantic_functions/partitioning` to not have too many nested
directories.
2023-04-26 22:50:24 +00:00

24 lines
667 B
Python

# Copyright (c) Microsoft. All rights reserved.
from typing import List
from semantic_kernel.orchestration.sk_context import SKContext
from semantic_kernel.orchestration.sk_function import SKFunction
async def aggregate_chunked_results_async(
func: SKFunction, chunked_results: List[str], context: SKContext
) -> SKContext:
"""
Aggregate the results from the chunked results.
"""
results = []
for chunk in chunked_results:
context.variables.update(chunk)
context = await func.invoke_async(context=context)
results.append(str(context.variables))
context.variables.update("\n".join(results))
return context