Skip to content

Commit af85259

Browse files
authored
Merge pull request #12 from oracle-devrel/k8s
adding oke automation and db component
2 parents 9fd50f5 + 52f5c0c commit af85259

File tree

114 files changed

+12598
-324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+12598
-324
lines changed

.gitignore

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,46 @@ Temporary Items
3333
.pem
3434

3535
#temp directory ignore
36-
deploy/
36+
# deploy/
3737
service/python/Dockerfile
38+
39+
.certs
40+
.artifacts
41+
deploy/k8s/backend/application.yaml
42+
deploy/k8s/overlays/prod/kustomization.yaml
43+
deploy/k8s/backend/wallet/
44+
45+
generated/
46+
47+
.env.json
48+
*.bkp
49+
*.zip
50+
kubeconfig
51+
52+
# Terraform
53+
**/.terraform/*
54+
*.tfstate
55+
*.tfstate.*
56+
crash.log
57+
crash.*.log
58+
*.tfvars
59+
*.tfvars.json
60+
override.tf
61+
override.tf.json
62+
*_override.tf
63+
*_override.tf.json
64+
.terraformrc
65+
terraform.rc
66+
67+
# Node
68+
node_modules/
69+
70+
# Java
71+
.gradle
72+
build/
73+
!gradle/wrapper/gradle-wrapper.jar
74+
!**/src/main/**/build/
75+
!**/src/test/**/build/
76+
.idea
77+
bin/
78+
dist/

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{}
1+
{
2+
"java.compile.nullAnalysis.mode": "automatic"
3+
}

FAQ.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# FAQ
2+
3+
## Technical help
4+
5+
### Get the Load Balancer Public IP address
6+
7+
```bash
8+
kubectl get service -n ingress-nginx -o jsonpath='{.items[?(@.spec.type=="LoadBalancer")].status.loadBalancer.ingress[0].ip}'
9+
```
10+
11+
### Get the `dockerconfigjson` from the secret
12+
13+
```bash
14+
kubectl get secret ocir-secret --output="jsonpath={.data.\.dockerconfigjson}" | base64 --decode | jq
15+
```

