From e60d75228fb161e464ca59fa2526bf0765f4d902 Mon Sep 17 00:00:00 2001 From: lyg <1543117173@qq.com> Date: 星期四, 22 五月 2025 12:35:55 +0800 Subject: [PATCH] 修改指令json生成,加入fastapi --- main.py | 53 ----------------------------------------------------- 1 files changed, 0 insertions(+), 53 deletions(-) diff --git a/main.py b/main.py index 701bf1d..e69de29 100644 --- a/main.py +++ b/main.py @@ -1,53 +0,0 @@ -import os -from lang_flow import LangFlow -from markitdown import MarkItDown - -from doc_to_docx import doc_to_docx - - -def process_docs(directory): - # 閬嶅巻鐩綍涓嬬殑鎵�鏈夋枃浠� - for filename in os.listdir(directory): - # 鍒ゆ柇鏄惁涓� doc 鏂囦欢 - if filename.endswith(".doc"): - # 杞崲涓� docx - doc_to_docx(directory + filename, directory + filename.replace(".doc", ".docx")) - - -md = MarkItDown() - - -def to_markdown(dst_dir: str): - text = '' - # 閬嶅巻鏂囦欢澶逛笅鐨勬墍鏈夋枃浠� - for file in os.listdir(dst_dir): - # 鍒ゆ柇鏄惁涓� docx 鏂囦欢 - 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) - return out_file - - -# 1.瑙f瀽鏂囨。 -# 2.杈撳叆鏂囨。 -# 3.鍚姩LangFlow -def main(): - # doc_dir = "D:\\workspace\\PythonProjects\\KnowledgeBase\\doc\\" - # 澶勭悊鏂囨。 - # process_docs(doc_dir) - # 鏂囨。杞崲涓簃arkdown - # md_file = to_markdown(doc_dir) - - md_file = 'D:\\workspace\\PythonProjects\\KnowledgeBase\\doc\\test.md' - # 鍚姩澶фā鍨嬪鐞嗘祦绋� - 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) - -if __name__ == '__main__': - main() -- Gitblit v1.9.1