Skip to content

Commit 3fdb5a2

Browse files
committed
init
1 parent 3f4dc12 commit 3fdb5a2

File tree

26,822 files changed

+4005873
-9
lines changed

Some content is hidden

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

26,822 files changed

+4005873
-9
lines changed

.gitignore

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

.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: 156 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +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 UI's which are fast, lightweight, and engaging. Your code takes center 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 for enhanced customer support solutions.
12+
13+
![alt text here](images/main.png)
914

1015
## Getting Started
11-
MISSING
16+
17+
### 0. Set up
18+
19+
```text
20+
Follow links below to generate a config file and a key pair in your ~/.oci directory
21+
https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm
22+
https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm
23+
https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/cliinstall.htm#configfile
24+
25+
After completion, you should have following 2 things in your ~/.oci directory
26+
27+
a. A config file(where key file point to private key:key_file=~/.oci/oci_api_key.pem)
28+
b. A key pair named oci_api_key.pem and oci_api_key_public.pem
29+
30+
Now make sure you change the reference of key file in config file (where key file point to private key:key_file=/YOUR_DIR_TO_KEY_FILE/oci_api_key.pem)
31+
```
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 root of 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+
```text
72+
# Upload your oci_api_key_public.pem to console:
73+
https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#three
74+
```
75+
76+
### 3. Make sure you have python installed on your machine
77+
78+
- In cli run following command to validate Python version
79+
`python --version`
80+
81+
You should see similar output:
82+
83+
```shell
84+
Python 3.8.3
85+
```
86+
87+
### 4. Install all dependencies(include our beta version SDK)
88+
89+
We suggest you install dependencies in a virtual env to avoid conflicts on your system.
90+
91+
- Navigate to the server root folder
92+
`cd /service/python`
93+
- Create vitrual environment:
94+
`python3 -m venv venv`
95+
- Activate your virtual environment:
96+
`. venv/bin/activate`
97+
- Upgrade pip:
98+
`pip install --upgrade pip`
99+
- Install requirements:
100+
`pip install -r requirements.txt`
101+
102+
## 5. Start Python server websocket app
103+
104+
Once dependencies are installed and your service credentials are updated you can run server.py
105+
106+
- `python server.py`
107+
108+
## 6. Start JET Client
109+
110+
- Open app directory:
111+
`cd app/`
112+
- Install dependencies:
113+
`ojet restore`
114+
- Run local version:
115+
`ojet serve`
116+
- Or package for web deployment
117+
`ojet build web`
118+
119+
Ask you questions to generate AI response
120+
![alt text here](images/QandA.png)
121+
122+
Note that app is capable of generating markdown
123+
![alt text here](images/Markdown.png)
124+
125+
## Appendix: Token-based Authentication
126+
127+
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)
128+
if need to run testing with session token via BOAT. Here is the sample config to setup client with session token in the test scripts:
129+
130+
```Python
131+
config = oci.config.from_file('~/.oci/config', profile_name="DEFAULT")
132+
133+
def make_security_token_signer(oci_config):
134+
pk = oci.signer.load_private_key_from_file(oci_config.get("key_file"), None)
135+
with open(oci_config.get("security_token_file")) as f:
136+
st_string = f.read()
137+
return oci.auth.signers.SecurityTokenSigner(st_string, pk)
138+
139+
signer = make_security_token_signer(oci_config=config)
140+
# Service endpoint
141+
endpoint = "https://generativeai.aiservice.<Region>.oci.oraclecloud.com"
142+
143+
generative_ai_client = oci.generative_ai.generative_ai_client.GenerativeAiClient(config=config, service_endpoint=endpoint, retry_strategy=oci.retry.NoneRetryStrategy(), signer=signer)
144+
```
12145

13146
### Prerequisites
14-
MISSING
147+
148+
- OCI Account
149+
- OCI Generative Service
150+
- Oracle JET
151+
- Python3
15152

16153
## Notes/Issues
17-
MISSING
154+
155+
Additional Use Cases like summarization and embedding coming soon.
156+
157+
To change output parameters edit server.py
158+
159+
```Python
160+
cohere_generate_text_request.max_tokens = 500 # choose number of tokens 1-4000
161+
cohere_generate_text_request.temperature = 0.75 # adjust temperature
162+
cohere_generate_text_request.top_p = 0.7 # adjust top_p
163+
cohere_generate_text_request.frequency_penalty = 1.0 # adjust frequency_penalty
164+
```
18165

19166
## URLs
20-
* Nothing at this time
167+
* developer.oracle.com/ai
168+
* oracle.com/ai
21169

22170
## Contributing
23171
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.
24172

25173
## License
26-
Copyright (c) 2022 Oracle and/or its affiliates.
174+
Copyright (c) 2024 Oracle and/or its affiliates.
27175

28176
Licensed under the Universal Permissive License (UPL), Version 1.0.
29177

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+
# RUN npm install -g @oracle/ojet-cli
6+
7+
WORKDIR /usr/share/build
8+
9+
RUN mkdir -p /usr/share/build/src \
10+
&& mkdir -p /usr/share/build/scripts
11+
12+
COPY src/ /usr/share/build/src/
13+
14+
COPY scripts/ /usr/share/build/scripts/
15+
16+
COPY *.json /usr/share/build/
17+
18+
RUN npm install
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)