JET.md

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
# Enhance Engagement Using Content Generation with OCI Generative AI
2+
3+
[![License: UPL](https://img.shields.io/badge/license-UPL-green)](https://img.shields.io/badge/license-UPL-green) [![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=oracle-devrel_oci-generative-ai-jet-ui)](https://sonarcloud.io/dashboard?id=oracle-devrel_oci-generative-ai-jet-ui)
4+
5+
## Introduction
6+
7+
Using Oracle JET, create a user-friendly prompt-led user interface (UI) to interact with Oracle's new Generative AI service. This toolkit will configure your Generative AI Service connection so you can begin your journey with AI, or migrate your existing (local or Cloud) LLMs to the Oracle AppDev ecosystem.
8+
9+
Oracle JET(Preact) allows you to craft pixel-perfect UIs which are fast, lightweight, and engaging. Your code takes centre stage with Oracle JET, while its powerful features enable you to create dynamic user experiences quickly and reliably.
10+
11+
Oracle's Generative AI service allows developers to unlock a better user experience for chat systems, question-and-answer solutions, and much more. This project provides a front end to that service so you can experiment and get a sense of the immense power of Oracle Generative AI. This is an excellent starting point on your AI journey, and experienced developers will be able to quickly port their LLMs to leverage this powerful service.
12+
13+
Check out [demo here](https://youtu.be/hpRoQ93YeaQ)
14+
15+
![alt text here](images/demo.gif)
16+
17+
## Getting Started
18+
19+
### 0. Prerequisites and setup
20+
21+
- Oracle Cloud Infrastructure (OCI) Account
22+
- Oracle Cloud Infrastructure (OCI) Generative AI Service - [Getting Started with Generative AI](https://docs.oracle.com/en-us/iaas/Content/generative-ai/getting-started.htm)
23+
- Oracle Cloud Infrastructure Documentation - [Generative AI](https://docs.oracle.com/en-us/iaas/Content/generative-ai/home.htm)
24+
- Oracle Cloud Infrastructure (OCI) Generative AI Service SDK - [Oracle Cloud Infrastructure Python SDK](https://pypi.org/project/oci/)
25+
- Node v16 - [Node homepage](https://nodejs.org/en)
26+
- Oracle JET v15 - [Oracle JET Homepage](https://www.oracle.com/webfolder/technetwork/jet/index.html)
27+
28+
Follow the links below to generate a config file and a key pair in your ~/.oci directory
29+
30+
- [SDK config](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm)
31+
- [API signing key](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm)
32+
- [CLI install](https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/cliinstall.htm#configfile)
33+
34+
After completion, you should have the following 2 things in your `~/.oci directory`
35+
36+
- A config file(where key file point to private key:key_file=`~/.oci/oci_api_key.pem`)
37+
- A key pair named `oci_api_key.pem` and `oci_api_key_public.pem`
38+
- Now make sure you change the reference of the key file in the config file
39+
- Append OCI Generative-AI service compartment and endpoint URL
40+
41+
```console
42+
vim service/python/server.py
43+
```
44+
45+
```Python
46+
#TODO: Update this section with your tenancy details
47+
compartment_id = "ocid1.compartment.oc1.."
48+
CONFIG_PROFILE = "DEFAULT"
49+
config = oci.config.from_file("~/.oci/config", CONFIG_PROFILE)
50+
endpoint = "https://inference.generativeai.<REGION>.oci.oraclecloud.com"
51+
generative_ai_inference_client = (
52+
oci.generative_ai_inference.GenerativeAiInferenceClient(
53+
config=config,
54+
service_endpoint=endpoint,
55+
retry_strategy=oci.retry.NoneRetryStrategy(),
56+
timeout=(10, 240),
57+
)
58+
)
59+
```
60+
61+
### 1. (Optional) Modify websocket ports
62+
63+
- In the root of the project directory run to edit ports
64+
65+
```console
66+
vim app/src/components/content/index.tsx
67+
```
68+
69+
```js
70+
const gateway = ws://${window.location.hostname}:1234;
71+
```
72+
73+
- Update default port in Python websocket server:
74+
75+
```console
76+
vim service/python/server.py
77+
```
78+
79+
```Python
80+
async def start_server():
81+
await websockets.serve(handle_websocket, "localhost", 1234 )
82+
```
83+
84+
### 2. Upload Public Key
85+
86+
- Upload your oci_api_key_public.pem to console:
87+
[API signing key](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#three)
88+
89+
### 3. Install all dependencies
90+
91+
We suggest you install dependencies in a virtual environment to avoid conflicts on your system.
92+
93+
- Navigate to the server root folder
94+
95+
```console
96+
cd service/python
97+
```
98+
99+
- Create a virtual environment:
100+
101+
```console
102+
python3 -m venv venv
103+
```
104+
105+
- Activate your virtual environment:
106+
107+
```console
108+
. venv/bin/activate
109+
```
110+
111+
- Upgrade pip:
112+
113+
```console
114+
pip3 install --upgrade pip
115+
```
116+
117+
- Install requirements:
118+
119+
```console
120+
pip3 install -r requirements.txt
121+
```
122+
123+
## 4. Start the websocket server app
124+
125+
Once dependencies are installed and your service credentials are updated you can run server.py
126+
127+
```console
128+
python3 server.py
129+
```
130+
131+
## 5. Start JET Client
132+
133+
- Open app directory:
134+
135+
```console
136+
cd ../../app
137+
```
138+
139+
- Install dependencies:
140+
141+
```console
142+
npm install
143+
```
144+
145+
- Run local version:
146+
147+
```console
148+
npx ojet serve
149+
```
150+
151+
- Or package for web deployment
152+
153+
```console
154+
npx ojet build web
155+
```
156+
157+
You can now ask question to generate LLM based response.
158+
![alt text here](images/QandA.png)
159+
160+
Note that sample app can generate markdown.
161+
![alt text here](images/Markdown.png)
162+
163+
## Appendix: Token-based Authentication
164+
165+
Check [Token-based Authentication for the CLI](https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/clitoken.htm#Running_Scripts_on_a_Computer_without_a_Browser)
166+
167+
```Python
168+
config = oci.config.from_file('~/.oci/config', profile_name="DEFAULT")
169+
170+
def make_security_token_signer(oci_config):
171+
pk = oci.signer.load_private_key_from_file(oci_config.get("key_file"), None)
172+
with open(oci_config.get("security_token_file")) as f:
173+
st_string = f.read()
174+
return oci.auth.signers.SecurityTokenSigner(st_string, pk)
175+
176+
signer = make_security_token_signer(oci_config=config)
177+
# Service endpoint
178+
endpoint = "https://generativeai.aiservice.<Region>.oci.oraclecloud.com"
179+
180+
generative_ai_client = oci.generative_ai.generative_ai_client.GenerativeAiClient(config=config, service_endpoint=endpoint, retry_strategy=oci.retry.NoneRetryStrategy(), signer=signer)
181+
```
182+
183+
## Notes/Issues
184+
185+
Additional Use Cases like summarization and embedding coming soon.
186+
187+
To change output parameters edit server.py
188+
189+
```Python
190+
cohere_generate_text_request.max_tokens = 500 # choose the number of tokens 1-4000
191+
cohere_generate_text_request.temperature = 0.75 # adjust temperature 0-1
192+
cohere_generate_text_request.top_p = 0.7 # adjust top_p 0-1
193+
cohere_generate_text_request.frequency_penalty = 1.0 # adjust frequency_penalty
194+
```
195+
196+
## URLs
197+
198+
- [Oracle AI](https://www.oracle.com/artificial-intelligence/)
199+
- [AI for Developers](https://developer.oracle.com/technologies/ai.html)
200+
201+
## Contributing
202+
203+
This project is open source. Please submit your contributions by forking this repository and submitting a pull request! Oracle appreciates any contributions that are made by the open-source community.
204+
205+
## License
206+
207+
Copyright (c) 2024 Oracle and/or its affiliates.
208+
209+
Licensed under the Universal Permissive License (UPL), Version 1.0.
210+
211+
See [LICENSE](LICENSE) for more details.
212+
213+
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

Comments
 (0)