1
0
Fork 0

Compare commits

..

2 commits

View file

@ -3,7 +3,6 @@
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
# TODO: Add `eza`, `gitui`, `opencode` # TODO: Add `eza`, `gitui`, `opencode`
# TODO: Increase context window for `aichat_reasoning_remote`
{ {
config, config,
@ -15,12 +14,30 @@
}: }:
let let
# localFastModel = "qwen2.5-coder-num_ctx";
# localReasoningModel = "deepseek-r1-num_ctx";
llm = { llm = {
remote = { free = {
coding = "moonshotai/kimi-k2:free"; key = "openrouter";
reasoning = "deepseek/deepseek-r1-0528:free"; name = "OpenRouter";
url = "https://openrouter.ai/api/v1";
env = "OPENROUTER_API_KEY";
models = {
coding = {
key = "moonshotai/kimi-k2:free";
name = "Kimi K2 (free)";
provider = [ "chutes/fp8" ];
tools = false;
reasoning = false;
vision = true;
};
reasoning = {
key = "deepseek/deepseek-r1-0528:free";
name = "Deepseek R1 (free)";
provider = [ "chutes" ];
tools = false;
reasoning = true;
vision = true;
};
};
}; };
}; };
in in
@ -151,7 +168,9 @@ in
nushell = { nushell = {
enable = true; enable = true;
environmentVariables = { environmentVariables = {
OPENROUTER_API_KEY = lib.hm.nushell.mkNushellInline "cat ${config.sops.secrets.openrouter_api_key.path}"; ${llm.free.env} = lib.hm.nushell.mkNushellInline "cat ${
config.sops.secrets."${llm.free.key}_api_key".path
}";
}; };
settings = { settings = {
completions = { completions = {
@ -164,9 +183,9 @@ in
}; };
# set -x ZATHURA_PLUGINS_PATH $GUIX_HOME/lib/zathura # set -x ZATHURA_PLUGINS_PATH $GUIX_HOME/lib/zathura
shellAliases = { shellAliases = {
aichat_reasoning_remote = "${pkgs.aichat}/bin/aichat --model openrouter:${llm.remote.reasoning}"; aichat_reasoning_free = "${pkgs.aichat}/bin/aichat --model openrouter:${llm.free.models.reasoning.key}";
aichat_coding_remote = "${pkgs.aichat}/bin/aichat --model openrouter:${llm.remote.coding}"; aichat_coding_free = "${pkgs.aichat}/bin/aichat --model ${llm.free.key}:${llm.free.models.coding.key}";
codex_remote = "${pkgs.codex}/bin/codex --provider openrouter --model ${llm.remote.coding}"; codex_free = "${pkgs.codex}/bin/codex --provider ${llm.free.key} --model ${llm.free.models.coding.key}";
hotspot = "sudo sysctl net.ipv4.ip_default_ttl=65"; hotspot = "sudo sysctl net.ipv4.ip_default_ttl=65";
}; };
}; };
@ -384,44 +403,44 @@ in
}; };
codex = { codex = {
enable = true; enable = true;
custom-instructions = '' # custom-instructions = ''
## 10. Applying Patch Files with patch # ## 10. Applying Patch Files with patch
When the built-in `apply_patch` tool or `git apply` fails to apply a diff/patch file (especially if the file being patched contains special characters that might confuse simpler patch tools), the standard `patch` utility can be a more robust alternative. # When the built-in `apply_patch` tool or `git apply` fails to apply a diff/patch file (especially if the file being patched contains special characters that might confuse simpler patch tools), the standard `patch` utility can be a more robust alternative.
- **Patch File Format**: Ensure your patch file is in a standard unified diff format. Typically, these patches are generated with `git diff > my_feature.patch` or manually crafted. If the patch refers to files with `a/` and `b/` prefixes (e.g., `--- a/file.txt`, `+++ b/file.txt`), you'll use the `-p1` option. # - **Patch File Format**: Ensure your patch file is in a standard unified diff format. Typically, these patches are generated with `git diff > my_feature.patch` or manually crafted. If the patch refers to files with `a/` and `b/` prefixes (e.g., `--- a/file.txt`, `+++ b/file.txt`), you'll use the `-p1` option.
- **Creating the Patch File**: You can create a patch file using shell redirection, for example: # - **Creating the Patch File**: You can create a patch file using shell redirection, for example:
```bash` # ```bash`
cat <<'EOF' > fix_descriptive_name.patch # cat <<'EOF' > fix_descriptive_name.patch
--- a/path/to/your/file.ext # --- a/path/to/your/file.ext
+++ b/path/to/your/file.ext # +++ b/path/to/your/file.ext
@@ -line_num,num_lines +line_num,num_lines @@ context_or_change # @@ -line_num,num_lines +line_num,num_lines @@ context_or_change
-old_line_content # -old_line_content
+new_line_content # +new_line_content
EOF # EOF
``` # ```
*Important*: Ensure the `EOF` marker is on its own line with no trailing spaces. # *Important*: Ensure the `EOF` marker is on its own line with no trailing spaces.
- **Applying the Patch**: Use the `patch` command via the `shell` tool. The `-p1` option strips the leading component from file paths in the patch file (`a/`, `b/`). # - **Applying the Patch**: Use the `patch` command via the `shell` tool. The `-p1` option strips the leading component from file paths in the patch file (`a/`, `b/`).
``` # ```
# Example: Apply a patch file # # Example: Apply a patch file
default_api.shell(command=["sh", "-c", "patch -p1 < fix_descriptive_name.patch"]) # default_api.shell(command=["sh", "-c", "patch -p1 < fix_descriptive_name.patch"])
``` # ```
- **Verification**: After applying, always verify that the target file has been changed as expected (e.g., using `cat` or `git diff`). # - **Verification**: After applying, always verify that the target file has been changed as expected (e.g., using `cat` or `git diff`).
- **Cleanup**: Remove the patch file if it's no longer needed: # - **Cleanup**: Remove the patch file if it's no longer needed:
``` # ```
default_api.shell(command=["rm", "fix_descriptive_name.patch"]) # default_api.shell(command=["rm", "fix_descriptive_name.patch"])
``` # ```
''; # '';
settings = { settings = {
model = "${llm.remote.coding}"; model = llm.free.models.coding.key;
provider = "ollama"; provider = "ollama";
providers = { providers = {
ollama = { ollama = {
@ -429,18 +448,77 @@ in
baseURL = "http://localhost:11434/v1"; baseURL = "http://localhost:11434/v1";
envKey = "OLLAMA_API_KEY"; envKey = "OLLAMA_API_KEY";
}; };
openrouter = { ${llm.free.key} = {
name = "OpenRouter"; name = llm.free.name;
baseURL = "https://openrouter.ai/api/v1"; baseURL = llm.free.url;
envKey = "OPENROUTER_API_KEY"; envKey = llm.free.env;
}; };
}; };
}; };
}; };
opencode = {
enable = true;
settings = {
"$schema" = "https://opencode.ai/config.json";
provider = {
${llm.free.key} = {
npm = "@ai-sdk/openai-compatible";
name = llm.free.name;
options = {
baseURL = llm.free.url;
apiKey = "{env:${llm.free.env}}";
};
models = {
${llm.free.models.coding.key} = (
let
model = llm.free.models.coding;
in
{
id = model.key;
name = model.name;
options = {
tools = model.tools;
${llm.free.name} = {
provider = {
order = model.provider;
allow_fallbacks = false;
};
};
};
tool_call = model.tools;
reasoning = model.reasoning;
}
);
${llm.free.models.reasoning.key} = (
let
model = llm.free.models.reasoning;
in
{
id = model.key;
name = model.name;
options = {
tools = model.tools;
${llm.free.name} = {
provider = {
order = model.provider;
allow_fallbacks = false;
};
};
};
tool_call = model.tools;
reasoning = model.reasoning;
}
);
};
};
};
model = "${llm.free.key}:${llm.free.models.coding.key}";
};
};
aichat = { aichat = {
enable = true; enable = true;
settings = { settings = {
model = "openrouter:${llm.remote.coding}"; model = "${llm.free.key}:${llm.free.models.coding.key}";
clients = [ clients = [
# { # {
# type = "openai-compatible"; # type = "openai-compatible";
@ -461,19 +539,29 @@ in
# } # }
{ {
type = "openai-compatible"; type = "openai-compatible";
name = "openrouter"; name = llm.free.key;
api_base = "https://openrouter.ai/api/v1"; api_base = llm.free.url;
models = [ models = [
{ (
name = "${llm.remote.coding}"; let
supports_function_calling = true; model = llm.free.models.coding;
supports_vision = true; in
} {
{ name = model.key;
name = "${llm.remote.reasoning}"; supports_function_calling = model.tools;
supports_function_calling = true; supports_vision = model.vision;
supports_vision = true; }
} )
(
let
model = llm.free.models.reasoning;
in
{
name = model.key;
supports_function_calling = model.tools;
supports_vision = model.vision;
}
)
]; ];
} }
]; ];