SIGN IN SIGN UP

Integrate cutting-edge LLM technology quickly and easily into your apps

0 0 24 C#
# Dev Setup
This document describes how to setup your environment with Python and uv,
2023-04-12 10:43:01 -07:00
if you're working on new features or a bug fix for Semantic Kernel, or simply
want to run the tests included.
## System setup
2023-04-12 10:43:01 -07:00
## If you're on WSL
Python: Introduce Pydantic settings (#6193) ### Motivation and Context SK Python is tightly coupled to the use of a `.env` file to read all secrets, keys, endpoints, and more. This doesn't scale well for users who wish to be able to use environment variables with their SK Applications. By introducing Pydantic Settings, it is possible to use both environment variables as well as have a fall-back to a `.env` file (via a `env_file_path` parameter), if desired. By introducing Pydantic Settings, we are removing the requirement to have to create Text/Embedding/Chat completion objects with an `api_key` or other previously required information (in the case of AzureChatCompletion that means an `endpoint`, an `api_key`, a `deployment_name`, and an `api_version`). When the AI connector is created, the Pydantic settings are loaded either via env vars or the fall-back `.env` file, and that means the user can create a chat completion object like: ```python chat_completion = OpenAIChatCompletion(service_id="test") ``` or, to optionally override the `ai_model_id` env var: ```python chat_completion = OpenAIChatCompletion(service_id="test", ai_model_id="gpt-4-1106") ``` Note: we have left the ability to specific an `api_key`/`org_id` for `OpenAIChatCompletion` or a `deployment_name`, `endpoint`, `base_url`, and `api_version` for `AzureChatCompletion` as before, but if your settings are configured to use env vars/.env file then there is no need to pass this information. <!-- 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. --> ### Description The PR introduces the use of Pydantic settings and removes the use of the python-dotenv library. - Closes #1779 - Updates notebooks, samples, code and tests to remove the explicit config of api_key or other previous .env files values. - Adds new unit test config using monkeypatch to simulate env variables for testing - All unit and integration tests passing <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### 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:
2024-05-16 07:44:40 -04:00
Check that you've cloned the repository to `~/workspace` or a similar folder.
Avoid `/mnt/c/` and prefer using your WSL user's home directory.
Python: Introduce Pydantic settings (#6193) ### Motivation and Context SK Python is tightly coupled to the use of a `.env` file to read all secrets, keys, endpoints, and more. This doesn't scale well for users who wish to be able to use environment variables with their SK Applications. By introducing Pydantic Settings, it is possible to use both environment variables as well as have a fall-back to a `.env` file (via a `env_file_path` parameter), if desired. By introducing Pydantic Settings, we are removing the requirement to have to create Text/Embedding/Chat completion objects with an `api_key` or other previously required information (in the case of AzureChatCompletion that means an `endpoint`, an `api_key`, a `deployment_name`, and an `api_version`). When the AI connector is created, the Pydantic settings are loaded either via env vars or the fall-back `.env` file, and that means the user can create a chat completion object like: ```python chat_completion = OpenAIChatCompletion(service_id="test") ``` or, to optionally override the `ai_model_id` env var: ```python chat_completion = OpenAIChatCompletion(service_id="test", ai_model_id="gpt-4-1106") ``` Note: we have left the ability to specific an `api_key`/`org_id` for `OpenAIChatCompletion` or a `deployment_name`, `endpoint`, `base_url`, and `api_version` for `AzureChatCompletion` as before, but if your settings are configured to use env vars/.env file then there is no need to pass this information. <!-- 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. --> ### Description The PR introduces the use of Pydantic settings and removes the use of the python-dotenv library. - Closes #1779 - Updates notebooks, samples, code and tests to remove the explicit config of api_key or other previous .env files values. - Adds new unit test config using monkeypatch to simulate env variables for testing - All unit and integration tests passing <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### 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:
2024-05-16 07:44:40 -04:00
Ensure you have the WSL extension for VSCode installed.
Python: Introduce Pydantic settings (#6193) ### Motivation and Context SK Python is tightly coupled to the use of a `.env` file to read all secrets, keys, endpoints, and more. This doesn't scale well for users who wish to be able to use environment variables with their SK Applications. By introducing Pydantic Settings, it is possible to use both environment variables as well as have a fall-back to a `.env` file (via a `env_file_path` parameter), if desired. By introducing Pydantic Settings, we are removing the requirement to have to create Text/Embedding/Chat completion objects with an `api_key` or other previously required information (in the case of AzureChatCompletion that means an `endpoint`, an `api_key`, a `deployment_name`, and an `api_version`). When the AI connector is created, the Pydantic settings are loaded either via env vars or the fall-back `.env` file, and that means the user can create a chat completion object like: ```python chat_completion = OpenAIChatCompletion(service_id="test") ``` or, to optionally override the `ai_model_id` env var: ```python chat_completion = OpenAIChatCompletion(service_id="test", ai_model_id="gpt-4-1106") ``` Note: we have left the ability to specific an `api_key`/`org_id` for `OpenAIChatCompletion` or a `deployment_name`, `endpoint`, `base_url`, and `api_version` for `AzureChatCompletion` as before, but if your settings are configured to use env vars/.env file then there is no need to pass this information. <!-- 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. --> ### Description The PR introduces the use of Pydantic settings and removes the use of the python-dotenv library. - Closes #1779 - Updates notebooks, samples, code and tests to remove the explicit config of api_key or other previous .env files values. - Adds new unit test config using monkeypatch to simulate env variables for testing - All unit and integration tests passing <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### 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:
2024-05-16 07:44:40 -04:00
## Using uv
2023-04-12 10:43:01 -07:00
uv allows us to use SK from the local files, without worrying about paths, as
if you had SK pip package installed.
2023-04-12 10:43:01 -07:00
To install SK and all the required tools in your system, first, navigate to the directory containing
this DEV_SETUP using your chosen shell.
2023-03-16 19:54:34 -07:00
### For windows (non-WSL)
2023-03-16 19:54:34 -07:00
Check the [uv documentation](https://docs.astral.sh/uv/getting-started/installation/) for the installation instructions. At the time of writing this is the command to install uv:
2023-03-16 19:54:34 -07:00
```powershell
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
```
2023-03-16 19:54:34 -07:00
You can then run the following commands manually:
```powershell
# Install Python 3.10, 3.11, and 3.12
uv python install 3.10 3.11 3.12
# Create a virtual environment with Python 3.10 (you can change this to 3.11 or 3.12)
$PYTHON_VERSION = "3.10"
uv venv --python $PYTHON_VERSION
# Install SK and all dependencies
uv sync --all-extras --dev
# Install pre-commit hooks
uv run pre-commit install -c python/.pre-commit-config.yaml
```
2023-03-16 19:54:34 -07:00
Or you can then either install [`make`](https://gnuwin32.sourceforge.net/packages/make.htm) and then follow the guide for Mac and Linux, or run the following commands, the commands are shown as bash but should work in powershell as well.
2023-03-16 19:54:34 -07:00
### For Mac and Linux (both native and WSL)
2023-03-16 19:54:34 -07:00
It is super simple to get started, run the following commands:
2023-03-16 19:54:34 -07:00
```bash
make install
2023-03-16 19:54:34 -07:00
```
This will install uv, python, Semantic Kernel and all dependencies and the pre-commit config. It uses python 3.10 by default, if you want to change that set the `PYTHON_VERSION` environment variable to the desired version (currently supported are 3.10, 3.11, 3.12). For instance for 3.12"
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
```bash
make install PYTHON_VERSION=3.12
```
2023-03-16 19:54:34 -07:00
If you want to change python version (without installing uv, python and pre-commit), you can use the same parameter, but do:
2023-03-16 19:54:34 -07:00
```bash
make install-sk PYTHON_VERSION=3.12
```
**Note**: Running the install or install-sk command will wipe away your existing virtual environment and create a new one.
Alternatively you can run the VSCode task `Python: Install` to run the same command.
## VSCode Setup
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
Install the [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) for VSCode.
Open the workspace in [VSCode](https://code.visualstudio.com/docs/editing/workspaces/workspaces).
> The workspace for python should be rooted in the `./python` folder.
Open any of the `.py` files in the project and run the `Python: Select Interpreter`
command from the command palette. Make sure the virtual env (default path is `.venv`) created by
`uv` is selected.
If prompted, install `ruff`. (It should have been installed as part of `uv sync --dev`).
You also need to install the `ruff` extension in VSCode so that auto-formatting uses the `ruff` formatter on save.
Read more about the extension [here](https://github.com/astral-sh/ruff-vscode).
Python: Improve azure assistant agent settings and retrieval operations. (#10063) ### Motivation and Context The AzureAssistantAgent retrieval path was not handling the optional ad_token. The agent constructor was handling it, to a degree, but there were improvements to make and a helper function to introduce so that we remove some code duplication. <!-- 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. --> ### Description This PR: - Cleans up the code used to create the azure settings for an azure assistant agent by introducing a helper function to streamline the logic - Allows the AzureAssistantAgent.retrieve() method to use an ad_token, if desired. - Adds unit tests for the new logic. Other unit tests are still passing after the refactor. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### 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:
2025-01-08 03:34:46 +09:00
### Configuring Unit Testing in VSCode
- We have removed the strict dependency on forcing `pytest` usage via the `.vscode/settings.json` file.
- Developers are free to set up unit tests using their preferred framework, whether it is `pytest` or `unittest`.
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
- If needed, adjust VSCode's local `settings.json` (accessed via the Command Palette(`Ctrl+Shift+P`) and type `Preferences: Open User Settings (JSON)`) to configure the test framework. For example:
Python: Improve azure assistant agent settings and retrieval operations. (#10063) ### Motivation and Context The AzureAssistantAgent retrieval path was not handling the optional ad_token. The agent constructor was handling it, to a degree, but there were improvements to make and a helper function to introduce so that we remove some code duplication. <!-- 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. --> ### Description This PR: - Cleans up the code used to create the azure settings for an azure assistant agent by introducing a helper function to streamline the logic - Allows the AzureAssistantAgent.retrieve() method to use an ad_token, if desired. - Adds unit tests for the new logic. Other unit tests are still passing after the refactor. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### 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:
2025-01-08 03:34:46 +09:00
```json
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
Python: Improve azure assistant agent settings and retrieval operations. (#10063) ### Motivation and Context The AzureAssistantAgent retrieval path was not handling the optional ad_token. The agent constructor was handling it, to a degree, but there were improvements to make and a helper function to introduce so that we remove some code duplication. <!-- 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. --> ### Description This PR: - Cleans up the code used to create the azure settings for an azure assistant agent by introducing a helper function to streamline the logic - Allows the AzureAssistantAgent.retrieve() method to use an ad_token, if desired. - Adds unit tests for the new logic. Other unit tests are still passing after the refactor. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### 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:
2025-01-08 03:34:46 +09:00
```
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
Python: Improve azure assistant agent settings and retrieval operations. (#10063) ### Motivation and Context The AzureAssistantAgent retrieval path was not handling the optional ad_token. The agent constructor was handling it, to a degree, but there were improvements to make and a helper function to introduce so that we remove some code duplication. <!-- 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. --> ### Description This PR: - Cleans up the code used to create the azure settings for an azure assistant agent by introducing a helper function to streamline the logic - Allows the AzureAssistantAgent.retrieve() method to use an ad_token, if desired. - Adds unit tests for the new logic. Other unit tests are still passing after the refactor. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### 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:
2025-01-08 03:34:46 +09:00
Or, for `unittest`:
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
Python: Improve azure assistant agent settings and retrieval operations. (#10063) ### Motivation and Context The AzureAssistantAgent retrieval path was not handling the optional ad_token. The agent constructor was handling it, to a degree, but there were improvements to make and a helper function to introduce so that we remove some code duplication. <!-- 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. --> ### Description This PR: - Cleans up the code used to create the azure settings for an azure assistant agent by introducing a helper function to streamline the logic - Allows the AzureAssistantAgent.retrieve() method to use an ad_token, if desired. - Adds unit tests for the new logic. Other unit tests are still passing after the refactor. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### 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:
2025-01-08 03:34:46 +09:00
```json
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
"python.testing.unittestEnabled": true,
"python.testing.pytestEnabled": false,
```
Python: Improve azure assistant agent settings and retrieval operations. (#10063) ### Motivation and Context The AzureAssistantAgent retrieval path was not handling the optional ad_token. The agent constructor was handling it, to a degree, but there were improvements to make and a helper function to introduce so that we remove some code duplication. <!-- 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. --> ### Description This PR: - Cleans up the code used to create the azure settings for an azure assistant agent by introducing a helper function to streamline the logic - Allows the AzureAssistantAgent.retrieve() method to use an ad_token, if desired. - Adds unit tests for the new logic. Other unit tests are still passing after the refactor. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### 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:
2025-01-08 03:34:46 +09:00
## LLM setup
Make sure you have an
[OpenAI API Key](https://platform.openai.com) or
[Azure OpenAI service key](https://learn.microsoft.com/azure/cognitive-services/openai/quickstart?pivots=rest-api)
There are two methods to manage keys, secrets, and endpoints:
2023-03-16 19:54:34 -07:00
1. Store them in environment variables. SK Python leverages pydantic settings to load keys, secrets, and endpoints from the environment.
> When you are using VSCode and have the python extension setup, it automatically loads environment variables from a `.env` file, so you don't have to manually set them in the terminal.
> During runtime on different platforms, environment settings set as part of the deployments should be used.
Python: dev_setup and readme updates (#5770) This pull request primarily updates the `DEV_SETUP.md` and `README.md` files in the `python` directory. The changes focus on improving the setup instructions, updating the code snippets, and providing additional information on running tests, code coverage, and keeping the local repository up-to-date. Changes to setup instructions: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90): Added instructions on how to use Python 3.11 with Poetry, how to install pre-commit hooks, and how to run tests using VSCode Tasks. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR112-R114) [[3]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR131-R133) [[4]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252) Code snippets updates: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227): Updated the code snippets to reflect the latest changes in the codebase. This includes changes in the use of Pydantic and the use of KernelBaseModel. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL244-R177) * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01L58-R66): Updated the code snippet to reflect the change in getting request settings from a service ID. Additional information: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252): Added information on how to run code coverage, how to keep the local repository up-to-date, and how to resolve conflicts after a rebase. * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01R7-R14): Added instructions on how to install optional dependencies.
2024-04-04 15:41:27 +02:00
2. Store them in a separate `.env` file, like `dev.env`, you can then pass that name into the constructor for most services, to the `env_file_path` parameter, see below.
> Do not store `*.env` files in your repository, and make sure to add them to your `.gitignore` file.
2023-03-16 19:54:34 -07:00
There are a lot of settings, for a more extensive list of settings, see [ALL_SETTINGS.md](./samples/concepts/setup/ALL_SETTINGS.md).
### Example for file-based setup with OpenAI Chat Completions
To configure a `.env` file with just the keys needed for OpenAI Chat Completions, you can create a `openai.env` (this name is just as an example, a single `.env` with all required keys is more common) file in the root of the `python` folder with the following content:
Python: dev_setup and readme updates (#5770) This pull request primarily updates the `DEV_SETUP.md` and `README.md` files in the `python` directory. The changes focus on improving the setup instructions, updating the code snippets, and providing additional information on running tests, code coverage, and keeping the local repository up-to-date. Changes to setup instructions: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90): Added instructions on how to use Python 3.11 with Poetry, how to install pre-commit hooks, and how to run tests using VSCode Tasks. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR112-R114) [[3]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR131-R133) [[4]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252) Code snippets updates: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227): Updated the code snippets to reflect the latest changes in the codebase. This includes changes in the use of Pydantic and the use of KernelBaseModel. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL244-R177) * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01L58-R66): Updated the code snippet to reflect the change in getting request settings from a service ID. Additional information: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252): Added information on how to run code coverage, how to keep the local repository up-to-date, and how to resolve conflicts after a rebase. * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01R7-R14): Added instructions on how to install optional dependencies.
2024-04-04 15:41:27 +02:00
Content of `openai.env`:
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
```env
OPENAI_API_KEY=""
OPENAI_CHAT_MODEL_ID="gpt-4o-mini"
2023-04-12 10:43:01 -07:00
```
2023-03-16 19:54:34 -07:00
You will then configure the ChatCompletion class with the keyword argument `env_file_path`:
```python
chat_completion = OpenAIChatCompletion(service_id="test", env_file_path="openai.env")
```
2023-03-16 19:54:34 -07:00
## Tests
2023-03-16 19:54:34 -07:00
You can run the unit tests under the [tests/unit](tests/unit/) folder.
2023-04-12 10:43:01 -07:00
```bash
uv run pytest tests/unit
```
Python: dev_setup and readme updates (#5770) This pull request primarily updates the `DEV_SETUP.md` and `README.md` files in the `python` directory. The changes focus on improving the setup instructions, updating the code snippets, and providing additional information on running tests, code coverage, and keeping the local repository up-to-date. Changes to setup instructions: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90): Added instructions on how to use Python 3.11 with Poetry, how to install pre-commit hooks, and how to run tests using VSCode Tasks. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR112-R114) [[3]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR131-R133) [[4]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252) Code snippets updates: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227): Updated the code snippets to reflect the latest changes in the codebase. This includes changes in the use of Pydantic and the use of KernelBaseModel. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL244-R177) * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01L58-R66): Updated the code snippet to reflect the change in getting request settings from a service ID. Additional information: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252): Added information on how to run code coverage, how to keep the local repository up-to-date, and how to resolve conflicts after a rebase. * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01R7-R14): Added instructions on how to install optional dependencies.
2024-04-04 15:41:27 +02:00
Alternatively, you can run them using VSCode Tasks. Open the command palette
(`Ctrl+Shift+P`) and type `Tasks: Run Task`. Select `Python: Tests - Unit` or `Python: Tests - Code Coverage` from the list.
You can run the integration tests under the [tests/integration](tests/integration/) folder.
```bash
uv run pytest tests/integration
```
2023-04-12 10:43:01 -07:00
You can also run all the tests together under the [tests](tests/) folder.
```bash
uv run pytest tests
```
Python: dev_setup and readme updates (#5770) This pull request primarily updates the `DEV_SETUP.md` and `README.md` files in the `python` directory. The changes focus on improving the setup instructions, updating the code snippets, and providing additional information on running tests, code coverage, and keeping the local repository up-to-date. Changes to setup instructions: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90): Added instructions on how to use Python 3.11 with Poetry, how to install pre-commit hooks, and how to run tests using VSCode Tasks. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR112-R114) [[3]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR131-R133) [[4]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252) Code snippets updates: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227): Updated the code snippets to reflect the latest changes in the codebase. This includes changes in the use of Pydantic and the use of KernelBaseModel. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL244-R177) * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01L58-R66): Updated the code snippet to reflect the change in getting request settings from a service ID. Additional information: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252): Added information on how to run code coverage, how to keep the local repository up-to-date, and how to resolve conflicts after a rebase. * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01R7-R14): Added instructions on how to install optional dependencies.
2024-04-04 15:41:27 +02:00
Alternatively, you can run them using VSCode Tasks. Open the command palette
(`Ctrl+Shift+P`) and type `Tasks: Run Task`. Select `Python: Tests - All` from the list.
Python: Restructure samples into new folders to make things more clear. (#6116) ### Motivation and Context All previous samples were either in kernel syntax or a separate notebooks folder. The goal is to make the samples easier to understand and have a better structure. <!-- 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. --> ### Description The PR restructures the kernel syntax examples into new folders: concepts (with subfolders for previous syntax examples), demos, getting_started, and learn_resources. - Closes #6119 - Adds a new concept/function example for understanding kernel arguments. - Updates the bookings plugin <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### 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-05-04 07:50:04 -04:00
## Implementation Decisions
### Asynchronous programming
Python: Restructure samples into new folders to make things more clear. (#6116) ### Motivation and Context All previous samples were either in kernel syntax or a separate notebooks folder. The goal is to make the samples easier to understand and have a better structure. <!-- 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. --> ### Description The PR restructures the kernel syntax examples into new folders: concepts (with subfolders for previous syntax examples), demos, getting_started, and learn_resources. - Closes #6119 - Adds a new concept/function example for understanding kernel arguments. - Updates the bookings plugin <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### 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-05-04 07:50:04 -04:00
It's important to note that most of this library is written with asynchronous in mind. The
developer should always assume everything is asynchronous. One can use the function signature
with either `async def` or `def` to understand if something is asynchronous or not.
### Documentation
Each file should have a single first line containing: # Copyright (c) Microsoft. All rights reserved.
We follow the [Google Docstring](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#383-functions-and-methods) style guide for functions and methods.
They are currently not checked for private functions (functions starting with '_').
They should contain:
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
- Single line explaining what the function does, ending with a period.
- If necessary to further explain the logic a newline follows the first line and then the explanation is given.
- The following three sections are optional, and if used should be separated by a single empty line.
- Arguments are then specified after a header called `Args:`, with each argument being specified in the following format:
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
- `arg_name`: Explanation of the argument.
- if a longer explanation is needed for a argument, it should be placed on the next line, indented by 4 spaces.
- Type and default values do not have to be specified, they will be pulled from the definition.
- Returns are specified after a header called `Returns:` or `Yields:`, with the return type and explanation of the return value.
- Finally, a header for exceptions can be added, called `Raises:`, with each exception being specified in the following format:
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
- `ExceptionType`: Explanation of the exception.
- if a longer explanation is needed for a exception, it should be placed on the next line, indented by 4 spaces.
Putting them all together, gives you at minimum this:
```python
def equal(arg1: str, arg2: str) -> bool:
"""Compares two strings and returns True if they are the same."""
...
```
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
Or a complete version of this:
```python
def equal(arg1: str, arg2: str) -> bool:
"""Compares two strings and returns True if they are the same.
Here is extra explanation of the logic involved.
Args:
arg1: The first string to compare.
arg2: The second string to compare.
This string requires extra explanation.
Returns:
True if the strings are the same, False otherwise.
Raises:
ValueError: If one of the strings is empty.
"""
...
```
If in doubt, use the link above to read much more considerations of what to do and when, or use common sense.
## Pydantic and Serialization
This section describes how one can enable serialization for their class using Pydantic.
For more info you can refer to the [Pydantic Documentation](https://docs.pydantic.dev/latest/).
### Upgrading existing classes to use Pydantic
Let's take the following example:
```python
class A:
def __init__(self, a: int, b: float, c: List[float], d: dict[str, tuple[float, str]] = {}):
self.a = a
self.b = b
self.c = c
self.d = d
```
You would convert this to a Pydantic class by sub-classing from the `KernelBaseModel` class.
```python
from pydantic import Field
from semantic_kernel.kernel_pydantic import KernelBaseModel
class A(KernelBaseModel):
# The notation for the fields is similar to dataclasses.
a: int
b: float
Python: dev_setup and readme updates (#5770) This pull request primarily updates the `DEV_SETUP.md` and `README.md` files in the `python` directory. The changes focus on improving the setup instructions, updating the code snippets, and providing additional information on running tests, code coverage, and keeping the local repository up-to-date. Changes to setup instructions: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90): Added instructions on how to use Python 3.11 with Poetry, how to install pre-commit hooks, and how to run tests using VSCode Tasks. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR112-R114) [[3]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR131-R133) [[4]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252) Code snippets updates: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227): Updated the code snippets to reflect the latest changes in the codebase. This includes changes in the use of Pydantic and the use of KernelBaseModel. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL244-R177) * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01L58-R66): Updated the code snippet to reflect the change in getting request settings from a service ID. Additional information: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252): Added information on how to run code coverage, how to keep the local repository up-to-date, and how to resolve conflicts after a rebase. * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01R7-R14): Added instructions on how to install optional dependencies.
2024-04-04 15:41:27 +02:00
c: list[float]
# Only, instead of using dataclasses.field, you would use pydantic.Field
Python: dev_setup and readme updates (#5770) This pull request primarily updates the `DEV_SETUP.md` and `README.md` files in the `python` directory. The changes focus on improving the setup instructions, updating the code snippets, and providing additional information on running tests, code coverage, and keeping the local repository up-to-date. Changes to setup instructions: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90): Added instructions on how to use Python 3.11 with Poetry, how to install pre-commit hooks, and how to run tests using VSCode Tasks. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR112-R114) [[3]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR131-R133) [[4]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252) Code snippets updates: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227): Updated the code snippets to reflect the latest changes in the codebase. This includes changes in the use of Pydantic and the use of KernelBaseModel. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL244-R177) * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01L58-R66): Updated the code snippet to reflect the change in getting request settings from a service ID. Additional information: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252): Added information on how to run code coverage, how to keep the local repository up-to-date, and how to resolve conflicts after a rebase. * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01R7-R14): Added instructions on how to install optional dependencies.
2024-04-04 15:41:27 +02:00
d: dict[str, tuple[float, str]] = Field(default_factory=dict)
```
#### Classes with data that need to be serialized, and some of them are Generic types
Let's take the following example:
```python
from typing import TypeVar
T1 = TypeVar("T1")
T2 = TypeVar("T2", bound=<some class>)
class A:
def __init__(a: int, b: T1, c: T2):
self.a = a
self.b = b
self.c = c
```
You can use the `KernelBaseModel` to convert these to pydantic serializable classes.
```python
from typing import Generic, TypeVar
from semantic_kernel.kernel_pydantic import KernelBaseModel
T1 = TypeVar("T1")
T2 = TypeVar("T2", bound=<some class>)
class A(KernelBaseModel, Generic[T1, T2]):
# T1 and T2 must be specified in the Generic argument otherwise, pydantic will
# NOT be able to serialize this class
a: int
b: T1
c: T2
```
## Code quality checks
2023-04-12 10:43:01 -07:00
To run the same checks that run during a commit and the GitHub Action `Python Code Quality Checks`, you can use this command, from the [python](../python) folder:
2023-04-12 10:43:01 -07:00
```bash
uv run pre-commit run -a
```
Python: dev_setup and readme updates (#5770) This pull request primarily updates the `DEV_SETUP.md` and `README.md` files in the `python` directory. The changes focus on improving the setup instructions, updating the code snippets, and providing additional information on running tests, code coverage, and keeping the local repository up-to-date. Changes to setup instructions: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90): Added instructions on how to use Python 3.11 with Poetry, how to install pre-commit hooks, and how to run tests using VSCode Tasks. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR112-R114) [[3]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR131-R133) [[4]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252) Code snippets updates: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227): Updated the code snippets to reflect the latest changes in the codebase. This includes changes in the use of Pydantic and the use of KernelBaseModel. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL244-R177) * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01L58-R66): Updated the code snippet to reflect the change in getting request settings from a service ID. Additional information: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252): Added information on how to run code coverage, how to keep the local repository up-to-date, and how to resolve conflicts after a rebase. * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01R7-R14): Added instructions on how to install optional dependencies.
2024-04-04 15:41:27 +02:00
or use the following task (using `Ctrl+Shift+P`):
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
Python: dev_setup and readme updates (#5770) This pull request primarily updates the `DEV_SETUP.md` and `README.md` files in the `python` directory. The changes focus on improving the setup instructions, updating the code snippets, and providing additional information on running tests, code coverage, and keeping the local repository up-to-date. Changes to setup instructions: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90): Added instructions on how to use Python 3.11 with Poetry, how to install pre-commit hooks, and how to run tests using VSCode Tasks. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR112-R114) [[3]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR131-R133) [[4]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252) Code snippets updates: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227): Updated the code snippets to reflect the latest changes in the codebase. This includes changes in the use of Pydantic and the use of KernelBaseModel. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL244-R177) * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01L58-R66): Updated the code snippet to reflect the change in getting request settings from a service ID. Additional information: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252): Added information on how to run code coverage, how to keep the local repository up-to-date, and how to resolve conflicts after a rebase. * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01R7-R14): Added instructions on how to install optional dependencies.
2024-04-04 15:41:27 +02:00
- `Python - Run Checks` to run the checks on the whole project.
- `Python - Run Checks - Staged` to run the checks on the currently staged files only.
Ideally you should run these checks before committing any changes, when you install using the instructions above the pre-commit hooks should be installed already.
Python: dev_setup and readme updates (#5770) This pull request primarily updates the `DEV_SETUP.md` and `README.md` files in the `python` directory. The changes focus on improving the setup instructions, updating the code snippets, and providing additional information on running tests, code coverage, and keeping the local repository up-to-date. Changes to setup instructions: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90): Added instructions on how to use Python 3.11 with Poetry, how to install pre-commit hooks, and how to run tests using VSCode Tasks. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR112-R114) [[3]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR131-R133) [[4]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252) Code snippets updates: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227): Updated the code snippets to reflect the latest changes in the codebase. This includes changes in the use of Pydantic and the use of KernelBaseModel. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL244-R177) * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01L58-R66): Updated the code snippet to reflect the change in getting request settings from a service ID. Additional information: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252): Added information on how to run code coverage, how to keep the local repository up-to-date, and how to resolve conflicts after a rebase. * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01R7-R14): Added instructions on how to install optional dependencies.
2024-04-04 15:41:27 +02:00
## Code Coverage
We try to maintain a high code coverage for the project. To run the code coverage on the unit tests, you can use the following command:
```bash
uv run pytest --cov=semantic_kernel --cov-report=term-missing:skip-covered tests/unit/
Python: dev_setup and readme updates (#5770) This pull request primarily updates the `DEV_SETUP.md` and `README.md` files in the `python` directory. The changes focus on improving the setup instructions, updating the code snippets, and providing additional information on running tests, code coverage, and keeping the local repository up-to-date. Changes to setup instructions: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90): Added instructions on how to use Python 3.11 with Poetry, how to install pre-commit hooks, and how to run tests using VSCode Tasks. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR112-R114) [[3]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR131-R133) [[4]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252) Code snippets updates: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227): Updated the code snippets to reflect the latest changes in the codebase. This includes changes in the use of Pydantic and the use of KernelBaseModel. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL244-R177) * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01L58-R66): Updated the code snippet to reflect the change in getting request settings from a service ID. Additional information: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252): Added information on how to run code coverage, how to keep the local repository up-to-date, and how to resolve conflicts after a rebase. * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01R7-R14): Added instructions on how to install optional dependencies.
2024-04-04 15:41:27 +02:00
```
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
Python: dev_setup and readme updates (#5770) This pull request primarily updates the `DEV_SETUP.md` and `README.md` files in the `python` directory. The changes focus on improving the setup instructions, updating the code snippets, and providing additional information on running tests, code coverage, and keeping the local repository up-to-date. Changes to setup instructions: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90): Added instructions on how to use Python 3.11 with Poetry, how to install pre-commit hooks, and how to run tests using VSCode Tasks. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR112-R114) [[3]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR131-R133) [[4]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252) Code snippets updates: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227): Updated the code snippets to reflect the latest changes in the codebase. This includes changes in the use of Pydantic and the use of KernelBaseModel. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL244-R177) * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01L58-R66): Updated the code snippet to reflect the change in getting request settings from a service ID. Additional information: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252): Added information on how to run code coverage, how to keep the local repository up-to-date, and how to resolve conflicts after a rebase. * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01R7-R14): Added instructions on how to install optional dependencies.
2024-04-04 15:41:27 +02:00
or use the following task (using `Ctrl+Shift+P`):
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
Python: dev_setup and readme updates (#5770) This pull request primarily updates the `DEV_SETUP.md` and `README.md` files in the `python` directory. The changes focus on improving the setup instructions, updating the code snippets, and providing additional information on running tests, code coverage, and keeping the local repository up-to-date. Changes to setup instructions: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90): Added instructions on how to use Python 3.11 with Poetry, how to install pre-commit hooks, and how to run tests using VSCode Tasks. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR112-R114) [[3]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR131-R133) [[4]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252) Code snippets updates: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227): Updated the code snippets to reflect the latest changes in the codebase. This includes changes in the use of Pydantic and the use of KernelBaseModel. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL244-R177) * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01L58-R66): Updated the code snippet to reflect the change in getting request settings from a service ID. Additional information: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252): Added information on how to run code coverage, how to keep the local repository up-to-date, and how to resolve conflicts after a rebase. * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01R7-R14): Added instructions on how to install optional dependencies.
2024-04-04 15:41:27 +02:00
- `Python: Tests - Code Coverage` to run the code coverage on the whole project.
This will show you which files are not covered by the tests, including the specific lines not covered. Make sure to consider the untested lines from the code you are working on, but feel free to add other tests as well, that is always welcome!
Python: dev_setup and readme updates (#5770) This pull request primarily updates the `DEV_SETUP.md` and `README.md` files in the `python` directory. The changes focus on improving the setup instructions, updating the code snippets, and providing additional information on running tests, code coverage, and keeping the local repository up-to-date. Changes to setup instructions: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90): Added instructions on how to use Python 3.11 with Poetry, how to install pre-commit hooks, and how to run tests using VSCode Tasks. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR112-R114) [[3]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR131-R133) [[4]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252) Code snippets updates: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227): Updated the code snippets to reflect the latest changes in the codebase. This includes changes in the use of Pydantic and the use of KernelBaseModel. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL244-R177) * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01L58-R66): Updated the code snippet to reflect the change in getting request settings from a service ID. Additional information: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252): Added information on how to run code coverage, how to keep the local repository up-to-date, and how to resolve conflicts after a rebase. * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01R7-R14): Added instructions on how to install optional dependencies.
2024-04-04 15:41:27 +02:00
## Catching up with the latest changes
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
Python: dev_setup and readme updates (#5770) This pull request primarily updates the `DEV_SETUP.md` and `README.md` files in the `python` directory. The changes focus on improving the setup instructions, updating the code snippets, and providing additional information on running tests, code coverage, and keeping the local repository up-to-date. Changes to setup instructions: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90): Added instructions on how to use Python 3.11 with Poetry, how to install pre-commit hooks, and how to run tests using VSCode Tasks. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR112-R114) [[3]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR131-R133) [[4]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252) Code snippets updates: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227): Updated the code snippets to reflect the latest changes in the codebase. This includes changes in the use of Pydantic and the use of KernelBaseModel. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL244-R177) * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01L58-R66): Updated the code snippet to reflect the change in getting request settings from a service ID. Additional information: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252): Added information on how to run code coverage, how to keep the local repository up-to-date, and how to resolve conflicts after a rebase. * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01R7-R14): Added instructions on how to install optional dependencies.
2024-04-04 15:41:27 +02:00
There are many people committing to Semantic Kernel, so it is important to keep your local repository up to date. To do this, you can run the following commands:
```bash
git fetch upstream main
git rebase upstream/main
git push --force-with-lease
```
Python: Fix function call content argument parsing (#10132) ### 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. --> This PR includes changes to improve the handling of JSON parsing when it fails to be parsed as it is in function call arguments by adding a regular expression for preprocessing JSON strings to remove single quotes only when they are not escaped. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Enhancements to JSON parsing: * [`python/semantic_kernel/contents/function_call_content.py`](diffhunk://#diff-1f5f27eade7117045bc9e62d66ebef5c93047142cdb4fd0115b0ff8eadf2f69cL152-R164): Modified `parse_arguments` method to preprocess JSON strings by replacing single quotes with double quotes, except for escaped single quotes. Added a debug log for invalid JSON. Test file updates: * [`python/tests/unit/contents/test_function_call_content.py`](diffhunk://#diff-6e891b3044d5bf5caa7abc97a44ef11ce291aba01fa8032ab1104773f4545c9dR135-R148): Added new tests for parsing single-quoted JSON strings. Renamed the test file from `test_function_call.py` to `test_function_call_content.py`. ### 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:
2025-01-09 02:47:09 -08:00
Python: dev_setup and readme updates (#5770) This pull request primarily updates the `DEV_SETUP.md` and `README.md` files in the `python` directory. The changes focus on improving the setup instructions, updating the code snippets, and providing additional information on running tests, code coverage, and keeping the local repository up-to-date. Changes to setup instructions: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90): Added instructions on how to use Python 3.11 with Poetry, how to install pre-commit hooks, and how to run tests using VSCode Tasks. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR75-R90) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR112-R114) [[3]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cR131-R133) [[4]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252) Code snippets updates: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227): Updated the code snippets to reflect the latest changes in the codebase. This includes changes in the use of Pydantic and the use of KernelBaseModel. [[1]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL140-L227) [[2]](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL244-R177) * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01L58-R66): Updated the code snippet to reflect the change in getting request settings from a service ID. Additional information: * [`python/DEV_SETUP.md`](diffhunk://#diff-22a026622159be328328c5bb6fef874e8aa799efb6ab8844d0c94ad051b08f3cL287-R252): Added information on how to run code coverage, how to keep the local repository up-to-date, and how to resolve conflicts after a rebase. * [`python/README.md`](diffhunk://#diff-217ed82f87b78b399e304b07a159b27dff327c0f83adf4a2fc30b03bcbf84b01R7-R14): Added instructions on how to install optional dependencies.
2024-04-04 15:41:27 +02:00
or:
```bash
git fetch upstream main
git merge upstream/main
git push
```
This is assuming the upstream branch refers to the main repository. If you have a different name for the upstream branch, you can replace `upstream` with the name of your upstream branch.
After running the rebase command, you may need to resolve any conflicts that arise. If you are unsure how to resolve a conflict, please refer to the [GitHub's documentation on resolving conflicts](https://docs.github.com/en/get-started/using-git/resolving-merge-conflicts-after-a-git-rebase), or for [VSCode](https://code.visualstudio.com/docs/sourcecontrol/overview#_merge-conflicts).