7.0 KiB
AIChat to Loki Migration Guide
Loki originally started as a fork of AIChat but has since evolved into its own separate project with separate goals.
As a result, there's some changes you'll need to make to your AIChat configuration to be able to use Loki.
Be sure you've followed the first-time setup steps so that the Loki configuration directory and subdirectories exist and is populated with the built-in defaults.
Global Configuration File
You should be able to copy/paste your AIChat configuration file into your Loki configuration directory. Since the location of the Loki configuration directory varies between systems, you can use the following command to locate your config directory:
loki --info | grep 'config_dir' | awk '{print $2}'
Then, you'll need to make the following changes:
function_calling->function_calling_supportuse_tools->enabled_toolsagent_prelude->agent_sessioncompress_threshold->compression_thresholdsummarize_prompt->summarization_promptsummary_prompt->summary_context_prompt
Roles
Locate your roles directory using the following command:
loki --info | grep 'roles_dir' | awk '{print $2}'
Update any roles that have use_tools to enabled_tools.
Sessions
Locate your sessions directory using the following command:
loki --info | grep 'sessions_dir' | awk '{print $2}'
Update the following settings:
use_tools->enabled_toolscompress_threshold->compression_thresholdsummarize_prompt->summarization_promptsummary_prompt->summary_context_prompt
LLM Functions Changes
Probably the most significant difference between AIChat and Loki is how tools are handled. So if you cloned the llm-functions repo, you'll need to make the following changes.
Note: JavaScript functions are not supported in Loki.
The following guide assumes you're using the llm-functions repository as your base for custom functions, and thus
follows that directory structure.
Agents
Agents are now all handled in one place: the agents directory (<loki-config-dir>/agents):
loki --info | grep 'agents_dir' | awk '{print $2}'
And instead of separate index.yaml and config.yaml files, they're now both in a single config.yaml file.
So now for all of your agents, copy all the contents of those directories to the corresponding directory in the Loki
agents directory. Then make the following changes:
- Copy the contents of your
<aichat-config-dir>/functions/agentsdirectory into<loki-config-dir/agents - Merge
index.yamlintoconfig.yaml- If you never created a custom
config.yamlfile, then simply renameindex.yamltoconfig.yaml - If you've defined an
agent_prelude, rename that field toagent_session
- If you never created a custom
- Convert all JavaScript tools to either Python or Bash
- For Bash
tools.sh: Remove the following line:eval "$(argc --argc-eval "$0" "$@")" - Any
tools.txtfiles you have that define what global functions the agent uses is now replaced by theglobal_toolsfield in the agent'sconfig.yaml. So for example: If yourtools.txtlooks like this:then you need to add the following to your agent'sfs_mkdir.sh fs_ls.sh fs_patch.sh fs_cat.shconfig.yaml:global_tools: - fs_mkdir.sh - fs_ls.sh - fs_patch.sh - fs_cat.sh - If you have any bash
tools.shthat depend on the utility scripts in thellm-functionsrepository, they've been replaced by built-in utility scripts. So use the following to replace any matching lines in yourtools.shfiles:################## ## Scripts file ## ################## ROOT_DIR="${LLM_ROOT_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}" # replace with source "$LLM_PROMPT_UTILS_FILE" ####################### ## guard_path script ## ####################### "$ROOT_DIR/utils/guard_path.sh" # replace with guard_path ############################ ## guard_operation script ## ############################ "$ROOT_DIR/utils/guard_operation.sh" # replace with guard_operation ###################### ## patch.awk script ## ###################### awk -f "$ROOT_DIR/utils/patch.awk" # replace with patch_file
When you're done with this migration, you should have the following:
- No more
functions/agentsdirectory - No
functions/agents.txtfile (Loki assumes that if the agent directory exists, it is loadable) - No
<loki-config-dir>/agents/<agent-name>/tools.txt - No
<loki-config-dir>/agents/<agent-name>/index.yaml
Functions
Loki consolidates much of the llm-functions repo functionality into one binary. So this means
- There's no need to have
argcinstalled anymore - No separate repository to manage
- No
tools.txt - No
functions.json - No
functions/mcpdirectory at all - No
functions/scripts
Here's how to migrate your functions over to Loki from the llm-functions repository.
- Copy your AIChat
<aichat-config-dir>/functionsdirectory into your Loki config directory - Delete the following files and directories from your
<loki-config-dir>/functionsdirectory:scripts/agents.txtfunctions.jsonArgcfile.shREADME.md(irrelevant now)LICENSE(irrelevant now)utils/guard_operation.shutils/guard_path.shutils/patch.awk
- Everything in
tools.txtnow lives in the global config file under thevisible_toolssetting:becomes the following in yourget_current_weather.sh execute_command.sh web_search.sh #execute_py_code.py query_jira_issues.sh<loki-config-dir>/config.yamlvisible_tools: - get_current_weather.sh - execute_command.sh - web_search.sh # - web_search.sh - query_jira_issues.sh - If you've defined a
functions/mcp.jsonfile, you can leave it alone. - Similarly to agents, if you have any bash
tools.shthat depend on the utility scripts in thellm-functionsrepository, they've been replaced by built-in utility scripts. So use the following to replace any matching lines in yourtools.shfiles:################## ## Scripts file ## ################## ROOT_DIR="${LLM_ROOT_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}" # replace with source "$LLM_PROMPT_UTILS_FILE" ####################### ## guard_path script ## ####################### "$ROOT_DIR/utils/guard_path.sh" # replace with guard_path ############################ ## guard_operation script ## ############################ "$ROOT_DIR/utils/guard_operation.sh" # replace with guard_operation ###################### ## patch.awk script ## ###################### awk -f "$ROOT_DIR/utils/patch.awk" # replace with patch_file
Refer to the custom bash tools docs to learn how to compile and test bash
tools in Loki without needing to use argc.