lyg
2025-04-08 1e85c429ceaad860aba16d1f518160d263c094c0
main.py
@@ -1,6 +1,7 @@
import math
import os
from lang_flow import LangFlow
from markitdown import MarkItDown
from knowledgebase.markitdown import MarkItDown
from doc_to_docx import doc_to_docx
@@ -25,10 +26,10 @@
        if file.endswith(".docx"):
            # 转换为 md
            result = md.convert(dst_dir + file)
            text += '\n\n' + result.text_content
    out_file = dst_dir + 'docs.md'
    with open(out_file, 'w', encoding='utf-8') as f:
        f.write(text)
            text = result.text_content
            out_file = dst_dir + file + '.md'
            with open(out_file, 'w', encoding='utf-8') as f:
                f.write(text)
    return out_file
@@ -36,18 +37,29 @@
# 2.输入文档
# 3.启动LangFlow
def main():
    # doc_dir = "D:\\workspace\\PythonProjects\\KnowledgeBase\\doc\\"
    doc_dir = ".\\doc\\"
    # 处理文档
    # process_docs(doc_dir)
    # 文档转换为markdown
    # md_file = to_markdown(doc_dir)
    md_file = to_markdown(doc_dir)
    md_file = 'D:\\workspace\\PythonProjects\\KnowledgeBase\\doc\\test.md'
    # 启动大模型处理流程
    ret_text = LangFlow([md_file]).run()
    # ret_text = LangFlow([md_file]).run()
    # 保存结果
    # with open('D:\\workspace\\PythonProjects\\KnowledgeBase\\doc\\test.text', 'w', encoding='utf-8') as f:
    #     f.write(ret_text)
def get_bit_mask(start, end):
    bits = math.ceil((end + 1) / 8) * 8
    if bits == 0:
        bits = 8
    mask = 0
    for i in range(start, end + 1):
        mask |= 1 << (bits - i - 1)
    return mask
if __name__ == '__main__':
    main()
    main()