make incremental mode language angostic
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()
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!
is it truly completed?
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!
Why did you close the issue when it has not been completed?