# SPDX-FileCopyrightText: Amolith # # SPDX-License-Identifier: Unlicense # llxprt agent definition for synu # Provides model configuration for routing through Synthetic API # llxprt only accepts configuration via CLI flags # Source cache functions source (status dirname)/../_synu_cache.fish # Fallback default (used when no cache entry exists) set -g _synu_llxprt_fallback_model "hf:zai-org/GLM-4.6" function _synu_llxprt_default --description "Get default model" set -l cached (_synu_cache_get llxprt model) if test $status -eq 0 echo $cached else echo $_synu_llxprt_fallback_model end end function _synu_agent_llxprt_flags --description "Return argparse-compatible flag specification" echo "m/model=" end function _synu_agent_llxprt_configure --description "Configure llxprt model selection" # Parse flags passed from main synu argparse 'm/model=' -- $argv or return 1 # Start with default (from cache or fallback) set -g _synu_llxprt_selected_model (_synu_llxprt_default) # Apply override if provided if set -q _flag_model set -g _synu_llxprt_selected_model $_flag_model end end function _synu_agent_llxprt_args --description "Return CLI arguments to pass to llxprt" echo --provider echo Synthetic echo --model echo $_synu_llxprt_selected_model end function _synu_agent_llxprt_interactive --description "Interactive model selection using gum" # Check for gum if not command -q gum echo "Error: gum is required for interactive mode. Install: https://github.com/charmbracelet/gum" >&2 return 1 end # Fetch available models set -l models_json (gum spin --spinner dot --title "Fetching models..." -- \ curl -s -H "Authorization: Bearer $SYNTHETIC_API_KEY" \ "https://api.synthetic.new/openai/v1/models") or return 1 set -l model_names (echo $models_json | jq -r '.data[].name') or return 1 # Get current model for display set -l current_id (_synu_llxprt_default) set -l current_name (echo $models_json | \ jq -r --arg id "$current_id" '.data[] | select(.id == $id) | .name // "unknown"') # Select model set -l model_name (printf "%s\n" $model_names | \ gum filter --limit 1 --header "Select model for llxprt (current: $current_id)" \ --placeholder "Filter models...") or return 1 set -l model_id (echo $models_json | \ jq -r --arg name "$model_name" '.data[] | select(.name == $name) | .id') if test -z "$model_id" echo "Error: Could not find model ID" >&2 return 1 end # Build flags set -l flags --model=$model_id # Offer to save as default if gum confirm "Save as default for 'llxprt'?" _synu_cache_set llxprt model $model_id end # Output flags for caller to use printf '%s\n' $flags end