-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
223 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
import vim | ||
import os | ||
|
||
if "PYTEST_VERSION" in os.environ: | ||
from utils import * | ||
|
||
roles_py_imported = True | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
from context import make_ai_context, make_prompt | ||
|
||
default_config = { | ||
"options": { | ||
"model": "gpt-4o", | ||
"endpoint_url": "https://api.openai.com/v1/chat/completions", | ||
"max_tokens": "0", | ||
"max_completion_tokens": "0", | ||
"temperature": "1", | ||
"request_timeout": "20", | ||
"stream": "1", | ||
"enable_auth": "1", | ||
"token_file_path": "", | ||
"selection_boundary": "", | ||
"initial_prompt": "You are a general assistant.", | ||
}, | ||
"ui": { | ||
"open_chat_command": "preset_below", | ||
"scratch_buffer_keep_open": "0", | ||
"populate_options": "0", | ||
"code_syntax_enabled": "1", | ||
"paste_mode": "1", | ||
}, | ||
} | ||
|
||
def test_role_config(): | ||
context = make_ai_context({ | ||
'config_default': default_config, | ||
'config_extension': {}, | ||
'user_instruction': '/deprecated-test-role-simple user instruction', | ||
'user_selection': 'selected text', | ||
'command_type': 'chat', | ||
}) | ||
actual_config = context['config'] | ||
actual_prompt = context['prompt'] | ||
assert 'o1-preview' == actual_config['options']['model'] | ||
assert 'simple role prompt:\nuser instruction:\nselected text' == actual_prompt | ||
|
||
def test_role_config_different_commands(): | ||
base = { | ||
'config_default': default_config, | ||
'config_extension': {}, | ||
'user_instruction': '/deprecated-test-role hello', | ||
'user_selection': '', | ||
} | ||
context = make_ai_context({ **base, 'command_type': 'chat' }) | ||
actual_config = context['config'] | ||
actual_prompt = context['prompt'] | ||
assert 'model-common' == actual_config['options']['model'] | ||
assert '0' == actual_config['ui']['paste_mode'] | ||
assert 'preset_tab' == actual_config['ui']['open_chat_command'] | ||
assert 'hello' == actual_prompt | ||
assert 'https://localhost/chat' == actual_config['options']['endpoint_url'] | ||
|
||
context = make_ai_context({ **base, 'command_type': 'complete' }) | ||
actual_config = context['config'] | ||
actual_prompt = context['prompt'] | ||
assert 'model-common' == actual_config['options']['model'] | ||
assert '0' == actual_config['ui']['paste_mode'] | ||
assert 'hello' == actual_prompt | ||
assert 'https://localhost/complete' == actual_config['options']['endpoint_url'] | ||
|
||
context = make_ai_context({ **base, 'command_type': 'edit' }) | ||
actual_config = context['config'] | ||
actual_prompt = context['prompt'] | ||
assert 'model-common' == actual_config['options']['model'] | ||
assert '0' == actual_config['ui']['paste_mode'] | ||
assert 'hello' == actual_prompt | ||
assert 'https://localhost/edit' == actual_config['options']['endpoint_url'] | ||
|
||
def test_multiple_role_configs(): | ||
context = make_ai_context({ | ||
'config_default': default_config, | ||
'config_extension': {}, | ||
'user_instruction': '/deprecated-test-role /deprecated-test-role-simple hello', | ||
'user_selection': '', | ||
'command_type': 'chat', | ||
}) | ||
actual_config = context['config'] | ||
actual_prompt = context['prompt'] | ||
assert 'o1-preview' == actual_config['options']['model'] | ||
assert 'https://localhost/chat' == actual_config['options']['endpoint_url'] | ||
assert 'simple role prompt:\nhello' == actual_prompt |
Oops, something went wrong.
2a418ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering if this only affects the config files or also the internal dictionary (as used here) ?
2a418ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old syntax is deprecated but still supported. If you want to use new syntax, it probably affects the internal dictionary. New planned features (like custom providers) may work with new syntax only
2a418ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind documenting the differences at some point? I could pipe the diff through an AI and propose a PR to this end, but likely you've got something similar already in mind?
2a418ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is new syntax:
https://github.com/madox2/vim-ai/blob/main/roles-example.ini
This is old syntax:
https://github.com/madox2/vim-ai/blob/b81a3c7cb4fb15295262e4e6a2896e5bc88c51de/roles-example.ini
2a418ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you,
Could you give a hint on how this changes the internal dictionaries for example at https://github.com/madox2/vim-ai?tab=readme-ov-file#configuration?
They seem to be working as before, but I suppose the current model options such as
will eventually have to be changed as they have been deprecated?
2a418ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, configuration structure is not going to change. what has changed is the format of role file and how it is parsed
2a418ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This o1-mini role
is a role that reuses the generic prompt and only changes the model settings?
Outsiders might imagine a role to be defined by a prompt (plus additional options), so it looks a bit surprising at first to see a role named like a model without a prompt
2a418ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that this role was already there before, so the question comes too late, I beg your pardon