@@ -5,23 +5,30 @@ IFS=$'\n\t'
55
66source " $( dirname " $0 " ) /common.sh"
77
8+ # model.sh - Functions for managing Ollama models in LiteLLM Service
9+ # Each function is responsible for a single aspect of model management.
10+
811function model_select() {
12+ # Lists available Ollama models and prompts user to select one
913 need_cmd ollama
1014 info " Available Ollama models:"
1115 ollama list | awk ' {print NR-1")", $1}' | tail -n +2
1216 echo " "
13- read -p " Enter model name: " CUSTOM_MODEL_NAME
14- export CUSTOM_MODEL_NAME
17+ local model_name
18+ read -p " Enter model name: " model_name
19+ export CUSTOM_MODEL_NAME=" $model_name "
1520 info " Selected model: ${CUSTOM_MODEL_NAME} "
1621}
1722
1823function model_create(){
24+ # Creates a custom Ollama model from a Modelfile
1925 need_cmd ollama
20- local name_arg=" ${1:- } "
21- local file_arg=" ${2:- } "
26+ local name_arg file_arg
27+ name_arg=" ${1:- } "
28+ file_arg=" ${2:- } "
2229
23- if [ -n " ${ name_arg:- } " ]; then CUSTOM_MODEL_NAME=" $name_arg " ; fi
24- if [ -n " ${ file_arg:- } " ]; then CUSTOM_MODEL_FILE=" $file_arg " ; fi
30+ if [ -n " $name_arg " ]; then CUSTOM_MODEL_NAME=" $name_arg " ; fi
31+ if [ -n " $file_arg " ]; then CUSTOM_MODEL_FILE=" $file_arg " ; fi
2532
2633 require_value CUSTOM_MODEL_NAME " Enter model name" " $CUSTOM_MODEL_NAME "
2734 require_value CUSTOM_MODEL_FILE " Enter Modelfile path" " $CUSTOM_MODEL_FILE "
@@ -36,13 +43,15 @@ function model_create(){
3643}
3744
3845function model_test(){
46+ # Tests the custom model by sending a prompt to the Ollama API
3947 need_cmd curl
4048 require_value CUSTOM_MODEL_NAME " Enter model name" " $CUSTOM_MODEL_NAME "
4149 info " Testing custom model '${CUSTOM_MODEL_NAME} '..."
4250 curl -s " $OLLAMA_API_BASE /api/generate" -d " {\n \" model\" : \" ${CUSTOM_MODEL_NAME} \" ,\n \" prompt\" : \" Hello\" \n }" | cat
4351}
4452
4553function model_run(){
54+ # Runs the custom model using Ollama
4655 need_cmd ollama
4756 require_value CUSTOM_MODEL_NAME " Enter model name" " $CUSTOM_MODEL_NAME "
4857 info " Running custom model '${CUSTOM_MODEL_NAME} '..."
0 commit comments