From dd56bd1d7ed880534e2291555164b3826f98c859 Mon Sep 17 00:00:00 2001 From: Amos Jun-yeung Ng Date: Sun, 19 May 2024 16:03:30 +0700 Subject: [PATCH] Allow bindings.ts to be formatted by prettier --- .prettierignore | 1 - src-svelte/src/lib/bindings.ts | 109 +++++++++++++++++++++++---------- 2 files changed, 78 insertions(+), 32 deletions(-) delete mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index d083a2c3..00000000 --- a/.prettierignore +++ /dev/null @@ -1 +0,0 @@ -src-svelte/src/lib/bindings.ts \ No newline at end of file diff --git a/src-svelte/src/lib/bindings.ts b/src-svelte/src/lib/bindings.ts index 7b68cde6..4a80fa37 100644 --- a/src-svelte/src/lib/bindings.ts +++ b/src-svelte/src/lib/bindings.ts @@ -2,64 +2,111 @@ // This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually. declare global { - interface Window { - __TAURI_INVOKE__(cmd: string, args?: Record): Promise; - } + interface Window { + __TAURI_INVOKE__( + cmd: string, + args?: Record, + ): Promise; + } } // Function avoids 'window not defined' in SSR const invoke = () => window.__TAURI_INVOKE__; export function getApiKeys() { - return invoke()("get_api_keys") + return invoke()("get_api_keys"); } -export function setApiKey(filename: string | null, service: Service, apiKey: string) { - return invoke()("set_api_key", { filename,service,apiKey }) +export function setApiKey( + filename: string | null, + service: Service, + apiKey: string, +) { + return invoke()("set_api_key", { filename, service, apiKey }); } export function playSound(sound: Sound, volume: number, speed: number) { - return invoke()("play_sound", { sound,volume,speed }) + return invoke()("play_sound", { sound, volume, speed }); } export function getPreferences() { - return invoke()("get_preferences") + return invoke()("get_preferences"); } export function setPreferences(preferences: Preferences) { - return invoke()("set_preferences", { preferences }) + return invoke()("set_preferences", { preferences }); } export function getSystemInfo() { - return invoke()("get_system_info") + return invoke()("get_system_info"); } -export function chat(provider: Service, llm: string, temperature: number | null, prompt: ChatMessage[]) { - return invoke()("chat", { provider,llm,temperature,prompt }) +export function chat( + provider: Service, + llm: string, + temperature: number | null, + prompt: ChatMessage[], +) { + return invoke()("chat", { + provider, + llm, + temperature, + prompt, + }); } export function getApiCall(id: string) { - return invoke()("get_api_call", { id }) + return invoke()("get_api_call", { id }); } export function getApiCalls(offset: number) { - return invoke()("get_api_calls", { offset }) + return invoke()("get_api_calls", { offset }); } -export type ChatMessage = { role: "System"; text: string } | { role: "Human"; text: string } | { role: "AI"; text: string } -export type Prompt = ({ type: "Chat" } & ChatPrompt) -export type Response = { completion: ChatMessage } -export type Service = "OpenAI" -export type Request = { prompt: Prompt; temperature: number } -export type Preferences = { animations_on?: boolean | null; background_animation?: boolean | null; animation_speed?: number | null; transparency_on?: boolean | null; sound_on?: boolean | null; volume?: number | null } -export type Llm = { name: string; requested: string; provider: Service } -export type LightweightLlmCall = { id: EntityId; timestamp: string; response_message: ChatMessage } -export type LlmCall = { id: EntityId; timestamp: string; llm: Llm; request: Request; response: Response; tokens: TokenMetadata } -export type ApiKeys = { openai: string | null } -export type OS = "Mac" | "Linux" | "Windows" -export type Shell = "Bash" | "Zsh" | "PowerShell" -export type SystemInfo = { zamm_version: string; os: OS | null; shell: Shell | null; shell_init_file: string | null } -export type ChatPrompt = { messages: ChatMessage[] } -export type TokenMetadata = { prompt: number | null; response: number | null; total: number | null } -export type Sound = "Switch" | "Whoosh" -export type EntityId = { uuid: string } +export type ChatMessage = + | { role: "System"; text: string } + | { role: "Human"; text: string } + | { role: "AI"; text: string }; +export type Prompt = { type: "Chat" } & ChatPrompt; +export type Response = { completion: ChatMessage }; +export type Service = "OpenAI"; +export type Request = { prompt: Prompt; temperature: number }; +export type Preferences = { + animations_on?: boolean | null; + background_animation?: boolean | null; + animation_speed?: number | null; + transparency_on?: boolean | null; + sound_on?: boolean | null; + volume?: number | null; +}; +export type Llm = { name: string; requested: string; provider: Service }; +export type LightweightLlmCall = { + id: EntityId; + timestamp: string; + response_message: ChatMessage; +}; +export type LlmCall = { + id: EntityId; + timestamp: string; + llm: Llm; + request: Request; + response: Response; + tokens: TokenMetadata; +}; +export type ApiKeys = { openai: string | null }; +export type OS = "Mac" | "Linux" | "Windows"; +export type Shell = "Bash" | "Zsh" | "PowerShell"; +export type SystemInfo = { + zamm_version: string; + os: OS | null; + shell: Shell | null; + shell_init_file: string | null; +}; +export type ChatPrompt = { messages: ChatMessage[] }; +export type TokenMetadata = { + prompt: number | null; + response: number | null; + total: number | null; +}; +export type Sound = "Switch" | "Whoosh"; +export type EntityId = { uuid: string };