2023-04-01 17:30:14 -05:00
|
|
|
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
|
|
|
|
|
|
from pytest import mark, raises
|
|
|
|
|
|
Python: rebuilt exceptions structure; pythonic version (#5231)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
The existing Exceptions structure was very much inspired by dotnet, this
is now replaced with a pythonic implementations.
This means all Exceptions derive from KernelException and then
specialise for different purposes.
Closes #2194
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Added folder for all exception types, all can be imported through `from
semantic_kernel.exceptions import ...` no need for a user to know which
file the relevant one is in, but keeps things tidy for developers.
Removed old KernelException, added back subtypes for the errorcodes.
Went through everything to make sure the `raise ... from exc` pattern is
used as much as possible as that returns a better stacktrace.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2024-02-28 19:53:53 +01:00
|
|
|
from semantic_kernel.exceptions import CodeBlockSyntaxError
|
2023-04-01 17:30:14 -05:00
|
|
|
from semantic_kernel.template_engine.blocks.block_types import BlockTypes
|
|
|
|
|
from semantic_kernel.template_engine.code_tokenizer import CodeTokenizer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_it_parses_empty_text():
|
|
|
|
|
target = CodeTokenizer()
|
|
|
|
|
|
|
|
|
|
assert not target.tokenize(None)
|
|
|
|
|
assert not target.tokenize("")
|
|
|
|
|
assert not target.tokenize(" ")
|
|
|
|
|
assert not target.tokenize(" \n ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@mark.parametrize(
|
|
|
|
|
"template, content",
|
|
|
|
|
[
|
|
|
|
|
("$foo", "$foo"),
|
|
|
|
|
("$foo ", "$foo"),
|
|
|
|
|
(" $foo", "$foo"),
|
|
|
|
|
(" $bar ", "$bar"),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
def test_it_parses_var_blocks(template, content):
|
|
|
|
|
target = CodeTokenizer()
|
|
|
|
|
blocks = target.tokenize(template)
|
|
|
|
|
|
|
|
|
|
assert len(blocks) == 1
|
|
|
|
|
assert blocks[0].content == content
|
|
|
|
|
assert blocks[0].type == BlockTypes.VARIABLE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@mark.parametrize(
|
|
|
|
|
"template, content",
|
|
|
|
|
[
|
|
|
|
|
("'foo'", "'foo'"),
|
|
|
|
|
("'foo' ", "'foo'"),
|
|
|
|
|
(" 'foo'", "'foo'"),
|
|
|
|
|
(' "bar" ', '"bar"'),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
def test_it_parses_val_blocks(template, content):
|
Python: major features for the Kernel Arguments, Function Result and new Prompt Templating (#5077)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo! Please
help reviewers and future users, providing the following information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here. -->
Major work to replace the context with Kernel Arguments on the front-end
and Function Results on the back.
Updated the function decorator to a new approach, in line with dotnet.
Revamps the way function are called, allowing native functions to be
completely ignorant of SK, other then the decorator.
This also moves things into the new folder structure in sync with
dotnet.
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Adds:
- KernelArguments, a dict-like class that replaces the variables in
KernelContext. Closes #4565
- FunctionResult, a class to hold the results of function executions,
includes the function, the value and metadata, as well as two convenient
function to get the value out of it (str and get_inner_content) the
first is generic, the second specifically for KernelContent responses
(from AI services).
- AI Service Selector class, has a default, which is based on the order
in the arguments followed by the order in the functions, can be
overridden to implement your own strategy. Closes #4631
- Introduces ChatHistory and refactors the PromptTemplateConfig. Closes
#4856, #4630
- Improves parsing of templates, will now all validate during creation
and throw an error then, instead of some that do not check for validaty
until used.
- Introduces named_args block and thereby the ability to have multiple
arguments for a function call in a template. Closes #5003
Updates:
- kernel_function decorators, the parameter decorator was removed and
instead we now use Annotated to add a description of a field and we get
the type and required from the function definition.
- core plugins, use the new approach to kernel_function decorators.
- planners, template engines have all been updated to use the kernel and
kernelarguments instead of Context.
- Events have been updated, now use kernelarguments and function_result
- Tokenizers support for named_args and improvements on parsing and
checking.
- Kernel examples and notebooks to use the latest code.
- All unit and integration tests. There is more code coverage now than
before.
Removed:
- kernelContext
- kernel_function_parameter_decorator
- delegate handling code for native functions
- file_io_plugin and tests
- SemanticFunctionConfig
- ChatPromptTemplate
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone :smile:
---------
Co-authored-by: Evan Mattson <evmattso@microsoft.com>
Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
Co-authored-by: Evan Mattson <evan.mattson@microsoft.com>
2024-02-24 21:05:40 +01:00
|
|
|
blocks = CodeTokenizer.tokenize(template)
|
2023-04-01 17:30:14 -05:00
|
|
|
|
|
|
|
|
assert len(blocks) == 1
|
|
|
|
|
assert blocks[0].content == content
|
|
|
|
|
assert blocks[0].type == BlockTypes.VALUE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@mark.parametrize(
|
|
|
|
|
"template, content",
|
|
|
|
|
[
|
|
|
|
|
("f", "f"),
|
|
|
|
|
(" x ", "x"),
|
|
|
|
|
("foo", "foo"),
|
|
|
|
|
("fo.o ", "fo.o"),
|
|
|
|
|
(" f.oo", "f.oo"),
|
|
|
|
|
(" bar ", "bar"),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
def test_it_parses_function_id_blocks(template, content):
|
Python: major features for the Kernel Arguments, Function Result and new Prompt Templating (#5077)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo! Please
help reviewers and future users, providing the following information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here. -->
Major work to replace the context with Kernel Arguments on the front-end
and Function Results on the back.
Updated the function decorator to a new approach, in line with dotnet.
Revamps the way function are called, allowing native functions to be
completely ignorant of SK, other then the decorator.
This also moves things into the new folder structure in sync with
dotnet.
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Adds:
- KernelArguments, a dict-like class that replaces the variables in
KernelContext. Closes #4565
- FunctionResult, a class to hold the results of function executions,
includes the function, the value and metadata, as well as two convenient
function to get the value out of it (str and get_inner_content) the
first is generic, the second specifically for KernelContent responses
(from AI services).
- AI Service Selector class, has a default, which is based on the order
in the arguments followed by the order in the functions, can be
overridden to implement your own strategy. Closes #4631
- Introduces ChatHistory and refactors the PromptTemplateConfig. Closes
#4856, #4630
- Improves parsing of templates, will now all validate during creation
and throw an error then, instead of some that do not check for validaty
until used.
- Introduces named_args block and thereby the ability to have multiple
arguments for a function call in a template. Closes #5003
Updates:
- kernel_function decorators, the parameter decorator was removed and
instead we now use Annotated to add a description of a field and we get
the type and required from the function definition.
- core plugins, use the new approach to kernel_function decorators.
- planners, template engines have all been updated to use the kernel and
kernelarguments instead of Context.
- Events have been updated, now use kernelarguments and function_result
- Tokenizers support for named_args and improvements on parsing and
checking.
- Kernel examples and notebooks to use the latest code.
- All unit and integration tests. There is more code coverage now than
before.
Removed:
- kernelContext
- kernel_function_parameter_decorator
- delegate handling code for native functions
- file_io_plugin and tests
- SemanticFunctionConfig
- ChatPromptTemplate
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone :smile:
---------
Co-authored-by: Evan Mattson <evmattso@microsoft.com>
Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
Co-authored-by: Evan Mattson <evan.mattson@microsoft.com>
2024-02-24 21:05:40 +01:00
|
|
|
blocks = CodeTokenizer.tokenize(template)
|
2023-04-01 17:30:14 -05:00
|
|
|
|
|
|
|
|
assert len(blocks) == 1
|
|
|
|
|
assert blocks[0].content == content
|
|
|
|
|
assert blocks[0].type == BlockTypes.FUNCTION_ID
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_it_parses_function_calls():
|
|
|
|
|
template1 = "x.y $foo"
|
|
|
|
|
template2 = "xy $foo"
|
|
|
|
|
template3 = "xy '$value'"
|
|
|
|
|
|
Python: major features for the Kernel Arguments, Function Result and new Prompt Templating (#5077)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo! Please
help reviewers and future users, providing the following information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here. -->
Major work to replace the context with Kernel Arguments on the front-end
and Function Results on the back.
Updated the function decorator to a new approach, in line with dotnet.
Revamps the way function are called, allowing native functions to be
completely ignorant of SK, other then the decorator.
This also moves things into the new folder structure in sync with
dotnet.
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Adds:
- KernelArguments, a dict-like class that replaces the variables in
KernelContext. Closes #4565
- FunctionResult, a class to hold the results of function executions,
includes the function, the value and metadata, as well as two convenient
function to get the value out of it (str and get_inner_content) the
first is generic, the second specifically for KernelContent responses
(from AI services).
- AI Service Selector class, has a default, which is based on the order
in the arguments followed by the order in the functions, can be
overridden to implement your own strategy. Closes #4631
- Introduces ChatHistory and refactors the PromptTemplateConfig. Closes
#4856, #4630
- Improves parsing of templates, will now all validate during creation
and throw an error then, instead of some that do not check for validaty
until used.
- Introduces named_args block and thereby the ability to have multiple
arguments for a function call in a template. Closes #5003
Updates:
- kernel_function decorators, the parameter decorator was removed and
instead we now use Annotated to add a description of a field and we get
the type and required from the function definition.
- core plugins, use the new approach to kernel_function decorators.
- planners, template engines have all been updated to use the kernel and
kernelarguments instead of Context.
- Events have been updated, now use kernelarguments and function_result
- Tokenizers support for named_args and improvements on parsing and
checking.
- Kernel examples and notebooks to use the latest code.
- All unit and integration tests. There is more code coverage now than
before.
Removed:
- kernelContext
- kernel_function_parameter_decorator
- delegate handling code for native functions
- file_io_plugin and tests
- SemanticFunctionConfig
- ChatPromptTemplate
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone :smile:
---------
Co-authored-by: Evan Mattson <evmattso@microsoft.com>
Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
Co-authored-by: Evan Mattson <evan.mattson@microsoft.com>
2024-02-24 21:05:40 +01:00
|
|
|
blocks1 = CodeTokenizer.tokenize(template1)
|
|
|
|
|
blocks2 = CodeTokenizer.tokenize(template2)
|
|
|
|
|
blocks3 = CodeTokenizer.tokenize(template3)
|
2023-04-01 17:30:14 -05:00
|
|
|
|
|
|
|
|
assert len(blocks1) == 2
|
|
|
|
|
assert len(blocks2) == 2
|
|
|
|
|
assert len(blocks3) == 2
|
|
|
|
|
|
|
|
|
|
assert blocks1[0].content == "x.y"
|
|
|
|
|
assert blocks2[0].content == "xy"
|
|
|
|
|
assert blocks3[0].content == "xy"
|
|
|
|
|
|
|
|
|
|
assert blocks1[0].type == BlockTypes.FUNCTION_ID
|
|
|
|
|
assert blocks2[0].type == BlockTypes.FUNCTION_ID
|
|
|
|
|
assert blocks3[0].type == BlockTypes.FUNCTION_ID
|
|
|
|
|
|
|
|
|
|
assert blocks1[1].content == "$foo"
|
|
|
|
|
assert blocks2[1].content == "$foo"
|
|
|
|
|
assert blocks3[1].content == "'$value'"
|
|
|
|
|
|
|
|
|
|
assert blocks1[1].type == BlockTypes.VARIABLE
|
|
|
|
|
assert blocks2[1].type == BlockTypes.VARIABLE
|
|
|
|
|
assert blocks3[1].type == BlockTypes.VALUE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_it_supports_escaping():
|
|
|
|
|
template = "func 'f\\'oo'"
|
Python: major features for the Kernel Arguments, Function Result and new Prompt Templating (#5077)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo! Please
help reviewers and future users, providing the following information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here. -->
Major work to replace the context with Kernel Arguments on the front-end
and Function Results on the back.
Updated the function decorator to a new approach, in line with dotnet.
Revamps the way function are called, allowing native functions to be
completely ignorant of SK, other then the decorator.
This also moves things into the new folder structure in sync with
dotnet.
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Adds:
- KernelArguments, a dict-like class that replaces the variables in
KernelContext. Closes #4565
- FunctionResult, a class to hold the results of function executions,
includes the function, the value and metadata, as well as two convenient
function to get the value out of it (str and get_inner_content) the
first is generic, the second specifically for KernelContent responses
(from AI services).
- AI Service Selector class, has a default, which is based on the order
in the arguments followed by the order in the functions, can be
overridden to implement your own strategy. Closes #4631
- Introduces ChatHistory and refactors the PromptTemplateConfig. Closes
#4856, #4630
- Improves parsing of templates, will now all validate during creation
and throw an error then, instead of some that do not check for validaty
until used.
- Introduces named_args block and thereby the ability to have multiple
arguments for a function call in a template. Closes #5003
Updates:
- kernel_function decorators, the parameter decorator was removed and
instead we now use Annotated to add a description of a field and we get
the type and required from the function definition.
- core plugins, use the new approach to kernel_function decorators.
- planners, template engines have all been updated to use the kernel and
kernelarguments instead of Context.
- Events have been updated, now use kernelarguments and function_result
- Tokenizers support for named_args and improvements on parsing and
checking.
- Kernel examples and notebooks to use the latest code.
- All unit and integration tests. There is more code coverage now than
before.
Removed:
- kernelContext
- kernel_function_parameter_decorator
- delegate handling code for native functions
- file_io_plugin and tests
- SemanticFunctionConfig
- ChatPromptTemplate
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone :smile:
---------
Co-authored-by: Evan Mattson <evmattso@microsoft.com>
Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
Co-authored-by: Evan Mattson <evan.mattson@microsoft.com>
2024-02-24 21:05:40 +01:00
|
|
|
blocks = CodeTokenizer.tokenize(template)
|
2023-04-01 17:30:14 -05:00
|
|
|
|
|
|
|
|
assert len(blocks) == 2
|
|
|
|
|
assert blocks[0].content == "func"
|
|
|
|
|
assert blocks[1].content == "'f'oo'"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_it_throws_when_separators_are_missing():
|
|
|
|
|
template1 = "call 'f\\\\'xy'"
|
|
|
|
|
template2 = "call 'f\\\\'x"
|
|
|
|
|
|
Python: major features for the Kernel Arguments, Function Result and new Prompt Templating (#5077)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo! Please
help reviewers and future users, providing the following information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here. -->
Major work to replace the context with Kernel Arguments on the front-end
and Function Results on the back.
Updated the function decorator to a new approach, in line with dotnet.
Revamps the way function are called, allowing native functions to be
completely ignorant of SK, other then the decorator.
This also moves things into the new folder structure in sync with
dotnet.
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Adds:
- KernelArguments, a dict-like class that replaces the variables in
KernelContext. Closes #4565
- FunctionResult, a class to hold the results of function executions,
includes the function, the value and metadata, as well as two convenient
function to get the value out of it (str and get_inner_content) the
first is generic, the second specifically for KernelContent responses
(from AI services).
- AI Service Selector class, has a default, which is based on the order
in the arguments followed by the order in the functions, can be
overridden to implement your own strategy. Closes #4631
- Introduces ChatHistory and refactors the PromptTemplateConfig. Closes
#4856, #4630
- Improves parsing of templates, will now all validate during creation
and throw an error then, instead of some that do not check for validaty
until used.
- Introduces named_args block and thereby the ability to have multiple
arguments for a function call in a template. Closes #5003
Updates:
- kernel_function decorators, the parameter decorator was removed and
instead we now use Annotated to add a description of a field and we get
the type and required from the function definition.
- core plugins, use the new approach to kernel_function decorators.
- planners, template engines have all been updated to use the kernel and
kernelarguments instead of Context.
- Events have been updated, now use kernelarguments and function_result
- Tokenizers support for named_args and improvements on parsing and
checking.
- Kernel examples and notebooks to use the latest code.
- All unit and integration tests. There is more code coverage now than
before.
Removed:
- kernelContext
- kernel_function_parameter_decorator
- delegate handling code for native functions
- file_io_plugin and tests
- SemanticFunctionConfig
- ChatPromptTemplate
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone :smile:
---------
Co-authored-by: Evan Mattson <evmattso@microsoft.com>
Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
Co-authored-by: Evan Mattson <evan.mattson@microsoft.com>
2024-02-24 21:05:40 +01:00
|
|
|
with raises(CodeBlockSyntaxError):
|
|
|
|
|
CodeTokenizer.tokenize(template1)
|
|
|
|
|
|
|
|
|
|
with raises(CodeBlockSyntaxError):
|
|
|
|
|
CodeTokenizer.tokenize(template2)
|
|
|
|
|
|
2023-04-01 17:30:14 -05:00
|
|
|
|
Python: major features for the Kernel Arguments, Function Result and new Prompt Templating (#5077)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo! Please
help reviewers and future users, providing the following information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here. -->
Major work to replace the context with Kernel Arguments on the front-end
and Function Results on the back.
Updated the function decorator to a new approach, in line with dotnet.
Revamps the way function are called, allowing native functions to be
completely ignorant of SK, other then the decorator.
This also moves things into the new folder structure in sync with
dotnet.
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Adds:
- KernelArguments, a dict-like class that replaces the variables in
KernelContext. Closes #4565
- FunctionResult, a class to hold the results of function executions,
includes the function, the value and metadata, as well as two convenient
function to get the value out of it (str and get_inner_content) the
first is generic, the second specifically for KernelContent responses
(from AI services).
- AI Service Selector class, has a default, which is based on the order
in the arguments followed by the order in the functions, can be
overridden to implement your own strategy. Closes #4631
- Introduces ChatHistory and refactors the PromptTemplateConfig. Closes
#4856, #4630
- Improves parsing of templates, will now all validate during creation
and throw an error then, instead of some that do not check for validaty
until used.
- Introduces named_args block and thereby the ability to have multiple
arguments for a function call in a template. Closes #5003
Updates:
- kernel_function decorators, the parameter decorator was removed and
instead we now use Annotated to add a description of a field and we get
the type and required from the function definition.
- core plugins, use the new approach to kernel_function decorators.
- planners, template engines have all been updated to use the kernel and
kernelarguments instead of Context.
- Events have been updated, now use kernelarguments and function_result
- Tokenizers support for named_args and improvements on parsing and
checking.
- Kernel examples and notebooks to use the latest code.
- All unit and integration tests. There is more code coverage now than
before.
Removed:
- kernelContext
- kernel_function_parameter_decorator
- delegate handling code for native functions
- file_io_plugin and tests
- SemanticFunctionConfig
- ChatPromptTemplate
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone :smile:
---------
Co-authored-by: Evan Mattson <evmattso@microsoft.com>
Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
Co-authored-by: Evan Mattson <evan.mattson@microsoft.com>
2024-02-24 21:05:40 +01:00
|
|
|
def test_named_args():
|
|
|
|
|
template = 'plugin.function "direct" arg1=$arg1 arg2="arg2"'
|
|
|
|
|
blocks = CodeTokenizer.tokenize(template)
|
|
|
|
|
assert len(blocks) == 4
|
|
|
|
|
assert blocks[0].content == "plugin.function"
|
|
|
|
|
assert blocks[1].content == '"direct"'
|
|
|
|
|
assert blocks[2].content == "arg1=$arg1"
|
|
|
|
|
assert blocks[3].content == 'arg2="arg2"'
|