Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ structure:
#!/bin/bash
echo "Hello, {{@ author_name @}}!"
- LICENSE:
file: https://raw.githubusercontent.com/nishanths/license/master/LICENSE
remote_file: https://raw.githubusercontent.com/nishanths/license/master/LICENSE
- src/main.py:
content: |
print("Hello, World!")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ structure:
#!/bin/bash
echo "Hello, {{@ author_name @}}!"
- LICENSE:
file: https://raw.githubusercontent.com/nishanths/license/master/LICENSE
remote_file: https://raw.githubusercontent.com/nishanths/license/master/LICENSE
- src/main.py:
content: |
print("Hello, World!")
Expand Down
27 changes: 19 additions & 8 deletions struct_module/file_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, properties):
self.name = properties.get("name")
self.file_directory = self._get_file_directory()
self.content = properties.get("content")
self.remote_location = properties.get("file")
self.content_location = properties.get("file")
self.permissions = properties.get("permissions")

self.system_prompt = properties.get("system_prompt") or properties.get("global_system_prompt")
Expand Down Expand Up @@ -69,13 +69,24 @@ def process_prompt(self, dry_run=False):
self.logger.debug(f"Generated content: {self.content}")

def fetch_content(self):
if self.remote_location:
self.logger.debug(f"Fetching content from: {self.remote_location}")
response = requests.get(self.remote_location)
self.logger.debug(f"Response status code: {response.status_code}")
response.raise_for_status()
self.content = response.text
self.logger.debug(f"Fetched content: {self.content}")
if self.content_location:
self.logger.debug(f"Fetching content from: {self.content_location}")

if self.content_location.startswith("file://"):
file_path = self.content_location[len("file://"):]
with open(file_path, 'r') as file:
self.content = file.read()
self.logger.debug(f"Fetched content from local file: {self.content}")

elif self.content_location.startswith("https://"):
response = requests.get(self.content_location)
self.logger.debug(f"Response status code: {response.status_code}")
response.raise_for_status()
self.content = response.text
self.logger.debug(f"Fetched content from URL: {self.content}")

else:
self.logger.warning(f"Unsupported protocol in content_location: {self.content_location}")

def _merge_default_template_vars(self, template_vars):
default_vars = {
Expand Down