Refactor model loading script and add Ollama notebook

- Updated the Modelfile path in `pull-deepseek-model.sh` to use an absolute path for model files.
- Simplified the model loading process by removing unnecessary directory changes and directly referencing the mounted Modelfile.
- Added a new Jupyter notebook `ollama.ipynb` that demonstrates the usage of the Ollama API with a sample query and error handling for unsupported tools.
This commit is contained in:
2025-06-16 15:41:55 +08:00
parent 3cfd66a31b
commit 23e798bb7c
3 changed files with 5842 additions and 332 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4 -9
View File
@@ -77,7 +77,7 @@ create_modelfile() {
log_info "Creating Modelfile at ${modelfile_path}"
cat > "${modelfile_path}" << EOF
FROM ./${MODEL_FILE}
FROM /models/${MODEL_FILE}
TEMPLATE """{{ if .System }}<|im_start|>system
{{ .System }}<|im_end|>
@@ -106,14 +106,9 @@ EOF
load_model() {
log_info "Loading model into Ollama..."
# Change to models directory for relative path in Modelfile
cd "${MODELS_DIR}"
# Create the model in Ollama
podman exec ollama-server ollama create "${MODEL_NAME}" -f "Modelfile.${MODEL_NAME}"
# Go back to original directory
cd - > /dev/null
# The model files are already mounted in /models/ directory in the container
# Just create the model directly using the mounted Modelfile
podman exec ollama-server ollama create "${MODEL_NAME}" -f "/models/Modelfile.${MODEL_NAME}"
log_info "Model '${MODEL_NAME}' loaded successfully into Ollama"
}