Skip to content

Commit 7cb8bfd

Browse files
authored
Merge pull request #1 from oracle-devrel/work
Branch Merge
2 parents 3f4dc12 + ac6b626 commit 7cb8bfd

File tree

108 files changed

+3024
-11
lines changed

Some content is hidden

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

108 files changed

+3024
-11
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ Temporary Items
3030
.key
3131
.crt
3232
.csr
33-
.pem
33+
.pem
34+
35+
#temp directory ignore
36+
deploy/
37+
service/python/Dockerfile

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

README.md

Lines changed: 155 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,176 @@
22

33
[![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)
44

5-
## THIS IS A NEW, BLANK REPO THAT IS NOT READY FOR USE YET. PLEASE CHECK BACK SOON!
6-
75
## Introduction
8-
MISSING
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+
![alt text here](images/demo.gif)
14+
15+
Check [demo here](https://youtu.be/hpRoQ93YeaQ)
916

1017
## Getting Started
11-
MISSING
18+
19+
### 0. Set up
20+
21+
Follow the links below to generate a config file and a key pair in your ~/.oci directory
22+
23+
- [SDK config](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm)
24+
- [API signing key](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm)
25+
- [CLI install](https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/cliinstall.htm#configfile)
26+
27+
After completion, you should have the following 2 things in your `~/.oci directory `
28+
29+
a. A config file(where key file point to private key:key_file=`~/.oci/oci_api_key.pem`)
30+
b. A key pair named `oci_api_key.pem` and `oci_api_key_public.pem`
31+
Now make sure you change the reference of the key file in the config file (where the key file points to private key:key_file=/YOUR_DIR_TO_KEY_FILE/oci_api_key.pem)
32+
33+
- Append OCI Generative-AI service compartment and endpoint URL
34+
`vim service/python/server.py`
35+
36+
```Python
37+
#TODO: Update this section with your tenancy details
38+
compartment_id = "ocid1.compartment.oc1.."
39+
CONFIG_PROFILE = "DEFAULT"
40+
config = oci.config.from_file("~/.oci/config", CONFIG_PROFILE)
41+
endpoint = "https://inference.generativeai.<REGION>.oci.oraclecloud.com"
42+
generative_ai_inference_client = (
43+
oci.generative_ai_inference.GenerativeAiInferenceClient(
44+
config=config,
45+
service_endpoint=endpoint,
46+
retry_strategy=oci.retry.NoneRetryStrategy(),
47+
timeout=(10, 240),
48+
)
49+
)
50+
```
51+
52+
### 1. (Optional) Modify websocket ports
53+
54+
- In the root of the project directory run to edit ports
55+
`vim app/web/components/content/index.tsx`
56+
57+
```Javascript
58+
const gateway = `ws://${window.location.hostname}:1234`;
59+
```
60+
61+
- Update default port in Python websocket server:
62+
`vim service/python/server.py`
63+
64+
```Python
65+
async def start_server():
66+
await websockets.serve(handle_websocket, "localhost", 1234 )
67+
```
68+
69+
### 2. Upload Public Key
70+
71+
- Upload your oci_api_key_public.pem to console:
72+
[API signing key](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#three)
73+
74+
### 3. Make sure you have Python installed on your machine
75+
76+
- In cli run the following command to validate the Python version
77+
`python --version`
78+
79+
You should see similar output:
80+
81+
```shell
82+
Python 3.8.3
83+
```
84+
85+
### 4. Install all dependencies
86+
87+
We suggest you install dependencies in a virtual environment to avoid conflicts on your system.
88+
89+
- Navigate to the server root folder
90+
`cd service/python`
91+
- Create a virtual environment:
92+
`python3 -m venv venv`
93+
- Activate your virtual environment:
94+
`. venv/bin/activate`
95+
- Upgrade pip:
96+
`pip3 install --upgrade pip`
97+
- Install requirements:
98+
`pip3 install -r requirements.txt`
99+
100+
## 5. Start the websocket server app
101+
102+
Once dependencies are installed and your service credentials are updated you can run server.py
103+
104+
- `python3 server.py`
105+
106+
## 6. Start JET Client
107+
108+
- Open app directory:
109+
`cd ../../app ` or `cd app/` in the root folder
110+
- Install dependencies:
111+
`ojet restore`
112+
- Run local version:
113+
`ojet serve`
114+
- Or package for web deployment
115+
`ojet build web`
116+
117+
Ask question to generate LLM response.
118+
![alt text here](images/QandA.png)
119+
120+
Note that sample app can generate markdown.
121+
![alt text here](images/Markdown.png)
122+
123+
## Appendix: Token-based Authentication
124+
125+
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)
126+
127+
```Python
128+
config = oci.config.from_file('~/.oci/config', profile_name="DEFAULT")
129+
130+
def make_security_token_signer(oci_config):
131+
pk = oci.signer.load_private_key_from_file(oci_config.get("key_file"), None)
132+
with open(oci_config.get("security_token_file")) as f:
133+
st_string = f.read()
134+
return oci.auth.signers.SecurityTokenSigner(st_string, pk)
135+
136+
signer = make_security_token_signer(oci_config=config)
137+
# Service endpoint
138+
endpoint = "https://generativeai.aiservice.<Region>.oci.oraclecloud.com"
139+
140+
generative_ai_client = oci.generative_ai.generative_ai_client.GenerativeAiClient(config=config, service_endpoint=endpoint, retry_strategy=oci.retry.NoneRetryStrategy(), signer=signer)
141+
```
12142

13143
### Prerequisites
14-
MISSING
144+
145+
- OCI Account
146+
- OCI Generative AI Service
147+
- Oracle JET/Node
15148

16149
## Notes/Issues
17-
MISSING
150+
151+
Additional Use Cases like summarization and embedding coming soon.
152+
153+
To change output parameters edit server.py
154+
155+
```Python
156+
cohere_generate_text_request.max_tokens = 500 # choose the number of tokens 1-4000
157+
cohere_generate_text_request.temperature = 0.75 # adjust temperature 0-1
158+
cohere_generate_text_request.top_p = 0.7 # adjust top_p 0-1
159+
cohere_generate_text_request.frequency_penalty = 1.0 # adjust frequency_penalty
160+
```
18161

19162
## URLs
20-
* Nothing at this time
163+
164+
- [Oracle AI](https://www.oracle.com/artificial-intelligence/)
165+
- [AI for Developers](https://developer.oracle.com/technologies/ai.html)
21166

22167
## Contributing
23-
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.
168+
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.
24169

25170
## License
26-
Copyright (c) 2022 Oracle and/or its affiliates.
171+
Copyright (c) 2024 Oracle and/or its affiliates.
27172

28173
Licensed under the Universal Permissive License (UPL), Version 1.0.
29174

30175
See [LICENSE](LICENSE) for more details.
31176

32-
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.
177+
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.

app/.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/jet_components
2+
/exchange_components
3+
/node_modules
4+
/bower_components
5+
/dist
6+
/web
7+
/staged-themes
8+
/themes
9+
/jaftmp@
10+
11+
/hybrid/node_modules
12+
/hybrid/platforms
13+
/hybrid/www/*
14+
15+
!hybrid/plugins
16+
hybrid/plugins/*
17+
!hybrid/plugins/fetch.json
18+
19+
package-lock.json
20+
21+
.DS_Store
22+
Thumbs.db

app/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM nginx:1.23-alpine-slim
2+
3+
RUN apk add --update nodejs npm
4+
5+
6+
WORKDIR /usr/share/build
7+
8+
RUN mkdir -p /usr/share/build/src \
9+
&& mkdir -p /usr/share/build/scripts
10+
11+
COPY src/ /usr/share/build/src/
12+
13+
COPY scripts/ /usr/share/build/scripts/
14+
15+
COPY *.json /usr/share/build/
16+
17+
RUN npm install
18+
RUN npm install -g @oracle/ojet-cli
19+
RUN npx ojet build web --release
20+
21+
EXPOSE 80
22+
23+
RUN cp -R /usr/share/build/web/* /usr/share/nginx/html/

app/oraclejafconfig.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"title": [
3+
"+---------------------------------------------------------------------+",
4+
"| OJET Application Audit |",
5+
"+---------------------------------------------------------------------+",
6+
"JAF $jafver - Jet $jetver : ($jafdate, $jaftime)\n"
7+
],
8+
"base": "$jafcwd",
9+
"files": [
10+
"./src/**/*.html",
11+
"./src/**/*.js",
12+
"./src/**/*.ts",
13+
"./src/**/component.json",
14+
"./src/styles/**/*.css"
15+
],
16+
"exclude": [
17+
"./src/**/*-min.js",
18+
"./src/**/*-min.css",
19+
"./src/styles/*",
20+
"./**/node_modules/**/*.*"
21+
],
22+
"components": ["./jet_components/**/component.json"],
23+
"builtinJetRules": true,
24+
"jetVer": "15.1",
25+
"ecmaVer": 14,
26+
"format": "prose",
27+
"severity": "all",
28+
"groups": ["all"],
29+
"theme": "Redwood",
30+
"typescript": {
31+
"tsconfig": "."
32+
},
33+
"options": {
34+
"verbose": false,
35+
"color": true
36+
},
37+
"ojet": {
38+
"update": true,
39+
"md5": "157a41b6c41e0ea3a2cf1220cb184de3"
40+
}
41+
}

app/oraclejetconfig.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"paths": {
3+
"source": {
4+
"common": "src",
5+
"web": "src-web",
6+
"javascript": ".",
7+
"typescript": ".",
8+
"styles": "styles",
9+
"themes": "themes",
10+
"components": "components",
11+
"exchangeComponents": "exchange_components"
12+
},
13+
"staging": {
14+
"web": "web",
15+
"themes": "staged-themes"
16+
}
17+
},
18+
"defaultBrowser": "chrome",
19+
"sassVer": "8.0.0",
20+
"defaultTheme": "redwood",
21+
"typescriptLibraries": "[email protected] yargs-parser@~13.1.2",
22+
"webpackLibraries": "[email protected] @types/[email protected] webpack-dev-server style-loader css-loader sass-loader sass [email protected] raw-loader noop-loader html-webpack-plugin html-replace-webpack-plugin copy-webpack-plugin @prefresh/webpack @prefresh/babel-plugin webpack-merge compression-webpack-plugin mini-css-extract-plugin clean-webpack-plugin css-fix-url-loader",
23+
24+
"jestTestingLibraries": "[email protected] @testing-library/[email protected] @types/[email protected] [email protected] @oracle/oraclejet-jest-preset@~15.1.0",
25+
"architecture": "vdom",
26+
"watchInterval": 1000,
27+
"exchange-url": "https://exchange.oraclecorp.com/api/0.2.0/"
28+
}

app/package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "JETGenAI",
3+
"version": "1.0.0",
4+
"description": "An Oracle JavaScript Extension Toolkit(JET) web app",
5+
"dependencies": {
6+
"@oracle/oraclejet": "~15.1.0",
7+
"@oracle/oraclejet-core-pack": "~15.1.0",
8+
"marked": "^4.3.0",
9+
"uuid": "^9.0.1"
10+
},
11+
"devDependencies": {
12+
"@oracle/ojet-cli": "~15.1.0",
13+
"@oracle/oraclejet-audit": "^15.1.3",
14+
"@types/uuid": "^9.0.7",
15+
"extract-zip": "^1.7.0",
16+
"fs-extra": "^8.1.0",
17+
"glob": "7.2.0",
18+
"typescript": "5.0.4",
19+
"underscore": "^1.10.2",
20+
"yargs-parser": "13.1.2"
21+
},
22+
"engines": {
23+
"node": ">=16.0.0"
24+
},
25+
"private": true
26+
}

0 commit comments

Comments
 (0)