Skip to content

Commit

Permalink
feat(backend): allow setting fetch repository
Browse files Browse the repository at this point in the history
- add AUTOGGUF_BACKEND_REPO environment variable to set GitHub repo to fetch releases
- remove Import Model confirmation
- fix error when deleting models from list
- add localizations and update README with message
  • Loading branch information
leafspark committed Jan 27, 2025
1 parent a0d00ab commit 93daedc
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 22 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ AUTOGGUF_SERVER=enabled
AUTOGGUF_SERVER_PORT=7001
AUTOGGUF_SERVER_API_KEY=
AUTOGGUF_LANGUAGE=en-US
AUTOGGUF_BACKEND_REPO=ggerganov/llama.cpp
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ cd build/<type>/dist/
pip install -U pyinstaller
build RELEASE | DEV
```
Find the executable in `build/<type>/dist/AutoGGUF.exe`.
Find the executable in `build/<type>/dist/AutoGGUF-x64.exe`.

You can also use Nuitka, which may result in a slower build but a faster output executable:
```bash
Expand All @@ -139,18 +139,21 @@ To use a specific language, set the `AUTOGGUF_LANGUAGE` environment variable to
## Issues

- Some inconsistent logging
- Missing translations

## Planned Features

- Time estimation for quantization
- Quantization file size estimate
- Perplexity testing
- bitsandbytes (coming soon)
- bitsandbytes

Due to my limited availability and a lack of time, I won't be actively developing new features for this project as much. While I'll continue to publish builds from time to time, I strongly recommend running from source if you want to stay up to date with the latest changes. I'm still committed to keeping dependencies updated weekly and making small maintenance fixes to ensure everything runs smoothly. If you run into any problems or notice issues, please don't hesitate to let me know - I appreciate your feedback and will do my best to address them.

## Support

- SSL module cannot be found error: Install OpenSSL or run from source using `python src/main.py` with the `run.bat` script (`pip install requests`)
- Check out the [Wiki](https://github.com/leafspark/AutoGGUF/wiki) for advanced usage
- Check out the [Wiki](https://github.com/leafspark/AutoGGUF/wiki) for advanced usage and configuration

## Contributing

Expand Down
18 changes: 5 additions & 13 deletions src/AutoGGUF.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ def delete_model(self, item):
reply = QMessageBox.question(
self,
CONFIRM_DELETE,
DELETE_WARNING.format(model_name),
DELETE_MODEL_WARNING.format(model_name),
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No,
)
Expand All @@ -1142,7 +1142,7 @@ def delete_model(self, item):
)
self.logger.info(MODEL_DELETED_SUCCESSFULLY.format(model_name))
except Exception as e:
show_error(self.logger, f"Error deleting model: {e}")
show_error(self.logger, ERROR_DELETING_MODEL.format(e))

def check_for_updates(self) -> None:
try:
Expand Down Expand Up @@ -1929,17 +1929,9 @@ def import_model(self) -> None:
show_error(self.logger, INVALID_GGUF_FILE.format(file_name))
return

reply = QMessageBox.question(
self,
CONFIRM_IMPORT,
IMPORT_MODEL_CONFIRMATION.format(file_name),
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No,
)
if reply == QMessageBox.StandardButton.Yes:
self.imported_models.append(file_path)
self.load_models()
self.logger.info(MODEL_IMPORTED_SUCCESSFULLY.format(file_name))
self.imported_models.append(file_path)
self.load_models()
self.logger.info(MODEL_IMPORTED_SUCCESSFULLY.format(file_name))

@validate_input(
"imatrix_model", "imatrix_datafile", "imatrix_model", "imatrix_output"
Expand Down
10 changes: 8 additions & 2 deletions src/Localizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ def __init__(self):
# Model actions
self.CONFIRM_DELETE = "Confirm Delete"
self.DELETE_MODEL_WARNING = "Are you sure you want to delete the model: {}?"
self.ERROR_DELETING_MODEL = "Error deleting model: {}"
self.MODEL_RENAMED_SUCCESSFULLY = "Model renamed successfully."
self.MODEL_DELETED_SUCCESSFULLY = "Model deleted successfully."

Expand Down Expand Up @@ -451,12 +452,17 @@ def __init__(self):
self.HF_REPOSITORY_TYPE = "Repository Type"
self.UPLOAD_TYPE = "Upload Type"
self.UPLOAD = "Upload"
self.INFO = "Info"

self.EXTRA_COMMAND_ARGUMENTS = "Additional command-line arguments"

self.INFO = "Info"
self.COPIED_COMMAND_TO_CLIPBOARD = "Copied command to clipboard:"

# Repository
self.INVALID_REPOSITORY_FORMAT = (
"Invalid repository format. Must be 'owner/repo'"
)
self.REPO_CANNOT_BE_EMPTY = "Owner and repository name cannot be empty"


class _French(_Localization):
def __init__(self):
Expand Down
25 changes: 21 additions & 4 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,35 @@ def download_llama_cpp(self) -> None:
self.download_progress.setValue(0)


def get_repo_from_env() -> tuple[str, str]:
repo = os.getenv("AUTOGGUF_BACKEND_REPO", "ggerganov/llama.cpp")

if not repo or "/" not in repo:
raise ValueError(INVALID_REPOSITORY_FORMAT)

owner, repo_name = repo.split("/", 1)
if not all(part.strip() for part in (owner, repo_name)):
raise ValueError(REPO_CANNOT_BE_EMPTY)

return owner, repo_name


def refresh_releases(self) -> None:
self.logger.info(REFRESHING_LLAMACPP_RELEASES)
try:
response = requests.get(
"https://api.github.com/repos/ggerganov/llama.cpp/releases"
)
response.raise_for_status() # Raise an exception for bad status codes
owner, repo = get_repo_from_env()
url = f"https://api.github.com/repos/{owner}/{repo}/releases"

response = requests.get(url)
response.raise_for_status()

releases = response.json()
self.release_combo.clear()
for release in releases:
self.release_combo.addItem(release["tag_name"], userData=release)
self.release_combo.currentIndexChanged.connect(self.update_assets)
self.update_assets()
except ValueError as e:
show_error(self.logger, f"Invalid repository configuration: {str(e)}")
except requests.exceptions.RequestException as e:
show_error(self.logger, ERROR_FETCHING_RELEASES.format(str(e)))

0 comments on commit 93daedc

Please sign in to comment.