diff options
author | A.J. Shulman <Shulman.aj@gmail.com> | 2024-12-18 11:46:14 -0500 |
---|---|---|
committer | A.J. Shulman <Shulman.aj@gmail.com> | 2024-12-18 11:46:14 -0500 |
commit | ad1e0cf62187e0f8bbb19b4720b7681585361de9 (patch) | |
tree | 673dd63ddc1808e6e89dab5021c2136cbbe843c8 /extract_code.py | |
parent | 9e447814b551c352709296ae562f1f50480320f5 (diff) |
better
Diffstat (limited to 'extract_code.py')
-rw-r--r-- | extract_code.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/extract_code.py b/extract_code.py new file mode 100644 index 000000000..43e0150e2 --- /dev/null +++ b/extract_code.py @@ -0,0 +1,39 @@ +import os + +# List of files to extract code from, relative to the `src` folder +files = [ + "src/client/views/nodes/chatbot/agentsystem/Agent.ts", + "src/client/views/nodes/chatbot/agentsystem/prompts.ts", + "src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx", + "src/client/views/nodes/chatbot/chatboxcomponents/MessageComponent.tsx", + "src/client/views/nodes/chatbot/response_parsers/AnswerParser.ts", + "src/client/views/nodes/chatbot/response_parsers/StreamedAnswerParser.ts", + "src/client/views/nodes/chatbot/tools/BaseTool.ts", + "src/client/views/nodes/chatbot/tools/CreateAnyDocTool.ts", + "src/client/views/nodes/chatbot/tools/RAGTool.ts", + "src/client/views/nodes/chatbot/tools/SearchTool.ts", + "src/client/views/nodes/chatbot/tools/WebsiteInfoScraperTool.ts", + "src/client/views/nodes/chatbot/types/tool_types.ts", + "src/client/views/nodes/chatbot/types/types.ts", + "src/client/views/nodes/chatbot/vectorstore/Vectorstore.ts", +] + +# Output file name +output_file = "extracted_code.txt" + +def extract_and_format_code(file_list, output_path): + with open(output_path, "w") as outfile: + for file in file_list: + # Since the script runs from the chatbot folder, prepend the relative path from chatbot to src + if os.path.exists(file): + with open(file, "r") as infile: + code = infile.read() + # Write formatted code to the output file + outfile.write(f"--- {file} ---\n\n```\n{code}\n```\n\n") + else: + print(f"File not found: {file}") + +# Run the extraction and formatting +extract_and_format_code(files, output_file) + +print(f"Code extracted and saved to {output_file}") |