Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code cleanup and random number updates to remove requirement on HTTPS #26

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions app/src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import { createContext } from "preact";
type Props = {
appName: string;
};
const convoUUID = window.crypto.randomUUID();
export const ConvoCtx = createContext(convoUUID);
const tempArray = new Uint32Array(10);
const convoUUID = window.crypto.getRandomValues(tempArray);

export const ConvoCtx = createContext("");

export const App = registerCustomElement("app-root", (props: Props) => {
props.appName = "Generative AI JET UI";

return (
<div id="appContainer" class="oj-web-applayout-page">
<ConvoCtx.Provider value={convoUUID}>
{console.log("UUID: ", convoUUID)}
<ConvoCtx.Provider value={convoUUID[0].toString()}>
{console.log("UUID: ", convoUUID[0].toString())}
<Header appName={props.appName} />
<Content />
</ConvoCtx.Provider>
Expand Down
2 changes: 0 additions & 2 deletions app/src/components/content/stomp-interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const InitStomp = (
chatData: any,
serviceType: any
) => {
//const [test, setTest] = useState();
const protocol = window.location.protocol === "http:" ? "ws://" : "wss://";
const hostname =
window.location.hostname === "localhost"
Expand Down Expand Up @@ -47,7 +46,6 @@ export const InitStomp = (

const onMessage = (msg: any) => {
let aiAnswer = JSON.parse(msg.body).content;
//console.log("answer: ", aiAnswer);
if (msg.data !== "connected") {
let tempArray = [...chatData.current];
// remove the animation item before adding answer
Expand Down
11 changes: 9 additions & 2 deletions app/src/components/content/summary.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "preact";
import { useState, useRef, useEffect } from "preact/hooks";
import { useState, useRef, useEffect, useContext } from "preact/hooks";
import "md-wrapper/loader";
import "ojs/ojtoolbar";
import "oj-c/file-picker";
Expand All @@ -13,6 +13,7 @@ import { CFilePickerElement } from "oj-c/file-picker";
import { CInputTextElement } from "oj-c/input-text";
import { CButtonElement } from "oj-c/button";
import MutableArrayDataProvider = require("ojs/ojmutablearraydataprovider");
import { ConvoCtx } from "../app";

declare global {
namespace preact.JSX {
Expand Down Expand Up @@ -47,6 +48,7 @@ export const Summary = ({
summary,
backendType,
}: Props) => {
const conversationId = useContext(ConvoCtx);
const [invalidMessage, setInvalidMessage] = useState<string | null>(null);
const [summaryPrompt, setSummaryPrompt] = useState<string>("");
const [summaryResults, setSummaryResults] = useState<string | null>(summary);
Expand Down Expand Up @@ -89,6 +91,7 @@ export const Summary = ({
mode: "cors",
referrerPolicy: "strict-origin-when-cross-origin",
body: formData,
headers: { conversationID: conversationId, modelId: "" },
});
console.log("Response: ", res);
const responseData = await res.json();
Expand Down Expand Up @@ -330,7 +333,11 @@ export const Summary = ({
</>
)}
{invalidFiles.current.length !== 1 && fileNames && summary && (
<div id="summaryContent" class="oj-panel oj-sm-width-full">
<div
id="summaryContent"
class="oj-panel oj-sm-width-full oj-color-invert oj-sm-padding-4x oj-sm-margin-6x-top"
style="background-color: var(--oj-sp-header-welcome-banner-background-color);"
>
<md-wrapper
id="TestingOne"
class="oj-sm-width-full"
Expand Down