ags: sync

This commit is contained in:
end-4
2024-02-16 17:08:11 +07:00
parent 631d0da839
commit a83d93e98a
52 changed files with 2648 additions and 756 deletions
+21 -11
View File
@@ -13,19 +13,12 @@ import Gemini from '../../services/gemini.js';
import { geminiView, geminiCommands, sendMessage as geminiSendMessage, geminiTabIcon } from './apis/gemini.js';
import { chatGPTView, chatGPTCommands, sendMessage as chatGPTSendMessage, chatGPTTabIcon } from './apis/chatgpt.js';
import { waifuView, waifuCommands, sendMessage as waifuSendMessage, waifuTabIcon } from './apis/waifu.js';
const TextView = Widget.subclass(Gtk.TextView, "AgsTextView");
import { enableClickthrough } from '../../lib/roundedcorner.js';
const TextView = Widget.subclass(Gtk.TextView, "AgsTextView");
const EXPAND_INPUT_THRESHOLD = 30;
const APIS = [
{
name: 'Assistant (ChatGPT 3.5)',
sendCommand: chatGPTSendMessage,
contentWidget: chatGPTView,
commandBar: chatGPTCommands,
tabIcon: chatGPTTabIcon,
placeholderText: 'Message ChatGPT...',
},
{
name: 'Assistant (Gemini Pro)',
sendCommand: geminiSendMessage,
@@ -34,6 +27,14 @@ const APIS = [
tabIcon: geminiTabIcon,
placeholderText: 'Message Gemini...',
},
{
name: 'Assistant (ChatGPT 3.5)',
sendCommand: chatGPTSendMessage,
contentWidget: chatGPTView,
commandBar: chatGPTCommands,
tabIcon: chatGPTTabIcon,
placeholderText: 'Message ChatGPT...',
},
{
name: 'Waifus',
sendCommand: waifuSendMessage,
@@ -141,6 +142,7 @@ const chatPlaceholderRevealer = Revealer({
transition: 'crossfade',
transitionDuration: 200,
child: chatPlaceholder,
setup: enableClickthrough,
});
const textboxArea = Box({ // Entry area
@@ -159,12 +161,20 @@ const textboxArea = Box({ // Entry area
const apiContentStack = Stack({
vexpand: true,
transition: 'slide_left_right',
items: APIS.map(api => [api.name, api.contentWidget]),
transitionDuration: 160,
children: APIS.reduce((acc, api) => {
acc[api.name] = api.contentWidget;
return acc;
}, {}),
})
const apiCommandStack = Stack({
transition: 'slide_up_down',
items: APIS.map(api => [api.name, api.commandBar]),
transitionDuration: 160,
children: APIS.reduce((acc, api) => {
acc[api.name] = api.commandBar;
return acc;
}, {}),
})
function switchToTab(id) {