|
| 1 | +# OCI Generative AI - Spring Cloud OCI Sample |
| 2 | + |
| 3 | +This sample demonstrates getting started quickly with Spring Cloud OCI to work with Oracle Cloud Infrastructure (OCI) Generative AI Service. This sample implements simple REST service which internally uses Spring Cloud OCI Generate AI APIs. |
| 4 | + |
| 5 | +## What is Spring Cloud OCI? |
| 6 | + |
| 7 | +Spring Cloud for OCI, eases the integration of OCI services with the help of internal OCI Java SDK. It offers a convenient way to interact with OCI-provided services using well-known Spring idioms and APIs, such as the messaging or storage API. Developers can build applications around the hosted services without concern for infrastructure or maintenance. Spring Cloud for OCI contains autoconfiguration support for OCI-managed services. |
| 8 | + |
| 9 | +## What is OCI Generative AI? |
| 10 | + |
| 11 | +Generative AI is a fully managed Oracle Cloud Infrastructure service that provides a set of state-of-the-art, customizable large language models (LLMs) that cover a wide range of use cases, including chat, text generation, summarization, and creating text embeddings. |
| 12 | + |
| 13 | +## Prerequisites |
| 14 | +Configuration items that are needed to run the Application can be configured in `application.properties`. |
| 15 | + |
| 16 | +* `spring.cloud.oci.region.static` - OCI Region name(Ex: us-phoenix-1) where the OCI resources need to be created. |
| 17 | +* `spring.cloud.oci.config.type` - Authentication type to be used for OCI. It could be one of the following: RESOURCE_PRINCIPAL, INSTANCE_PRINCIPAL, SESSION_TOKEN, SIMPLE, FILE, and WORKLOAD_IDENTITY. If nothing is specified, FILE type is used by default. |
| 18 | +* `spring.cloud.oci.config.file` - The file path set to this property will be used as the configuration file for FILE type authentication which uses the OCI configuration file. If nothing is specified, the OCI configuration file from the user's home directory will be used. |
| 19 | +* `spring.cloud.oci.config.profile` - Profile to be used in the OCI config file for Authentication. If a profile is not specified, a DEFAULT profile will be used. |
| 20 | + |
| 21 | +If the `spring.cloud.oci.config.type` is SIMPLE, then the following properties also need to be set in the `application.properties`. |
| 22 | + |
| 23 | +* `spring.cloud.oci.config.userId` |
| 24 | +* `spring.cloud.oci.config.tenantId` |
| 25 | +* `spring.cloud.oci.config.fingerprint` |
| 26 | +* `spring.cloud.oci.config.privateKey` |
| 27 | +* `spring.cloud.oci.config.passPhrase` |
| 28 | +* `spring.cloud.oci.config.region` |
| 29 | + |
| 30 | +Refer to [OCI SDK Authentication Methods](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdk_authentication_methods.htm) for more details on the Authentication types supported by OCI. |
| 31 | + |
| 32 | +## Quick Launch |
| 33 | + |
| 34 | +Clone the repository manually with the following instructions: |
| 35 | + |
| 36 | +``` |
| 37 | +git clone https://github.com/oracle/spring-cloud-oci.git spring-cloud-oci |
| 38 | +``` |
| 39 | + |
| 40 | +## Getting Started |
| 41 | + |
| 42 | +1. Run `mvn clean install` from the root directory of the repository code. |
| 43 | + |
| 44 | +1. Set appropriate values at `application.properties` for the following properties. (Refer to the Spring Cloud OCI docs for more details.) |
| 45 | +``` |
| 46 | +spring.cloud.oci.region.static = US_ASHBURN_1 |
| 47 | +
|
| 48 | +spring.cloud.oci.genai.embedding.compartment = ${OCI_COMPARTMENT_ID} |
| 49 | +spring.cloud.oci.genai.chat.compartment = ${OCI_COMPARTMENT_ID} |
| 50 | +
|
| 51 | +spring.cloud.oci.genai.chat.onDemandModelId = ${OCI_CHAT_MODEL_ID} |
| 52 | +spring.cloud.oci.genai.embedding.onDemandModelId = ${OCI_EMBEDDING_MODEL_ID} |
| 53 | +``` |
| 54 | +1. Start the application using the following command from sample root directory. |
| 55 | +``` |
| 56 | +mvn spring-boot:run |
| 57 | +``` |
| 58 | + |
| 59 | +Note: Default service port is `8080`. You can change this with the `server.port` property. |
| 60 | + |
| 61 | +## Sample Application API Reference |
| 62 | + |
| 63 | +Launch the Swagger UI (http://localhost:8080/swagger-ui/index.html) to view all available APIs and their payload samples. |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +## References |
| 68 | +* [Spring Cloud OCI - Documentation](#) |
| 69 | +* [Spring Cloud OCI - Open Source](https://github.com/oracle/spring-cloud-oci) |
| 70 | +* [OCI SDK - Documentation](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdks.htm) |
| 71 | + |
| 72 | +## Contributing |
| 73 | +This project is open source. Submit your contributions by forking this repository and submitting a pull request. Oracle appreciates any contributions that are made by the open source community. |
| 74 | + |
| 75 | +## License |
| 76 | +Copyright (c) 2024 Oracle and/or its affiliates. |
| 77 | + |
| 78 | +Licensed under the Universal Permissive License (UPL), Version 1.0. |
| 79 | + |
| 80 | +See [LICENSE](../../LICENSE.txt) for more details. |
| 81 | + |
| 82 | +ORACLE AND ITS AFFILIATES DO NOT PROVIDE ANY WARRANTY WHATSOEVER, EXPRESS OR IMPLIED, FOR ANY SOFTWARE, MATERIAL OR CONTENT OF ANY KIND CONTAINED OR PRODUCED WITHIN THIS REPOSITORY, AND IN PARTICULAR SPECIFICALLY DISCLAIM ANY AND ALL IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. FURTHERMORE, ORACLE AND ITS AFFILIATES DO NOT REPRESENT THAT ANY CUSTOMARY SECURITY REVIEW HAS BEEN PERFORMED WITH RESPECT TO ANY SOFTWARE, MATERIAL OR CONTENT CONTAINED OR PRODUCED WITHIN THIS REPOSITORY. IN ADDITION, AND WITHOUT LIMITING THE FOREGOING, THIRD PARTIES MAY HAVE POSTED SOFTWARE, MATERIAL OR CONTENT TO THIS REPOSITORY WITHOUT ANY REVIEW. USE AT YOUR OWN RISK. |
0 commit comments