Skip to content

Commit fde254c

Browse files
committed
financial app work
1 parent 214e99b commit fde254c

File tree

8 files changed

+68
-36
lines changed

8 files changed

+68
-36
lines changed

interactive-ai-holograms/java-version/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Ie, there are examples for various AI services in app but none of them are neede
1414
It is necessary to export a few values. Here's is the contents of build_and_runrun.ps1 to give the idea...
1515
```commandline
1616
$env:SANDBOX_API_URL = "http://129.80.247.232:8000/v1/chat/completions"
17-
$env:SANDBOX_AUTH_TOKEN = "Bearer asdf"
17+
$env:AI_OPTIMZER = "Bearer asdf"
1818
$env:AIHOLO_HOST_URL = "https://aiholo.org/"
1919
$env:AUDIO_DIR_PATH = "C:/Users/opc/src/github.com/paulparkinson/oracle-ai-for-sustainable-dev/interactive-ai-holograms/java-version/src/main/resources/static/audio-aiholo"
2020

interactive-ai-holograms/java-version/build_and_run.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Set the environment variables
22
$env:SANDBOX_API_URL = "http://129.80.247.232:8000/v1/chat/completions"
3-
$env:SANDBOX_AUTH_TOKEN = "Bearer asdf"
3+
$env:AI_OPTIMZER = "Bearer asdf"
44
$env:AIHOLO_HOST_URL = "https://aiholo.org/"
55
$env:AUDIO_DIR_PATH = "C:/Users/opc/src/github.com/paulparkinson/oracle-ai-for-sustainable-dev/interactive-ai-holograms/java-version/src/main/resources/static/audio-aiholo"
66

interactive-ai-holograms/java-version/build_and_run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
export `cat env.properties`
44
export SANDBOX_API_URL="http://129.80.247.232:8000/v1/chat/completions"
5-
export SANDBOX_AUTH_TOKEN="Bearer asdf"
5+
export AI_OPTIMZER="Bearer asdf"
66
export AIHOLO_HOST_URL="https://aiholo.org/"
77
export AUDIO_DIR_PATH="C:/Users/opc/src/github.com/paulparkinson/oracle-ai-for-sustainable-dev/interactive-ai-holograms/java-version/src/main/resources/static/audio-aiholo"
88
#export `cat ~/Downloads/env.properties`

interactive-ai-holograms/java-version/src/main/java/oracleai/aiholo/AIHoloController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class AIHoloController {
5252
private String theValue = "mirrorme";
5353
private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
5454
private static final String SANDBOX_API_URL = System.getenv("SANDBOX_API_URL");
55-
private static final String SANDBOX_AUTH_TOKEN = System.getenv("SANDBOX_AUTH_TOKEN");
55+
private static final String AI_OPTIMZER = System.getenv("AI_OPTIMZER");
5656
static final String AUDIO_DIR_PATH = System.getenv("AUDIO_DIR_PATH");
5757
static int currentAnswerIntro = 0;
5858
private static final String DEFAULT_LANGUAGE_CODE = "es-ES";
@@ -283,7 +283,7 @@ public String executeSandbox(String cummulativeResult) {
283283
JSONObject jsonPayload = new JSONObject(payload);
284284
HttpHeaders headers = new HttpHeaders();
285285
headers.setContentType(MediaType.APPLICATION_JSON);
286-
headers.set("Authorization", SANDBOX_AUTH_TOKEN);
286+
headers.set("Authorization", AI_OPTIMZER);
287287
headers.set("Accept", "application/json");
288288
headers.set("client", "server");
289289
HttpEntity<String> request = new HttpEntity<>(jsonPayload.toString(), headers);

interactive-ai-holograms/java-version/src/main/java/oracleai/aiholo/AIHoloController.java0

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class AIHoloController {
5252
private String theValue = "mirrorme";
5353
private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
5454
private static final String SANDBOX_API_URL = System.getenv("SANDBOX_API_URL");
55-
private static final String SANDBOX_AUTH_TOKEN = System.getenv("SANDBOX_AUTH_TOKEN");
55+
private static final String AI_OPTIMZER = System.getenv("AI_OPTIMZER");
5656
static final String AUDIO_DIR_PATH = System.getenv("AUDIO_DIR_PATH");
5757
private static final String DEFAULT_LANGUAGE_CODE = "es-ES";
5858
private static final String DEFAULT_VOICE_NAME = "es-ES-Wavenet-D";
@@ -233,7 +233,7 @@ public class AIHoloController {
233233
JSONObject jsonPayload = new JSONObject(payload);
234234
HttpHeaders headers = new HttpHeaders();
235235
headers.setContentType(MediaType.APPLICATION_JSON);
236-
headers.set("Authorization", SANDBOX_AUTH_TOKEN);
236+
headers.set("Authorization", AI_OPTIMZER);
237237
headers.set("Accept", "application/json");
238238
headers.set("client", "server");
239239
HttpEntity<String> request = new HttpEntity<>(jsonPayload.toString(), headers);

interactive-ai-holograms/java-version/src/main/resources/templates/aiholo.html

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -318,23 +318,43 @@ <h5>Ask the hologram a question and get a reply!</h5>
318318
const listeningSound = document.getElementById("listeningSound");
319319
const sendingSound = document.getElementById("sendingSound");
320320

321-
singleBtnMode.addEventListener("click", () => {
322-
if (!singleBtnModeState) {
323-
// Start recognition
324-
if (!isListening) recognition.start();
321+
// Mouse down/up logic for press-to-talk
322+
singleBtnMode.addEventListener("mousedown", () => {
323+
if (!isListening && recognition) {
324+
recognition.start();
325325
singleBtnIcon.src = stopIcon;
326-
singleBtnModeState = true;
327326
singleBtnMode.disabled = false;
328-
// Play listening sound
329327
listeningSound.currentTime = 0;
330328
listeningSound.play();
331-
} else {
332-
// Stop recognition (always call stop, let onend handle the rest)
329+
}
330+
});
331+
332+
singleBtnMode.addEventListener("mouseup", () => {
333+
if (isListening && recognition) {
333334
recognition.stop();
334-
singleBtnMode.disabled = true; // Prevent double clicks
335-
// Only clear the display for feedback, NOT the buffer!
336-
document.getElementById("transcription").innerText = "";
337-
// Play sending sound
335+
singleBtnMode.disabled = true; // Prevent double triggers
336+
sendingSound.currentTime = 0;
337+
sendingSound.play();
338+
}
339+
});
340+
341+
// Also support touch devices
342+
singleBtnMode.addEventListener("touchstart", (e) => {
343+
e.preventDefault();
344+
if (!isListening && recognition) {
345+
recognition.start();
346+
singleBtnIcon.src = stopIcon;
347+
singleBtnMode.disabled = false;
348+
listeningSound.currentTime = 0;
349+
listeningSound.play();
350+
}
351+
});
352+
353+
singleBtnMode.addEventListener("touchend", (e) => {
354+
e.preventDefault();
355+
if (isListening && recognition) {
356+
recognition.stop();
357+
singleBtnMode.disabled = true;
338358
sendingSound.currentTime = 0;
339359
sendingSound.play();
340360
}
@@ -343,12 +363,12 @@ <h5>Ask the hologram a question and get a reply!</h5>
343363
if (recognition) {
344364
recognition.onstart = () => {
345365
singleBtnIcon.src = stopIcon;
346-
singleBtnModeState = true;
366+
isListening = true;
347367
singleBtnMode.disabled = false;
348368
};
349369
recognition.onend = async () => {
350370
singleBtnIcon.src = micIcon;
351-
singleBtnModeState = false;
371+
isListening = false;
352372
singleBtnMode.disabled = false;
353373
await sendTranscript();
354374
transcriptBuffer = "";

interactive-ai-holograms/java-version/src/main/resources/templates/aiholo0.html

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171

7272
<!-- Language selection -->
7373
<div class="flags">
74+
<a href="aiholo?languageCode=he-IL"><img src="../images-aiholo/Flags/ko-KO.svg" alt="Korean"></a>
7475
<a href="aiholo?languageCode=he-IL"><img src="../images-aiholo/Flags/he-IL.svg" alt="Hebrew"></a>
7576
<a href="aiholo?languageCode=de-DE"><img src="../images-aiholo/Flags/de-DE.svg" alt="German"></a>
7677
<a href="aiholo?languageCode=es-MX"><img src="../images-aiholo/Flags/es-MX.svg" alt="Spanish (Mexico)"></a>
@@ -383,8 +384,8 @@ <h5>Ask the hologram a question and get a reply!</h5>
383384
<div class="footer">
384385
<form id="footerSayForm" class="input-group" action="https://aiholo.org/aiholo/playarbitrary" method="GET">
385386
<input type="text" id="speechInput" name="answer" class="form-control" placeholder="Type something to say directly..." required>
386-
<input type="hidden" name="languageCode" value="en-US">
387-
<input type="hidden" name="voiceName" value="en-US-Wavenet-A">
387+
<input type="hidden" id="footerLanguageCode" name="languageCode" value="" />
388+
<input type="hidden" id="footerVoiceName" name="voiceName" value="" />
388389
<div class="input-group-append">
389390
<button type="submit" style="background:none; border:none; padding:0;" title="Submit">
390391
<img src="../images-aiholo/Icons/Yellow/Stop recording.svg" style="cursor:pointer;">
@@ -393,6 +394,22 @@ <h5>Ask the hologram a question and get a reply!</h5>
393394
</div>
394395
</form>
395396
</div>
396-
397+
<script>
398+
// Set the languageCode and voiceName from the JS variables used elsewhere
399+
document.addEventListener("DOMContentLoaded", function () {
400+
document.getElementById("footerLanguageCode").value = typeof languageCodeSTT !== "undefined" ? languageCodeSTT : "en-US";
401+
document.getElementById("footerVoiceName").value = typeof voiceName !== "undefined" ? voiceName : "en-US-Wavenet-A";
402+
403+
document.getElementById("footerSayForm").addEventListener("submit", function (e) {
404+
e.preventDefault();
405+
const answer = document.getElementById("speechInput").value;
406+
const languageCode = document.getElementById("footerLanguageCode").value;
407+
const voiceName = document.getElementById("footerVoiceName").value;
408+
const fileName = "footer.wav";
409+
const url = `https://aiholo.org/aiholo/playarbitrary?fileName=${encodeURIComponent(fileName)}&answer=${encodeURIComponent(answer)}&languageCode=${encodeURIComponent(languageCode)}&voiceName=${encodeURIComponent(voiceName)}`;
410+
window.open(url, "aiholoFooterSay", "width=600,height=400");
411+
});
412+
});
413+
</script>
397414
</body>
398415
</html>

