diff --git a/config.example.yml b/config.example.yml index fde1416..df83eeb 100644 --- a/config.example.yml +++ b/config.example.yml @@ -17,8 +17,7 @@ settings: # If the content length exceeds the non-zero limit, the review will be skipped # Note that it's unicode width not LLM token length max-length: 0 - # The temperature of the model, Note: It works only for DeepSeek V3 model - # The value should be between 0 and 2, with default value 1.0 + # The temperature of the model, The value should be between 0 and 2, with default value 1.0 temperature: 1.0 # The user prompt name to use for DeepSeek API select from 'prompts.user' user-prompt: 'default' diff --git a/nu/review.nu b/nu/review.nu index 80f9a17..30fcea0 100644 --- a/nu/review.nu +++ b/nu/review.nu @@ -64,7 +64,7 @@ export def --env deepseek-review [ --user-prompt(-u): string # Default to $DEFAULT_OPTIONS.USER_PROMPT, --include(-i): string, # Comma separated file patterns to include in the code review --exclude(-x): string, # Comma separated file patterns to exclude in the code review - --temperature(-T): float, # Temperature for the model, between `0` and `2`, default value `1.0`, Only for V3 + --temperature(-T): float, # Temperature for the model, between `0` and `2`, default value `1.0` ]: nothing -> nothing { $env.config.table.mode = 'psql' diff --git a/tests/resources/.env.test b/tests/resources/.env.test new file mode 100644 index 000000000..39fb8dc --- /dev/null +++ b/tests/resources/.env.test @@ -0,0 +1,13 @@ +# Description: Environment variables for Local Code Review Only +# Usage: Copy this file to .env and replace the values with your own + +CHAT_MODEL="deepseek-chat" # Official DeepSeek model +# BASE_URL: Deepseek API base URL +BASE_URL='https://api.deepseek.ai' # DeepSeek Official +# The maximum temperature for the model to generate the response. 1.0 by default. +TEMPERATURE=1.0 +# MAX_LENGTH: The maximum length of the content for review, 0 means no limit. +MAX_LENGTH=0 + +# USER_PROMPT: User prompt message +USER_PROMPT='Please review the following code changes' diff --git a/tests/test-common.nu b/tests/test-common.nu index f2d2279..9a1b22c 100644 --- a/tests/test-common.nu +++ b/tests/test-common.nu @@ -1,20 +1,57 @@ use std/assert -use ../nu/common.nu [compare-ver] +use ../nu/common.nu [compare-ver, 'from env', is-installed, has-ref, git-check] #[test] -def 'v1.0.0 is greater than v0.1.0' [] { - assert equal (compare-ver 1.0.0 0.1.0) 1 - assert equal (compare-ver v1.0.0 v0.1.0) 1 +def 'compare-ver:v1.0.0 is greater than v0.999.0' [] { + assert equal (compare-ver 1.0.0 0.999.0) 1 + assert equal (compare-ver v1.0.0 v0.999.0) 1 } #[test] -def 'v1.0.1 is equal to v1.0.1' [] { +def 'compare-ver:v1.0.1 is equal to v1.0.1' [] { assert equal (compare-ver 1.0.1 1.0.1) 0 } #[test] -def 'v1.0.1 is lower than v1.1.0' [] { +def 'compare-ver:v1.0.0 is equal to v1' [] { + assert equal (compare-ver v1.0.0 v1) 0 +} + +#[test] +def 'compare-ver:v1.0.1 is greater than v1' [] { + assert equal (compare-ver v1.0.1 v1) 1 +} + +#[test] +def 'compare-ver:v1.0.1 is lower than v1.1.0' [] { assert equal (compare-ver 1.0.1 1.1.0) (-1) } + +#[test] +def 'from-env:.env load should work' [] { + open tests/resources/.env.test | from env | load-env + assert equal $env.CHAT_MODEL deepseek-chat + assert equal $env.BASE_URL https://api.deepseek.ai + assert equal $env.TEMPERATURE '1.0' + assert equal $env.MAX_LENGTH '0' + assert equal $env.USER_PROMPT 'Please review the following code changes' +} + +#[test] +def 'is-installed:binary install check should work' [] { + assert equal (is-installed git) true + assert equal (is-installed abc) false +} + +#[test] +def 'has-ref:git repo should has HEAD ref' [] { + assert equal (has-ref HEAD) true + assert equal (has-ref 0000) false +} + +#[test] +def 'git-check:current dir is a git repo' [] { + assert equal (git-check (pwd) --check-repo=1) true +}