### Motivation and Context
New release version 0.2.6
Fix bug in 0.2.5.dev0 pip package
Update notebooks to the latest pip package (0.2.6)
### Description of Changes
- fixed a param name error in the creation of a reference memory_record
- renamed text_service -> text_completion_service (consistency with .NET)
- renamed text_embedding_service -> text_embedding_generation_service
(consistency with .NET)
- Updated notebooks accordingly
- bumped pip versions to 0.2.6.dev0
### Motivation and Context
An unexpected exception is being thrown when attempting to find nearest
vectors and no vectors exist. This results in the current completion
activity to fail. An example of this behavior can be observed in the
copilot-sample-app by changing the MemoriesStore type in appsettings
from "volatile" to "qdrant". All subsequent chat completions will fail.
There are seven other API requests in this same class which all use
roughly the same conventions and handling of the HTTP request /
response. _FindNearestInCollectionAsync_ is the only one of the eight
total which doesn't explicitly check or catch to prevent an exception.
For more details and context, see the write-up outlined in the linked
issue: #694
### Description
Align HTTP response behavior in FindNearestInCollectionAsync to match
the consistent behavior uniformly observed for HTTP request/response
handling. This amounts to simply breaking when the response status code
is NotFound.
### Motivation and Context
This PR introduces the ability to run formal integration tests for
python using pytest - separated from unit tests for easier automation.
### Description
- moved `python/tests/end-to-end` directory to
`python/tests/integration`
- renamed integration tests to test_* pattern so pytest will detect them
- import `GenerationConfig` for hugging face completions - according to
logs, this is the recommended practice
### Motivation and Context
My company network needs more custom set up in HttpClient to make calls,
but SK OpenAI code only allows me to pass a hander delegate factory. I
cannot use SK without more settings in HttpClient and I want to pass in
my own instances anyway so I can manage them from my application.
I think I am not the only one to need this:
- https://github.com/microsoft/semantic-kernel/issues/527
- https://github.com/microsoft/semantic-kernel/issues/133
See
https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines.
### Description
Changes included:
- The OpenAI and AzureOpenAI connectors take optional HttpClient? in the
constructor methods instead of IDelegatingHandlerFactory
- Note first approach was adding two new constructor methods to each
type so you could choose. But two constructors could not be there
together with optional HttpClient? in one and optional
IDelegatingHandlerFactory? in the other because it made calls ambiguous.
Then I tried making HttpClient not optional, but that made the parameter
order different because in some there are also other optional parameters
like openai `string? organization = null`. So the not optional
HttpClient would have to come BEFORE optional openai organization in one
constructor, but the optional IDelegatingHandlerFactory comes AFTER
optional openai organization in another constructor. In the end it
seemed better to just take HttpClient and do the custom client creation
in the extension methods. I hope this is okay I know it is a bigger
change than I planned.
- IDelegatingHandlerFactory is not being used as a factory in these Open
AI connector classes anyway. They use it one to create an HttpClient
instance in the constructor method anyway and never call it again so
it's just as easy to pass in the HttpClient you want.
- Updated the extension methods in `KernelConfigOpenAIExtensions` so
that they can optionally pass in a custom HttpClient and ILogger. If
null then it uses the same defaults as before.
- There was some mix use of `Logger log` and `ILogger logger` in
different places so on the parts I changed I set these all to "logger"
because it makes it more clear that it is a object and not a "log"
method. I can undo if you don't like this.
- Changed "credentials" to "credential" to match this is one
`TokenCredenial` not a credential collection. I can undo if you don't
like this.
- Made the default HttpClientHandler static and shared for new
HttpClients with `disposeHandler: false`
https://github.com/dotnet/runtime/issues/16255
- Updated a sample Program
- I can add more tests if required
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [X] The code builds clean without any errors or warnings
- [X] The PR follows SK Contribution Guidelines
(https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
- [X] The code follows the .NET coding conventions
(https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions)
verified with `dotnet format`
- [X] All unit tests pass, and I have added new tests where possible
- Most tests pass but it skips some because I don't have keys for all
these model types so I hope your github build will run this and double
check.
- [ ] I didn't break anyone 😄
- I changed the constructor method args in the OpenAI code, and the will
break your users that are creating these open ai classes using their
constructors directly. If the users are using the extension methods
(AddAzureOpenAI) then they should not have problems.
- If you want I can put back all of the constructor methods so they can
be created with HttpClient or IDelegatingHandlerFactory but with
parameters orders different as explained
- I don't think those classes need to be aware of
IDelegatingHandlerFactory or have it included in the constructor
methods, since the extension method or calling code can always convert
to HttpClient before calling.
### Motivation and Context
Azure Cognitive Search is a managed service on Azure that allows to
store data and search it using natural language.
### Description
Add a new Semantic Memory Connector leveraging Azure Cognitive Search.
Update the syntax example to show how it seamlessly provides
`ISemanticTextMemory` API without the need to use embeddings.
Co-authored-by: Adrian Bonar <[email protected]>
Remove custom ValidationException in favor of using built-in .NET
exception types typically used for the same purposes.
### Description
The conditions ValidationException was used for validating are better
suited to existing .NET exception types that .NET developers expect in
those situations.
- NotNullOrWhiteSpace is represented with ArgumentException.
- Directory not found is represented with DirectoryNotFoundException
- Invalid state of an object (e.g. a field not being initialized) is
represented with InvalidOperationException
Argument validation exceptions are also usage exceptions typically not
intended to be caught. The same would go for the ValidationExceptions
that were serving the same purpose, so having a separate type identity
for those exceptions isn't desirable.
There are more of these in unit tests and samples, where I think it's
not a big deal. The PR fixes code in the SDK (one false positive simply
resolved using ICollection) and code that could be copied into other
projects.
Co-authored-by: Adrian Bonar <[email protected]>
* Fix filename containing a space (`ApiKeyAuthenticationHandler .cs`)
* Fix typos
* Fix code style
* Add missing rule for local constants
* Add commented code to automate code style checks. These don't work
with .NET Standard 2.0, so we'll need some extra research.
* Fix one incorrect ILogger naming
* Add some TODOs about unused code
* Fix xmldocs
### Motivation and Context
When configuring AI models (text completion, embeddings, chat, image
generation, etc) currently one has to pass a "service Id", ie assign a
name to the configuration. This allows apps to work with different
models providing the same features, e.g. working with OpenAI and Azure
OpenAI and HuggingFace at the same time.
In many scenarios though, there is only one AI model/service provider,
e.g. an app might be using just Open AI, and in this case service names
are unused.
Also, the kernel config API allows to remove AI models from the
configuration, a tentative feature that has never been used and can be
removed for now, and reintroduced if we find scenarios or get explicit
requests.
### Description
* Make the Service ID optional, making the AI configuration simpler
* Remove some unused API, reducing the complexity of kernel config
Co-authored-by: Adrian Bonar (HE/HIM) <[email protected]>
### Motivation and Context
Provide an example implementation of connecting the Semantic Kernel to
external plugins following the open api schema.
### Description
Jira Open API schema usage example
Renaming the azure key vault example, so all open api skill examples are
grouped together
Prevent RestApiOperationRunner.cs from wrapping a json response into a
json object.
These are all handled by the corresponding overload that takes an
optional CancellationToken. Their presence also means the optionality of
the tokens in the other overloads would never actually be used.
### Motivation and Context
Hard to debug errors when there are leading or trailing spaces in
configuration values.
### Description
Trim all configuration strings on startup.
### Motivation and Context
Clean up exposure and handling of CancellationToken in public APIs.
### Description
- In public API, they should always be the last parameter (unless they
can't be, e.g. due to a params array), named "cancellationToken", and be
non-nullable.
- Ensure they're forwarded appropriately from one API to the next. There
may be some more missing cases, but I fixed all the ones I found.
- Make the XML docs consistent.
- Remove unnecessary cancellation-related analyzer suppressions
### Motivation and Context
Avoid use of Regex's static methods.
### Description
The static methods on Regex are convenient, but they're also a bit of a
performance trap. Parsing regexes is fairly expensive, so that static
methods employ a MRU cache to avoid reparsing on every use, but a) that
cache has cost to access and b) the cache is very small by default. The
net result is usage of other static Regex methods elsewhere in the app
can make the use of the static methods in SK much more expensive. Regex
is thread-safe, and it's better to just store the necessary instances
into readonly static fields and then use the instance methods on those.
Note that there is an analyzer that flags these, but it's only available
when targeting .NET 7+, where it recommends (and provides a fixer) for
turning them into source-generated regexes using [GeneratedRegex(...)].
[see #537 - PR rebuilt to fix nuget dependency and merge conflicts]
### Motivation and Context
Allow the usage of Google search equivalent to current Bing search
implementation.
### Description
Uses the Google.Apis.CustomSearchAPI.v1 packages to interface with the
Google search API, this requires an API key from GCP and a custom search
engine ID
---------
Co-authored-by: Scott Kane <[email protected]>
### Motivation and Context
The chat history skill handles the creation of new chat sessions,
retrieval of chat sessions and messages, and editing of chat titles. It
was unnecessary and improper to use a skill to handle non-AI related
task.
### Description
Replace the chat history skill with a controller that provides APIs to
handle the above-mentioned tasks.
### Motivation and Context
This PR significantly reduces the complexity of implementing a new
memory store. Previously, memory stores needed to implement
EmbeddingIndexBase, DataStoreBase, and MemoryStoreBase. Now, memory
stores only need to implement MemoryStoreBase. This PR also brings
MemoryStoreBase to parity with the .NET IMemoryStore interface.
### Description
- Removed `data_entry.py`, `data_store_base.py`,
`volatile_data_store.py`, and `embedding_index_base.py`
- Added `with_embedding` parameter to all get/search methods. Passing
the embedding between the application and storage is not optional and
defaults to False
- `MemoryStoreBase` (Python SK) == `IMemoryStore` (.NET SK)
- Updated `volatile_memory_store` to implement `MemoryStoreBase`
- Removed `ABC` from `MemoryStoreBase`
- Added documentation to memory files
Closes https://github.com/microsoft/semantic-kernel/issues/670
### Motivation and Context
New code example showing how to render prompts, e.g. in cases where one
wants to leverage semantic functions but execute them with a custom
flow, e.g. passing prompts to GPT Turbo 3.5.
The example shows the basics of how one could add a chat UI into an app,
selecting some piece of content, and asking AI to extract data. In this
case, instead of calling a semantic function, the code calls a Chat
model directly, to leverage chat model protections against prompt
injection.
### Description
* New syntax example, explaining how to use `PromptTemplateEngine`
* Make one chat service param optional, to simplify the code
### Motivation and Context
New Python API changes the signature for invoke_async.
This aligns it and makes it clearer that the context passed into
invoke_async are context variables.
This fixes the current issue where the chat function will just repeat
back the user input instead of actually chatting
---------
Co-authored-by: Abby Harrison <[email protected]>
The AIException constructor that takes an errorCode, a message, and a
detail was incorrectly passing null as the detail parameter to the base
constructor. This commit fixes this bug by passing the detail parameter
correctly. This ensures that the detail information is preserved and
available for error handling.
### Motivation and Context
Bug Introduced: #701
Bug Hidden by: #596
### Motivation and Context
Integration tests have stopped running due to #596
### Description
This updates the yml to properly include any projects of the form
`*IntegrationTests.csproj`
There are failing tests due to changes recently that were not caught.
Will fix those separately.
Fixes scrollbar issue on main view (would show a double scrollbar on
zoom. now scroll only shows on chat history component and conversations
as necessary)
Currently the document import feature only supports .txt files. We would
like to support PDF files as well.
### Description
1. Add PdfPig 0.1.8 to the project as the lib to read PDFs.
2. Update READMEs.
Added a check for empty goal in CreatePlanAsync method and threw a
PlanningException with appropriate error code. Wrapped the plan parsing
logic in a try-catch block and re-threw any exceptions as
PlanningExceptions with a different error code. This improves the
robustness and usability of the SequentialPlanner class.
This commit simplifies the labeler rules for the kernel label by using
the any and all operators instead of a list of patterns. This makes the
rules more readable and easier to maintain and ensures `kernel` label is
used as appropriate. The logic of the rules still exclude the
SemanticKernel and SemanticKernel.Abstractions projects from the kernel
label but will now include if only non-core kernel changes are made.
### Motivation and Context
This PR changes the way payload/body for POST and PUT operations is
resolved.
This change is required to support the following scenarios:
- A POST/PUT operation payload has more than one property with the same
name - { 'sender': { '**name**': 'val1'}, 'receiver': {'**name**':
'val2'} }
- A POST/PUT operation payload has a property of array of objects with
the same name - { 'receivers': [ {'**name**':'val1'},
{'**name**':'val2'} ] }
- A POST/PUT operation payload metadata is missing.
### Description
Curent RestApi functionality builds operation payload dynamically and
relies on:
- Payload metadata that describes the payload/body schema/shape and
usually obtained from OpenAPI documents.
- Arguments resolution mechanism that resolves payload parameters in SK
context.
As practice shows, in some cases (malformed OpenAPI document), the
payload metadata is missing which means that it's not possible to create
operation payload dynamically and as a result it's not possible to run
the operation. In other cases, if a payload has two of more parameters
with the same name or parameters of array type with object items it is
impossible to resolve them from SK context.
To support these scenarios, the RestApi functionality does not build the
payload dynamically anymore and instead relies on either AI or a caller
of the APi to create/supply it. To help AI generate the payload, a new
schema property will be added to the ParameterView class to describe the
payload structure/shape to AI.
### Motivation and Context
Use ArgumentNullException as devs expect, and avoid exception-related
work when not throwing.
### Description
.NET developers expect that passing null erroneously to a method will
result in an ArgumentNullException, but currently it's resulting in a
custom ValidationException.
There are also places where string interpolation is being used to create
the error message; the work and allocation associated with that
interpolation is going to happen regardless of whether the exception is
thrown or not.
### Motivation and Context
Fixes https://github.com/microsoft/semantic-kernel/issues/573
### Description
- Make the base class non-generic and rename it to SKException
- Remove unnecessary private ctors from derived types
- Clean up how messages are generated
### Motivation and Context
Qdrant was failing in CopilotChat on first use when querying for vectors
in collections that don't exist yet.
### Description
- Swallow 404s from Qdrant when querying for nearest match.