Skip to content

Commit

Permalink
open ai layout
Browse files Browse the repository at this point in the history
SQUASHED: AUTO-COMMIT-src-client-contextmenu.js,AUTO-COMMIT-src-client-openai.js,AUTO-COMMIT-src-components-tools-openai-audio-chat.html,
  • Loading branch information
JensLincke committed May 23, 2024
1 parent 25de4fd commit 3ca078a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/client/contextmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { iconStringForFileEntry } from 'src/client/utils/font-awesome-utils.js'

// import lively from './lively.js'; #TODO resinsert after we support cycles again

var lastOpenEvent

export default class ContextMenu {

constructor(target, optItems, options) {
Expand All @@ -36,7 +38,7 @@ export default class ContextMenu {
}

openIn(container, evt, target, worldContext) {
return ContextMenu.openIn(container, evt, target, worldContext, this.items, this.options);
return ContextMenu.openIn(container, evt, target, worldContext, this.items, this.options);
}

static hide() {
Expand Down Expand Up @@ -667,7 +669,7 @@ export default class ContextMenu {
["Scholar Author", evt => lively.openBrowser("scholar://browse/author/search?query=Hidehiko Masuhara"), "", '<i class="fa fa-book" aria-hidden="true"></i>'],
["OpenAI chat", async evt => {

await this.openComponentInWindow("openai-audio-chat", evt, worldContext);
await this.openComponentInWindow("openai-audio-chat", lastOpenEvent, worldContext);
}],

], undefined, '<i class="fa fa-wrench" aria-hidden="true"></i>'],
Expand Down Expand Up @@ -909,6 +911,8 @@ export default class ContextMenu {
}

static openIn(container, evt, target, worldContext, optItems, options) {
lastOpenEvent = evt

this.hide();
this.firstEvent = evt

Expand Down
13 changes: 13 additions & 0 deletions src/client/openai.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ export default class OpenAI {
return localStorage.getItem(openAiSubscriptionKeyId);
}

static async get(url) {
const apiKey = await this.ensureSubscriptionKey();

const requestOptions = {
method: "GET",
headers: {
"Authorization": `Bearer ${apiKey}`
},
body: JSON.stringify(prompt)
};
return fetch(url, requestOptions);
}

}


Expand Down
4 changes: 2 additions & 2 deletions src/components/tools/openai-audio-chat.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@
}

#responses li.user {
background: lightgray;
background: #F3F3F3;
border-radius: 10px;
text-align: right;
padding: 2px;
padding-right: 10px;
padding-left: 10px;

}

Expand Down

0 comments on commit 3ca078a

Please sign in to comment.