sidebar: add google gemini api

This commit is contained in:
end-4
2024-01-24 20:19:00 +07:00
parent b7d2d2bd4f
commit 2838a1a8c1
7 changed files with 648 additions and 17 deletions
+26 -11
View File
@@ -8,26 +8,41 @@ const { execAsync, exec } = Utils;
import ChatGPT from '../../../services/chatgpt.js';
import { MaterialIcon } from "../../../lib/materialicon.js";
import { setupCursorHover, setupCursorHoverInfo } from "../../../lib/cursorhover.js";
import { SystemMessage, ChatMessage } from "./chatgpt_chatmessage.js";
import { SystemMessage, ChatMessage } from "./ai_chatmessage.js";
import { ConfigToggle, ConfigSegmentedSelection, ConfigGap } from '../../../lib/configwidgets.js';
import { markdownTest } from '../../../lib/md2pango.js';
import { MarginRevealer } from '../../../lib/advancedwidgets.js';
export const chatGPTTabIcon = Box({
Gtk.IconTheme.get_default().append_search_path(`${App.configDir}/assets`);
export const chatGPTTabIcon = Icon({
hpack: 'center',
className: 'sidebar-chat-apiswitcher-icon',
homogeneous: true,
children: [
MaterialIcon('forum', 'norm'),
],
icon: `openai-symbolic`,
setup: (self) => Utils.timeout(513, () => { // stupid condition race
const styleContext = self.get_style_context();
const width = styleContext.get_property('min-width', Gtk.StateFlags.NORMAL);
const height = styleContext.get_property('min-height', Gtk.StateFlags.NORMAL);
// console.log(Math.round(Math.max(width, height, 1)));
self.size = Math.max(width, height, 1) * 116 / 180;
// ↑ Why such a specific proportion? See https://openai.com/brand#logos
})
});
const ChatGPTInfo = () => {
const openAiLogo = Label({
const openAiLogo = Icon({
hpack: 'center',
className: 'sidebar-chat-welcome-logo',
label: 'forum',
})
icon: `openai-symbolic`,
setup: (self) => Utils.timeout(513, () => { // stupid condition race
const styleContext = self.get_style_context();
const width = styleContext.get_property('min-width', Gtk.StateFlags.NORMAL);
const height = styleContext.get_property('min-height', Gtk.StateFlags.NORMAL);
// console.log(Math.round(Math.max(width, height, 1)));
self.size = Math.max(width, height, 1) * 116 / 180;
// ↑ Why such a specific proportion? See https://openai.com/brand#logos
})
});
return Box({
vertical: true,
className: 'spacing-v-15',
@@ -37,7 +52,7 @@ const ChatGPTInfo = () => {
className: 'txt txt-title-small sidebar-chat-welcome-txt',
wrap: true,
justify: Gtk.Justification.CENTER,
label: 'Assistant',
label: 'Assistant (ChatGPT)',
}),
Box({
className: 'spacing-h-5',
@@ -169,7 +184,7 @@ export const chatContent = Box({
.hook(ChatGPT, (box, id) => {
const message = ChatGPT.messages[id];
if (!message) return;
box.add(ChatMessage(message, chatGPTView))
box.add(ChatMessage(message, 'ChatGPT'))
}, 'newMsg')
,
});