diff options
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}") |