SIGN IN SIGN UP

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

0 0 11 C#
Python: Unsafe input handling (#6003) ### 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. --> Implements dealing with unsafe content, by doing HTML parsing on variables and function results. Closes: #5889 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Adds parameter `allow_dangerously_set_content` to: - InputVariable - PromptTemplateConfig - PromptTemplateBase The behavior is that if the flag is set to True on the template itself (KernelPromptTemplate, Jinja2PromptTemplate or HandlebarsPromptTemplate) the behavior is the same, no encoding is done on inputs. Otherwise: - variables are encoded by default, this can be switched off using the InputVariables class for that variable. - function output is encoded by default, this can be switched off using the flag in the PromptTemplateConfig, this is not yet possible to do on a per function basis. ### 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-16 15:02:54 +02:00
# Copyright (c) Microsoft. All rights reserved.
Python: Unsafe input handling (#6003) ### 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. --> Implements dealing with unsafe content, by doing HTML parsing on variables and function results. Closes: #5889 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Adds parameter `allow_dangerously_set_content` to: - InputVariable - PromptTemplateConfig - PromptTemplateBase The behavior is that if the flag is set to True on the template itself (KernelPromptTemplate, Jinja2PromptTemplate or HandlebarsPromptTemplate) the behavior is the same, no encoding is done on inputs. Otherwise: - variables are encoded by default, this can be switched off using the InputVariables class for that variable. - function output is encoded by default, this can be switched off using the flag in the PromptTemplateConfig, this is not yet possible to do on a per function basis. ### 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-16 15:02:54 +02:00
from typing import Final
METADATA_EXCEPTION_KEY: Final[str] = "exception"
DEFAULT_SERVICE_NAME: Final[str] = "default"
Python: Updates to user agent. Add unit tests. (#6824) ### Motivation and Context Updates to the User-Agent are required so that we can align with all three SK languages. Examples: User agent - semantic-kernel-csharp/1.1.1 [existing user agent] - semantic-kernel-java/1.1.1 [existing user agent] - semantic-kernel-python/1.1.1 [existing user agent] semantic-kernel-version header - csharp/1.1.1 - java/1.1.1 - python/1.1.1 <!-- 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 Updates to the user agent to reflect the desired changes/standardization across all SK languages. Adding unit tests. - Closes #6827 - Moves the `USER_AGENT` const from its previous home in the openai const file to a more generic const file. - Updates unit tests to be able to run properly when a valid `.env` file exists in the current working directory. The unit tests patch the env vars and our current implementation of Pydantic Settings loads the `.env` file if not specified. <!-- 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-06-20 11:02:01 -04:00
USER_AGENT: Final[str] = "User-Agent"
PARSED_ANNOTATION_UNION_DELIMITER: Final[str] = ","
Python: Bedrock connector (#9100) ### 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. --> Add Amazon Bedrock AI to Semantic Kernel. Amazon Bedrock is a platform on AWS that offers access to a wide range to LLMs, including proprietary Amazon Titan models. We are integrating it into Semantic Kernel as one of our AI connectors to provide more options to developers. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> 1. All interfaces implemented: chat completion (streaming + non-streaming), text completion (streaming + non-streaming), and text embedding. 2. Supports for function calling. 3. Supports for image content. 4. Supports for all models available on Bedrock. ### 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-10-10 15:33:42 -07:00
DEFAULT_FULLY_QUALIFIED_NAME_SEPARATOR: Final[str] = "-"
Python: More telemetry in AI services (#8641) ### 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. --> Add more telemetry to our built-in AI services, and update the telemetry sample app to show case the changes. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist The following items are added: 1. Add tracing to all streaming APIs via the `trace_streaming_xxx` decorators. 2. Wrap auto function invocation, with span name set to `AutoFunctionInvocationLoop`. Available functions will be recorded by the attribute `sk.available_functions`. 3. Common completion usage interface. 4. Add a test to make all APIs are instrumented. 5. Record service address when possible. Updates made to the telemetry sample app: 1. Rename to `telemetry` from `telemetry_with_application_insights`. 2. Add sample code showing auto function calling. 3. Reorganize the sample by scenarios. 4. Add more output options: Aspire dashboard and console. 6. Update Readme. TODO: Add unit tests from the streaming decorators and improve code converage. <!-- 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-09-12 09:51:49 -07:00
AUTO_FUNCTION_INVOCATION_SPAN_NAME: Final[str] = "AutoFunctionInvocationLoop"