interactive-ai-holograms/python-realtimespeech-selectai/src/AIHoloRest.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,36 +79,31 @@ def executeSelectAI(cummulativeResult: str = None):
7979
{"containsWord": "satellites", "latestQuestion": "satellites", "latestAnswer": "satellites"},
8080
{"containsWord": "spatial", "latestQuestion": "spatial", "latestAnswer": "spatial"}
8181
]
82-
# other profiles includes AIHOLO , VIDEOGAMES_PROFILE, MOVIESTREAM
82+
# profile_name(s) specify what LLMs, tables, vectors, etc. to use.
8383
chatquery = """SELECT DBMS_CLOUD_AI.GENERATE(
8484
prompt => :prompt,
85-
profile_name => 'AIHOLO',
86-
action => 'chat')
87-
FROM dual"""
85+
profile_name => 'AIHOLO_OCIGENAI',
86+
action => 'chat')"""
8887

8988
narratequery = """SELECT DBMS_CLOUD_AI.GENERATE(
9089
prompt => :prompt,
9190
profile_name => 'AIHOLO',
92-
action => 'narrate')
93-
FROM dual"""
91+
action => 'narrate')"""
9492

9593
runsqlquery = """SELECT DBMS_CLOUD_AI.GENERATE(
9694
prompt => :prompt,
9795
profile_name => 'AIHOLO',
98-
action => 'runsql')
99-
FROM dual"""
96+
action => 'runsql')"""
10097

10198
showssqlquery = """SELECT DBMS_CLOUD_AI.GENERATE(
10299
prompt => :prompt,
103100
profile_name => 'AIHOLO',
104-
action => 'showsql')
105-
FROM dual"""
101+
action => 'showsql')"""
106102

107103
explainsqlquery = """SELECT DBMS_CLOUD_AI.GENERATE(
108104
prompt => :prompt,
109105
profile_name => 'AIHOLO',
110-
action => 'explainsql')
111-
FROM dual"""
106+
action => 'explainsql')"""
112107

113108
if isShowSQL:
114109
query = showssqlquery

0 commit comments

Comments
 (0)