Skip to content

Commit 9771995

Browse files
authored
Merge pull request #3 from oracle-samples/initial-release
Set version to 1.0.0 and add MIGRATION.md
2 parents fc2038d + 569e023 commit 9771995

5 files changed

Lines changed: 115 additions & 6 deletions

File tree

MIGRATION.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Migration Guide: `oci-genai-openai` to `oci-genai-auth-java`
2+
3+
This guide helps existing `oci-genai-openai` users migrate to `oci-genai-auth-java`.
4+
5+
## Summary
6+
7+
- Replace dependency `oci-genai-openai` with `oci-genai-auth-java-core`.
8+
- Continue using the `openai-java` SDK client.
9+
- Use `OciOkHttpClientFactory` to build a signed OkHttpClient.
10+
- Choose endpoint/config based on API mode:
11+
- AgentHub: `https://inference.generativeai.<region>.oci.oraclecloud.com/openai/v1` + `openai-project` header
12+
- Partner : `https://inference.generativeai.<region>.oci.oraclecloud.com/20231130/actions/v1` + `compartmentId`
13+
14+
## 1) Dependency Changes
15+
16+
Replace the old dependency with the new one in your `pom.xml`:
17+
18+
```xml
19+
<!-- Remove old dependency -->
20+
<!-- <artifactId>oci-genai-openai</artifactId> -->
21+
22+
<!-- Add new dependency -->
23+
<dependencyManagement>
24+
<dependencies>
25+
<dependency>
26+
<groupId>com.oracle.genai</groupId>
27+
<artifactId>oci-genai-auth-java-bom</artifactId>
28+
<version>1.0.0</version>
29+
<type>pom</type>
30+
<scope>import</scope>
31+
</dependency>
32+
</dependencies>
33+
</dependencyManagement>
34+
35+
<dependencies>
36+
<dependency>
37+
<groupId>com.oracle.genai</groupId>
38+
<artifactId>oci-genai-auth-java-core</artifactId>
39+
</dependency>
40+
</dependencies>
41+
```
42+
43+
## 2) Import Changes
44+
45+
```java
46+
// Old
47+
import com.oracle.genai.openai.OciOpenAI;
48+
49+
// New
50+
import com.oracle.genai.auth.OciAuthConfig;
51+
import com.oracle.genai.auth.OciOkHttpClientFactory;
52+
```
53+
54+
## 3) Client Initialization Changes
55+
56+
### AgentHub
57+
58+
Use the OpenAI-compatible endpoint and provide project OCID:
59+
60+
```java
61+
import com.oracle.genai.auth.OciAuthConfig;
62+
import com.oracle.genai.auth.OciOkHttpClientFactory;
63+
import com.openai.client.OpenAIClient;
64+
import com.openai.client.okhttp.OpenAIOkHttpClient;
65+
66+
OciAuthConfig config = OciAuthConfig.builder()
67+
.authType("security_token")
68+
.profile("DEFAULT")
69+
.build();
70+
71+
OkHttpClient ociHttpClient = OciOkHttpClientFactory.build(config);
72+
73+
OpenAIClient client = OpenAIOkHttpClient.builder()
74+
.baseUrl("https://inference.generativeai.<region>.oci.oraclecloud.com/openai/v1")
75+
.okHttpClient(ociHttpClient)
76+
.apiKey("not-used")
77+
.addHeader("openai-project", "<ocid1.generativeaiproject...>")
78+
.build();
79+
```
80+
81+
### Partner APIs
82+
83+
Use `/20231130/actions/v1` and include compartment ID:
84+
85+
```java
86+
OciAuthConfig config = OciAuthConfig.builder()
87+
.authType("security_token")
88+
.profile("DEFAULT")
89+
.compartmentId("<ocid1.compartment...>")
90+
.build();
91+
92+
OkHttpClient ociHttpClient = OciOkHttpClientFactory.build(config);
93+
94+
OpenAIClient client = OpenAIOkHttpClient.builder()
95+
.baseUrl("https://inference.generativeai.<region>.oci.oraclecloud.com/20231130/actions/v1")
96+
.okHttpClient(ociHttpClient)
97+
.apiKey("not-used")
98+
.build();
99+
```
100+
101+
## 4) Endpoint and required parameters
102+
103+
- AgentHub:
104+
- `baseUrl`: `https://inference.generativeai.<region>.oci.oraclecloud.com/openai/v1`
105+
- required: `openai-project` header with project OCID
106+
- Partner:
107+
- `baseUrl`: `https://inference.generativeai.<region>.oci.oraclecloud.com/20231130/actions/v1`
108+
- required: `compartmentId` in `OciAuthConfig`

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Requires **Java 17+** and **Maven 3.8+**.
2626
<dependency>
2727
<groupId>com.oracle.genai</groupId>
2828
<artifactId>oci-genai-auth-java-bom</artifactId>
29-
<version>0.1.0-SNAPSHOT</version>
29+
<version>1.0.0</version>
3030
<type>pom</type>
3131
<scope>import</scope>
3232
</dependency>
@@ -131,6 +131,7 @@ OciAuthConfig config = OciAuthConfig.builder()
131131
.build();
132132

133133
OkHttpClient ociHttpClient = OciOkHttpClientFactory.build(config);
134+
134135
OpenAIClient client = OpenAIOkHttpClient.builder()
135136
.baseUrl("https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/20231130/actions/v1")
136137
.okHttpClient(ociHttpClient)

oci-genai-auth-java-bom/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<groupId>com.oracle.genai</groupId>
1414
<artifactId>oci-genai-auth-java-bom</artifactId>
15-
<version>0.1.0-SNAPSHOT</version>
15+
<version>1.0.0</version>
1616
<packaging>pom</packaging>
1717

1818
<name>OCI GenAI Auth :: BOM</name>
@@ -23,7 +23,7 @@
2323
</description>
2424

2525
<properties>
26-
<oci-genai-auth.version>0.1.0-SNAPSHOT</oci-genai-auth.version>
26+
<oci-genai-auth.version>1.0.0</oci-genai-auth.version>
2727

2828
<!-- OCI SDK -->
2929
<oci-sdk.version>3.72.1</oci-sdk.version>

oci-genai-auth-java-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<parent>
1414
<groupId>com.oracle.genai</groupId>
1515
<artifactId>oci-genai-auth-java-parent</artifactId>
16-
<version>0.1.0-SNAPSHOT</version>
16+
<version>1.0.0</version>
1717
</parent>
1818

1919
<artifactId>oci-genai-auth-java-core</artifactId>

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<groupId>com.oracle.genai</groupId>
1414
<artifactId>oci-genai-auth-java-parent</artifactId>
15-
<version>0.1.0-SNAPSHOT</version>
15+
<version>1.0.0</version>
1616
<packaging>pom</packaging>
1717

1818
<name>OCI GenAI Auth :: Parent</name>
@@ -39,7 +39,7 @@
3939
<maven.compiler.target>17</maven.compiler.target>
4040

4141
<!-- First-party versions -->
42-
<oci-genai-auth.version>0.1.0-SNAPSHOT</oci-genai-auth.version>
42+
<oci-genai-auth.version>1.0.0</oci-genai-auth.version>
4343

4444
<!-- OCI SDK -->
4545
<oci-sdk.version>3.72.1</oci-sdk.version>

0 commit comments

Comments
 (0)