mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
### 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.
24 lines
667 B
Python
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
|