OpenBMB / ChatDev

Create Customized Software using Natural Language Idea (through LLM-powered Multi-Agent Collaboration)
https://arxiv.org/abs/2307.07924
Apache License 2.0
25.65k stars 3.22k forks source link

make incremental mode language angostic #409

Closed realies closed 1 month ago

realies commented 3 months ago

at the moment, it looks for .py files; it can be language agnostic with something like this:

import os
import openai

def _load_from_hardware(self, directory) -> None:
    all_files = [f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f))]

    if len(all_files) == 0:
        raise ValueError(f"No files found in {directory}")

    for filename in all_files:
        file_path = os.path.join(directory, filename)
        with open(file_path, "r", encoding="utf-8") as file:
            content = file.read()

        # Use LLM to identify the language
        language = self._identify_language(content)

        self.codebooks[filename] = {
            'content': self._format_code(content),
            'language': language
        }

    log_visualize(f"{len(self.codebooks)} files read from {directory}")

def _identify_language(self, content):
    prompt = f"Identify the programming language of the following code:\n\n{content[:1000]}"
    response = openai.ChatCompletion.create(
        model="gpt-4-turbo",
        messages=[
            {"role": "system", "content": "You are a code language identifier. Respond with only the name of the programming language."},
            {"role": "user", "content": prompt}
        ]
    )
    return response.choices[0].message.content.strip()
moonlandar commented 3 months ago

Thank you for your support. The default generated software is a Python program, which is usually not recognized as another programming language. However, you can make modifications to the repo according to your needs. Thank you again for your contribution!

realies commented 1 month ago

is it truly completed?

NA-Wen commented 1 month ago

At present, the default generated software is a Python program, so the implementation focuses specifically on handling .py files. Please feel free to make any modifications to the repository as needed, and we would greatly appreciate a pull request. Thank you once again for your valuable contribution!

realies commented 1 month ago

Why did you close the issue when it has not been completed?