### 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 <!-- 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: --> - [ ] The code builds clean without any errors or warnings - [ ] 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 - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Mark Wallace <[email protected]> Co-authored-by: Teresa Hoang <[email protected]> Co-authored-by: Gil LaHaye <[email protected]> Co-authored-by: Craig Presti <[email protected]> Co-authored-by: adityachallapally <[email protected]> Co-authored-by: Devis Lucato <[email protected]> Co-authored-by: Gina Triolo <[email protected]> Co-authored-by: Adrian Bonar <[email protected]> Co-authored-by: Gudge <[email protected]> Co-authored-by: Shawn Callegari <[email protected]> Co-authored-by: Roger Barreto <[email protected]> Co-authored-by: Stephen Toub <[email protected]> Co-authored-by: Jadyn <[email protected]> Co-authored-by: Lee Miller <[email protected]> Co-authored-by: name <email> Co-authored-by: Milder Hernandez Cagua <[email protected]> Co-authored-by: Milder Hernandez <[email protected]> Co-authored-by: Yoshio Terada <[email protected]> Co-authored-by: Almir Kazazic <[email protected]> Co-authored-by: Alexander Siniouguine <[email protected]> Co-authored-by: Harleen Thind <[email protected]> Co-authored-by: David Barkol <[email protected]> Co-authored-by: Mark Karle <[email protected]> Co-authored-by: poweihuang0817 <[email protected]> Co-authored-by: Po-Wei Huang <[email protected]> Co-authored-by: Ikko Eltociear Ashimine <[email protected]> Co-authored-by: Adrian Bonar (HE/HIM) <[email protected]> Co-authored-by: Tao Chen <[email protected]> Co-authored-by: Vivien Hung <[email protected]> Co-authored-by: Abby Harrison <[email protected]> Co-authored-by: Abby Harrison <[email protected]> Co-authored-by: Devis Lucato <[email protected]> Co-authored-by: fabio fumarola <[email protected]> Co-authored-by: cdMSFT <[email protected]> Co-authored-by: Dmytro Struk <[email protected]> Co-authored-by: Lex Li <[email protected]> Co-authored-by: Damir Dobric <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Aman Sachan <[email protected]> Co-authored-by: Joowon <[email protected]> Co-authored-by: Richard Edgar <[email protected]> Co-authored-by: nacharya1 <[email protected]> Co-authored-by: Kevdome3000 <[email protected]> Co-authored-by: tech <[email protected]> Co-authored-by: Masumi Morishige <[email protected]> Co-authored-by: Alex Chao <[email protected]> Co-authored-by: Alex Chao <[email protected]> Co-authored-by: markwallace-microsoft <[email protected]> Co-authored-by: David Grieve <[email protected]> Co-authored-by: Bruno Borges <[email protected]> Co-authored-by: Martijn Verburg <[email protected]> Co-authored-by: Luigi Montoya <[email protected]> Co-authored-by: joe-braley <[email protected]> Co-authored-by: Luigi96 <[email protected]> Co-authored-by: GitHub <[email protected]> Co-authored-by: Derek Keeler <[email protected]> Co-authored-by: Joe Braley <[email protected]> Co-authored-by: Craig Presti <[email protected]> Co-authored-by: cschadewitz <[email protected]> Co-authored-by: Desmond Howard <[email protected]> Co-authored-by: Jean-Sylvain Boige <[email protected]> Co-authored-by: Dave Arlin <[email protected]> Co-authored-by: Ben Thomas <[email protected]> Co-authored-by: Ben Thomas <[email protected]> Co-authored-by: Sebastian Santoyo <[email protected]> Co-authored-by: sneha <[email protected]> Co-authored-by: Alisha Maddy <[email protected]> Co-authored-by: Alisha Maddy <[email protected]> Co-authored-by: Sneha <[email protected]> Co-authored-by: Guy Bowerman <[email protected]> Co-authored-by: kshitijcode <[email protected]> Co-authored-by: dantelmomsft <[email protected]> Co-authored-by: Vikram Seshadri <[email protected]>
Semantic Kernel for Java
Semantic Kernel (SK) is a lightweight foundation that lets you easily mix conventional programming languages with the latest in Large Language Model (LLM) AI "prompts" with templating, chaining, and planning capabilities out-of-the-box.
To learn more about Microsoft Semantic Kernel, visit the Microsoft Semantic Kernel documentation.
The Microsoft Semantic Kernel for Java is a library that implements the key concepts and foundations of Microsoft Semantic Kernel. It is designed to be used in Java applications in both client (desktop, mobile, CLIs) and server environments in an idiomatic way, and to be easily integrated with other Java libraries and frameworks.
Get started
To run the LLM prompts and semantic functions in this kernel, make sure you have an Open AI API Key or Azure Open AI service key.
Requirements
To build the Semantic Kernel for Java, you will need:
- Required:
- OpenJDK 17 or newer
Build the Semantic Kernel
-
Clone this repository
git clone -b java-development https://github.com/microsoft/semantic-kernel/ -
Build the project with the Maven Wrapper
cd semantic-kernel/java ./mvnw install
Using the Semantic Kernel for Java
The library is organized in a set of dependencies published to Maven Central. For a list of the Maven dependencies and how to use each of them, see PACKAGES.md.
Alternatively, check the samples folder for examples of common AI-enabled scenarios implemented with Semantic Kernel for Java.
Discord community
Join the Microsoft Semantic Kernel Discord community to discuss the Semantic Kernel
and get help from the community. We have a #java channel for Java-specific questions.
Contributing
Testing locally
The project may contain end-to-end tests that require an OpenAI key to run. To run these tests locally, you will need to set the following environment variable:
OPENAI_API_KEY- the OpenAI API key.
If you are using Azure OpenAI, you will also need to set the following environment variables:
AZURE_OPENAI_ENDPOINT- the Azure OpenAI endpoint found in Keys * Endpoint section of the Azure OpenAI service.AZURE_OPENAI_API_KEY- the Azure OpenAI API key found in Keys * Endpoint section of the Azure OpenAI service.AZURE_OPENAI_DEPLOYMENT_NAME- the custom name you chose for your deployment when you deployed a model. It can be found under Resource Management > Deployments in the Azure Portal.
For more information, see the Azure OpenAI documentation on how to get your Azure OpenAI credentials.
To run the unit tests only, run the following command:
./mvnw package
To run all tests, including integration tests that require an OpenAI key, run the following command:
./mvnw verify
Submitting a pull request
Before submitting a pull request, please make sure that you have run the project with the command:
./mvnw clean package -Pbug-check
The bug-check profile will detect some static analysis issues that will prevent merging as well as apply formatting requirements to the code base.
Also ensure that:
- All new code is covered by unit tests
- All new code is covered by integration tests
Once your proposal is ready, submit a pull request to the java-development branch. The pull request will be reviewed by the
project maintainers.
Make sure your pull request has an objective title and a clear description explaining the problem and solution.
License
This project is licensed under the MIT License.
Code of Conduct
This project has adopted the Microsoft Open Source Code of Conduct.