Skip to content

Commit

Permalink
changes from CR
Browse files Browse the repository at this point in the history
  • Loading branch information
atabel committed Dec 9, 2024
1 parent 2b8e4eb commit 2b13fa2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
Binary file not shown.
52 changes: 26 additions & 26 deletions .yarn/patches/playroom-npm-0.39.0-24448abd08.patch
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ index 0000000000000000000000000000000000000000..21d14ae14f317c051123f269242ee58d
+]);
diff --git a/src/Playroom/AiPanel/AiPanel.tsx b/src/Playroom/AiPanel/AiPanel.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..dd60b29783442680768eba84b600c2f5a90b6a5d
index 0000000000000000000000000000000000000000..57e123e4dfc28dbd4154d2c7bb62d47596ecbf25
--- /dev/null
+++ b/src/Playroom/AiPanel/AiPanel.tsx
@@ -0,0 +1,506 @@
Expand Down Expand Up @@ -187,7 +187,7 @@ index 0000000000000000000000000000000000000000..dd60b29783442680768eba84b600c2f5
+// export const aiBaseUrl = `http://localhost:3000`;
+export const aiBaseUrl = `https://mistica-playroom-api.tooling-dev.svc.dev.tuenti.io`;
+
+const fetchApi = (path: string, options?: RequestInit): Promise<Response> =>
+const fetchApi = (path: string, options?: RequestInit): Promise<any> =>
+ fetch(`${aiBaseUrl}${path}`, {
+ credentials: 'include',
+ method: 'POST',
Expand All @@ -202,42 +202,42 @@ index 0000000000000000000000000000000000000000..dd60b29783442680768eba84b600c2f5
+ window.location.assign('/oauth2/sign_in');
+ return new Promise(() => {}); // never resolve, as we are redirecting to login
+ }
+ return response;
+ return response.json();
+ });
+
+const sendMessageToAi = (conversationId: string, message: string) =>
+const sendMessageToAi = (
+ conversationId: string,
+ message: string
+): Promise<string> =>
+ fetchApi('/send-message', {
+ body: JSON.stringify({ conversationId, message }),
+ })
+ .then((response) => response.json())
+ .then((data) => {
+ if (!data.success) {
+ throw new Error(data.error);
+ }
+ return data.source;
+ });
+ }).then((data) => {
+ if (!data.success) {
+ throw new Error(data.error);
+ }
+ return data.source;
+ });
+
+const createConversation = (): Promise<string> =>
+ fetchApi('/create-conversation')
+ .then((response) => response.json())
+ .then((data) => data.conversationId);
+ fetchApi('/create-conversation').then((data) => data.conversationId);
+
+const deleteConversation = (conversationId: string) =>
+const deleteConversation = (conversationId: string): Promise<void> =>
+ fetchApi('/delete-conversation', {
+ body: JSON.stringify({ conversationId }),
+ });
+ }).then(() => {});
+
+const regenerateMessage = (conversationId: string, messageIndex: number) =>
+const regenerateMessage = (
+ conversationId: string,
+ messageIndex: number
+): Promise<string> =>
+ fetchApi('/regenerate-message', {
+ body: JSON.stringify({ conversationId, messageIndex }),
+ })
+ .then((response) => response.json())
+ .then((data) => {
+ if (!data.success) {
+ throw new Error(data.error);
+ }
+ return data.source;
+ });
+ }).then((data) => {
+ if (!data.success) {
+ throw new Error(data.error);
+ }
+ return data.source;
+ });
+
+export const EmptyState = ({
+ onImagePaste,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"detect-circular-dependencies": "npx dpdm --circular src/index.tsx",
"audit-accessibility": "node .github/actions/audit-accessibility/main.js",
"circular-dependencies": "yarn dpdm src/index.tsx --tree=false --warning=false --exit-code circular:1",
"prepare": "husky install"
"prepare": "husky install",
"edit-playroom-patch": "playroom/patch-playroom.sh"
},
"browserslist": [
"chrome >= 51",
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17966,7 +17966,7 @@ __metadata:

"playroom@patch:playroom@npm%3A0.39.0#./.yarn/patches/playroom-npm-0.39.0-24448abd08.patch::locator=%40telefonica%2Fmistica%40workspace%3A.":
version: 0.39.0
resolution: "playroom@patch:playroom@npm%3A0.39.0#./.yarn/patches/playroom-npm-0.39.0-24448abd08.patch::version=0.39.0&hash=bc8505&locator=%40telefonica%2Fmistica%40workspace%3A."
resolution: "playroom@patch:playroom@npm%3A0.39.0#./.yarn/patches/playroom-npm-0.39.0-24448abd08.patch::version=0.39.0&hash=2ce33c&locator=%40telefonica%2Fmistica%40workspace%3A."
dependencies:
"@babel/core": ^7.20.5
"@babel/parser": ^7.23.4
Expand Down Expand Up @@ -18028,7 +18028,7 @@ __metadata:
react-dom: ^17 || ^18
bin:
playroom: bin/cli.cjs
checksum: afc8c31a5a94c624f9011f0c825f8ae0e7a3958139c750f0d7f55c2e95c60ed492b2b31a40261eeea2f9bae5d6bd1c544f53f5e6985e36c522c3a857b6f80ac3
checksum: 4519b01e0bbf62650671841a75c935e0f26e91f55380816d6f9f85e843c25672c039d43f7eb1a0f289cd19253bb08e7fb73f9f5b214e76b20d8636fe219c5bf1
languageName: node
linkType: hard

Expand Down

0 comments on commit 2b13fa2

Please sign in to comment.