File tree Expand file tree Collapse file tree 1 file changed +11
-19
lines changed
Expand file tree Collapse file tree 1 file changed +11
-19
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3- from inspect import iscoroutinefunction
43import traceback
54import asyncio
65import configparser
@@ -1758,24 +1757,17 @@ async def process_document(
17581757 content = content_data ["content" ]
17591758
17601759 # Generate chunks from document
1761- if iscoroutinefunction (self .chunking_func ):
1762- chunks = await self .chunking_func (
1763- self .tokenizer ,
1764- content ,
1765- split_by_character ,
1766- split_by_character_only ,
1767- self .chunk_overlap_token_size ,
1768- self .chunk_token_size ,
1769- )
1770- else :
1771- chunks = self .chunking_func (
1772- self .tokenizer ,
1773- content ,
1774- split_by_character ,
1775- split_by_character_only ,
1776- self .chunk_overlap_token_size ,
1777- self .chunk_token_size ,
1778- )
1760+ chunks = self .chunking_func (
1761+ self .tokenizer ,
1762+ content ,
1763+ split_by_character ,
1764+ split_by_character_only ,
1765+ self .chunk_overlap_token_size ,
1766+ self .chunk_token_size ,
1767+ )
1768+ # 判断chunks是否是异步异步函数的返回
1769+ if asyncio .iscoroutine (chunks ):
1770+ chunks = await chunks
17791771 chunks : dict [str , Any ] = {
17801772 compute_mdhash_id (dp ["content" ], prefix = "chunk-" ): {
17811773 ** dp ,
You can’t perform that action at this time.
0 commit comments