e9e28a5ca8
- Created model files for Qwen3.5 with different context lengths. - Added a new Ansible host variable file for CI server configuration. - Updated GPU server host variables to include Ollama models and model files. - Enhanced playbooks for Podman to manage Ollama models, including copying model files and checking existing models. - Introduced a new playbook for setting up Qwen3.6 with specific configurations. - Updated Windows SSH tasks to improve security and configuration management. - Added a Python utility to parse Ollama model names from command output. - Modified Terraform configurations to include new DNS entries and proxy settings. - Improved Nginx proxy configurations with timeout settings.
58 lines
1.5 KiB
Python
Executable File
58 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Utility to parse ollama ls output and extract model names.
|
|
|
|
Replicates the Jinja2 filter logic from:
|
|
ollama_existing_models.stdout_lines
|
|
| reject('match', '^\\s*$|^(NAME|\\-+)')
|
|
| map('regex_replace', '^\\s*(\\S+)\\s.*', '\\1')
|
|
| list
|
|
|
|
Usage:
|
|
python parse_ollama_models.py < input.txt
|
|
python parse_ollama_models.py models_output.txt
|
|
echo "model_name ..." | python parse_ollama_models.py
|
|
"""
|
|
|
|
import re
|
|
import sys
|
|
|
|
|
|
def parse_ollama_models(lines):
|
|
"""Parse ollama ls output lines and return list of model names."""
|
|
results = []
|
|
for line in lines:
|
|
# Skip empty lines and header rows (NAME, ---)
|
|
if not line.strip() or re.match(r'^(NAME|\-+)$', line.strip()):
|
|
continue
|
|
# Extract the model name (first non-whitespace token)
|
|
match = re.match(r'^\s*(\S+)\s.*', line)
|
|
if match:
|
|
results.append(match.group(1))
|
|
return results
|
|
|
|
|
|
def main():
|
|
# Read input from file argument, stdin, or skip
|
|
if len(sys.argv) > 1:
|
|
with open(sys.argv[1], 'r') as f:
|
|
lines = f.read().splitlines()
|
|
else:
|
|
lines = sys.stdin.read().splitlines()
|
|
|
|
models = parse_ollama_models(lines)
|
|
|
|
# Output: one model per line
|
|
for model in models:
|
|
print(model)
|
|
|
|
# Also write to a JSON file if a second arg is given
|
|
if len(sys.argv) > 2:
|
|
import json
|
|
with open(sys.argv[2], 'w') as f:
|
|
json.dump(models, f, indent=2)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|