Commit Graph
37 Commits
Author SHA1 Message Date
d019485568 Python: Update notebooks and add samples for streaming and multiple responses (#1489)
### Motivation and Context
The python notebooks are pinned to 0.2.7.dev0 while the latest pip
package for python is 0.3.1.dev0. This PR updates the notebooks to pull
the 0.3.1.dev0 and adds 2 new notebooks demonstrating new features added
to SK between these versions.


### Description
- All notebooks depend on semantic-kernel==0.3.1.dev0
- Added a notebook demonstrating streaming completion responses
- Added a notebook demonstrating multiple responses per prompt
(including streaming them)


### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows SK Contribution Guidelines
(https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
- [ ] The code follows the .NET coding conventions
(https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions)
verified with `dotnet format`
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄

---------

Co-authored-by: Lee Miller <[email protected]>
Co-authored-by: Shawn Callegari <[email protected]>
2023-07-08 03:22:42 +00:00
451b640cb3 Feature/notebook bing search (#1729)
### 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.
-->


### Description
I have added a new notebook to show how to bring search functionality in
SK


### 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
- [x] I didn't break anyone 😄

---------

Co-authored-by: newton.mallick <[email protected]>
Co-authored-by: Gina Triolo <[email protected]>
2023-07-05 21:26:07 +00:00
Matthew C. AndersonandTeresa Hoang 4f4dbd5b84 Python: Add option for Azure OpenAI to notebook sample 06 (#1529)
### Motivation and Context
This is addressing issue
[1528](https://github.com/microsoft/semantic-kernel/issues/1528)

### Description
In the Jupyter notebook for Python sample
[06-memory-and-embeddings](https://github.com/microsoft/semantic-kernel/blob/main/samples/notebooks/python/06-memory-and-embeddings.ipynb),
I updated the sample to include support for Azure OpenAI.

This includes: 
- Importing classes for AzureTextCompletion and AzureTextEmbedding, 
- Adding a switch to choose OpenAI or Azure OpenAI Service.

### 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
- [x] I didn't break anyone 😄

---------

Co-authored-by: Teresa Hoang <[email protected]>
2023-06-20 17:27:50 +00:00
4b68d6a1e3 Add Grounding Skill to Samples (#1064)
### Motivation and Context
This introduces functions related to groundedness checking, based on
learnings from the Aether Central team. The skills are showcased in both
an Python notebook and a .NET sample.

---------

Co-authored-by: Lee Miller <[email protected]>
Co-authored-by: Lee Miller <[email protected]>
2023-06-15 11:48:41 -07:00
Matthew C. Anderson d5de382117 Python: added reference to AzureTextCompletion to notebook (#1456)
### Motivation and Context
This is addressing issue#1455
https://github.com/microsoft/semantic-kernel/issues/1455

### Description
In the second cell, I added the missing reference to Azure Text
Completion.

In the _Context Variables_ section, I updated the first cell to include
an option to run using Azure OpenAI (was missed previously). This
follows the same format as used in other cells.
2023-06-14 19:31:45 +00:00
Robin-Manuel Thiel 3dce34ca3f Consistent Defaults in Python Notebooks (#1411)
### Description
Consistently use `useAzureOpenAI = False` in Python Notebooks. I
stumbled over this. Default was always false.
2023-06-13 01:13:06 +00:00
Robin-Manuel Thiel eafe8c7625 Print Chat History at the end of Notebooks (#1412)
### Motivation and Context
When working through the notebooks, I had the feeling that printing the
chat history at the end, makes it much clearer how it actually looks
like after a bunch of chats. I would like to see this added for
everyone.


### Description
Printing the chat history in the Notebooks at the end of the _Planner_
section
2023-06-12 20:06:15 +00:00
ShukriandDan Dascalescu e4781e51d4 Add sample notebook to demo weaviate memory store (#1359)
### Motivation and Context
  1. Why is this change required?
      To show users how to use the WeaviateMemoryStore memory store
  2. What problem does it solve?
Users don't know how to config and use the WeaviateMemoryStore memory
store
  3. What scenario does it contribute to?
Users want to learn how to config and use the WeaviateMemoryStore memory
store
  4. If it fixes an open issue, please link to the issue here.
      NA

### Description
Add a notebook to show users how to config and use the
WeaviateMemoryStore memory store in a few examples.
---------

Co-authored-by: Dan Dascalescu <[email protected]>
2023-06-10 04:10:39 +00:00
Alex Chao dae1c16786 Python: Added examples of using ChatCompletion models for skill building in Jupyter Notebooks (#1242)
### Motivation and Context
Many people run into the issue of wanting to use ChatCompletion models
like gpt-35-turbo or gpt4 for building Semantic Skills but aren't aware
that they need to update the API to do so. This adds some examples in
the Jupyter notebooks to illustrate the concept.
2023-06-09 14:10:35 -07:00
Matt Mazzola f4e92eb1de fix: Add Azure OpenAI support for python/08-native-function-inline (#1365)
### Motivation and Context

Other Semantic Kernal samples allow using both OpenAI and Azure OpenAI
by setting a different set of environment variables and toggling the
`useAzureOpenAI` bool value

### Description

Add the same snippet used in other notebooks such as
`02-running-prompts-from-file` to use Azure OpenAI to the
`08-native-function-inline`
2023-06-09 00:13:52 +00:00
Lee Miller de74668637 Fixing typos (#1377)
### Motivation and Context
Fixing typos to unblock PRs.
2023-06-08 17:41:02 +00:00
Mars Wang 77e7272e74 Change the description of the comment due to no "Deployment ID" on Az… (#1290)
…ure OpenAI, should be "Deployment Name"
<img width="968" alt="Screenshot 2023-06-01 at 00 39 02"
src="https://github.com/microsoft/semantic-kernel/assets/68472667/844fddbf-77fe-463d-af90-3fee94044b02">
2023-06-01 19:04:08 +00:00
0ebc599f57 Adding Python notebook for native function examples (#699)
### Motivation and Context
This PR is intended to give some functioning examples to help users get
started with python native functions.
Currently, there are no examples or very limited examples. When I was
playing around with this tool I ended up using some of the integration
tests as examples to help get started. Hopefully, this will help the
next user with the lessons learned.


### Description
This adds a jupyter notebook that walks users through using native
functions alongside semantic functions to build a simple story writing
app. This notebook also shows how to use ContextVariables and run a
semantic function from within a native function.

Co-authored-by: Carter Williamson <[email protected]>
Co-authored-by: Devis Lucato <[email protected]>
Co-authored-by: Alex Chao <[email protected]>
2023-05-22 12:49:24 -07:00
Richard Edgar a414592fc5 Fix authentication in notebook (#1022)
### Motivation and Context
Fix an authentication issue with the fourth Python notebook, by copying
from one of the others.

Fixes #1021
2023-05-17 21:13:36 -07:00
Devis Lucato fd1e014618 Spell checking automation + fix typos (#977)
Spell checking automation:
* Add typos checker to PR flow using
https://github.com/marketplace/actions/typos-action
* Fix existing typos
* Add config file, with exclusions and exceptions: `.github/_typos.toml`

The checker can be run locally, e.g.

* Install: `brew install typos-cli`
* Install: `conda install typos`

Run: `typos -c .github/_typos.toml`
2023-05-12 20:04:16 +00:00
7ed26eacaa Python: Update notebooks by pinning pip package and removing requirements.txt (#868)
### Motivation and Context

* Removing the requirements.txt and just pinning each notebook to a pip
package that should work.
Doing this allows users to run notebooks without error even if the code
in the core repo updates.
When a new pip package is released, we will bump the version number in
each notebook.
* Fix usage of context variables. Apps should avoid using anonymous
context variables and prefer using the context, to retain access to the
kernel internals during the orchestration.

---------

Co-authored-by: Alex Chao <[email protected]>
Co-authored-by: Devis Lucato <[email protected]>
2023-05-08 18:13:17 -07:00
Mark KarleandShawn Callegari 3e1d13e945 Merge KernelConfig with Kernel (#731)
### Motivation and Context
KernelConfig isn't needed as it's less pythonic and is not used
independently from Kernel. This moves all its methods and members into
Kernel.

### Description
- Removed KernelConfig
- Put KernelConfig's methods and variables into Kernel
- Ran unit and end-to-end tests
- Did not run notebooks because they are out of date with the current
repo.

---------
Co-authored-by: Shawn Callegari <[email protected]>
2023-05-05 22:27:49 -07:00
Abby Harrison a9b61b2cf4 Python: Optional dependencies (#820)
### Motivation and Context
The release of Python SK from 0.2.4 -> 0.2.6 significantly increased the
size of the pip package. The dependencies causing this are not core to
the kernel, so this PR establishes a pattern for SK connector
dependencies (ex: Hugging Face, memory storage)

### Description
- Added a poetry group called hugging_face - this is the same name as
the connectors namespace in the code.
- Added dependency installs to the Hugging Face sample notebook.
- removed Hugging Face dependencies from requirements.txt.
- Added import errors for torch, transformers, and sentence-transformers
in the hugging_face connector classes.
- Added command `--with hugging_face` to integration test setup.
2023-05-06 03:35:13 +00:00
224857ebc3 Python: Basic JSON-based Planner implementation (#597)
### Motivation and Context
Many users and customers have expressed interest in having planning
capabilities in Python. This PR seeks to provide a basic version of the
planner so that people can learn and play around with the concepts and
can be comfortable with implementing their own versions.

A Jupyter notebook is included. 

### Description
Most of the logic of the plan can be found under the `PROMPT` in
`basic_planner.py`.

There is a known limitation that this currently doesn't explicit parse
out arguments that are defined in the semantic function prompts, so when
creating the [AVAILABLE FUNCTIONS] string, it just uses the name of the
function and the description.

The execution of the plan also happens from start to finish. There is
currently no support for piecewise execution.

---------

Co-authored-by: Alex Chao <[email protected]>
Co-authored-by: Alex Chao <[email protected]>
Co-authored-by: Abby Harrison <[email protected]>
Co-authored-by: Mark Karle <[email protected]>
2023-05-04 22:04:36 +00:00
Abby Harrison f08051fa8f Python/hf example notebook (#762)
### Motivation and Context
This PR adds a notebook to the python samples demonstrating how to use
SK with hugging face models.

### Description
- add notebook 07-hugging-face-for-skills.ipynb
2023-05-04 09:48:21 -07:00
Abby Harrison 04206c67dc Python: Update Notebooks to version 0.2.6.dev0; Fix bug in 0.2.5.dev0 (#761)
### 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
2023-05-01 17:16:01 -07:00
Alex ChaoandAbby Harrison f4758ff50d Fix Notebook 04 for invoke_async with context variables (#672)
### 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]>
2023-04-28 14:32:29 +00:00
Shukri eea509e235 Fix typo in docs (#669)
### Motivation and Context

Fix some typos in the python sample notebooks
2023-04-27 00:15:03 -07:00
chuan 2d2dd7179b use i += 1 instead of ++i, because Python didn't support ++i (#665)
### Motivation and Context
1. Why is this change required? **Although it does not affect the main
logic, it is still recommended to make corrections.**
2. What problem does it solve? **use i += 1 instead of ++i, because
Python didn't support ++i**
2023-04-26 07:34:58 +00:00
Abby Harrison c9b9220333 Refactor 'AI Backend' -> 'AI Service'; Move AI Namespace to semantic_kernel.connectors.ai (#595)
### Motivation and Context
This PR is a consistency update between the Python and .NET Semantic
Kernels.

**This PR does not contain any feature enhancements or improvements!**

### Description
- Replace terminology 'backend' with 'service'
- Move semantic_kernel.ai (semantic_kernel/ai) to
semantic_kernel.connectors.ai (semantic_kernel/connectors/ai)
2023-04-25 00:01:16 +00:00
Masaki Yamamoto 5bd451762b fixed error notebboks pyhon 4 when useAzureOpenAI equals True (#600)
### Motivation and Context
I fixed error `useAzureOpenAI = True` on
`samples/notebooks/python/04-context-variables-chat.ipynb`

### Description
before:

![image](https://user-images.githubusercontent.com/875216/233800808-69edecc7-9233-4fcb-9e40-3a20a173a972.png)

after:

![image](https://user-images.githubusercontent.com/875216/233800826-894bbc75-7272-4cd0-900e-8ab0b770ca75.png)
2023-04-24 19:39:45 +00:00
chuanzhubin 024cba5b02 Documentation: the corrected text should be Python instead of C#. (#605)
Simple doc fix.
2023-04-23 22:09:26 +00:00
Abby Harrison 7c013d015c Python: Use overloads for sk function invoke_* calls (#487)
### Motivation and Context
It is confusing to have multiple skfunction invoke_* calls. This PR
combines invoke and invoke_with_vars to enable calls with the input
pattern: with SKContext, or with SKContextVariables.

### Description
- Removed `sk_function` methods `invoke_with_vars` and
`invoke_with_vars_async`
- Added the following optional paramters to `sk_function` methods
`invoke_` and `invoke_async`: `variables` and `memory`
- Added log warnings for when an both SKContext and variables/memory are
passed to `invoke` methods - this design ensures that the SDContext and
it's associated variables and memory are prioritized
- Updated tests and notebooks where applicable
2023-04-22 19:23:40 +00:00
Abby Harrison e8c299a30d Python: Use overloads for run_async method (#511)
### Motivation and Context
To make the Python SK more pythonic, combined all kernel.run_* methods
into a single method with optional parameters.

### Description
- Removed `kernel.run_on_vars_async()`
- Removed `kernel.run_on_str_async()`
- Added `SKContext`, `ContextVariables`, and string params to
`kernel.run_async()`
- Moved `run_on_vars_async()` logic to `run_async()` method
- Arranged method params so that required params come before optional
params.
- Updated tests and notebooks where applicable.
2023-04-19 19:18:10 -07:00
Devis Lucato 60148bd070 Upgrade python notebooks to 0.2.3 (#500)
### Motivation and Context

Upgrade to latest version and verify that all notebooks work.
Tested README, everything working fine.
2023-04-18 10:51:58 -07:00
Abby HarrisonandDevis Lucato d9323b573f Remove kernel builder pattern for Python: sk.kernel_create() -> sk.Kernel() (#454)
### Motivation and Context

This PR makes creating a kernel instance more pythonic. The builder
pattern is removed and the kernel is constructed using Kernel(...).

Work originally started with #137

### Description

- Removed kernel_builder.py.
- Instance creation pattern `kernel = sk.create_kernel() -> kernel =
sk.Kernel()`
- For notebook 6, there is no need to create a separate kernel for the
GitHub files. Changed to use a separate collection.


Co-authored-by: Devis Lucato <[email protected]>
2023-04-17 11:07:46 -07:00
Devis Lucato e2e5e2dad3 Python: docs update + ruff config + fix tests 2023-04-13 16:12:36 -07:00
Devis Lucato 5fc05b2bea * Update notebooks to use pip package
* Add python getting started notebook
* Fix notebooks usage of Azure text completion
* Fix bug with skills definition
* Update READMEs
* New release version 0.2.2
2023-04-13 16:12:36 -07:00
Devis Lucato 3b04cfa1d2 Update READMEs, reduce code complexity, misc improvements (#374)
READMEs and examples are out of date and showing incorrect code. There
are also a few bugs in the SKFunction blocking simpler syntax.

Extend SKFunction to allow synchronous calls and have simpler syntax
when async is not required.

* Update homepage README, moving all Python examples under python/README
* Make SKFunction callable as per v0
* Fix bugs in SKFunction
* Fix examples using realistic code
* Allow to use functions synchronously
2023-04-13 16:12:36 -07:00
Jordan Henkel 407fb36e59 Python: cleanup/sync/fixes (for examples, docs, tests, notebooks) (#317)
### Motivation and Context

The `python-preview` branch is under active development and many
docs/tests/examples are getting a bit out of sync. There are also a few
small cleanup chores/refactors to make _usage_ easier (e.g., to make
examples cleaner). I've grouped these small fixes (plus a few bug fixes)
into this "cleanup" PR.

### Description

This PR does the following:

1. Updates the out-of-date example in `README.md`
2. Fixes all 5 of the notebooks we support right now (1,2,3,4, and 6;
notebook 5 is planner, I've blanked out most of the code there so we
don't confuse people, especially as the planner API is changing)
3. Fixes a bug w/ `stop_sequences` in `(Azure)OpenAITextCompletion`
4. Fixes a bug introduced in our upgrades to the embeddings cosine-sim
check (we should add more thorough tests here)
5. Cleans up tests
6. Ensures end-to-end tests are all runnable 
7. Fixes up the `kernel_extensions` to work more naturally (so that end
users can use them directly on the `kernel` object and get good
type-hinting)
2023-04-13 16:12:36 -07:00
Joowon 27e18312c0 Fix for running samples/notebooks/python/6-memory-and-embeddings.ipynb (#166)
### Motivation and Context
Please help reviewers and future users, providing the following
information:

1. Why is this change required?
`SemanticTextMemory.save_reference_async` do nothing for its storage.
2. What problem does it solve? `save_reference_async` will work
appropriately
3. What scenario does it contribute to? embeddings
4. If it fixes an open issue, please link to the issue here.
https://github.com/microsoft/semantic-kernel/issues/165


### Description

I add missing codes with references of
`SemanticTextMemory.save_information_async` and C# version of
`SemanticTextMemory.save_reference_async`
2023-04-13 16:12:36 -07:00
Devis Lucato 655c583ee0 Initial commit 2023-04-13 16:12:36 -07:00