Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually trigger specta bindings export #88

Merged
merged 2 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

109 changes: 78 additions & 31 deletions src-svelte/src/lib/bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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__<T>(cmd: string, args?: Record<string, unknown>): Promise<T>;
}
interface Window {
__TAURI_INVOKE__<T>(
cmd: string,
args?: Record<string, unknown>,
): Promise<T>;
}
}

// Function avoids 'window not defined' in SSR
const invoke = () => window.__TAURI_INVOKE__;

export function getApiKeys() {
return invoke()<ApiKeys>("get_api_keys")
return invoke()<ApiKeys>("get_api_keys");
}

export function setApiKey(filename: string | null, service: Service, apiKey: string) {
return invoke()<null>("set_api_key", { filename,service,apiKey })
export function setApiKey(
filename: string | null,
service: Service,
apiKey: string,
) {
return invoke()<null>("set_api_key", { filename, service, apiKey });
}

export function playSound(sound: Sound, volume: number, speed: number) {
return invoke()<null>("play_sound", { sound,volume,speed })
return invoke()<null>("play_sound", { sound, volume, speed });
}

export function getPreferences() {
return invoke()<Preferences>("get_preferences")
return invoke()<Preferences>("get_preferences");
}

export function setPreferences(preferences: Preferences) {
return invoke()<null>("set_preferences", { preferences })
return invoke()<null>("set_preferences", { preferences });
}

export function getSystemInfo() {
return invoke()<SystemInfo>("get_system_info")
return invoke()<SystemInfo>("get_system_info");
}

export function chat(provider: Service, llm: string, temperature: number | null, prompt: ChatMessage[]) {
return invoke()<LightweightLlmCall>("chat", { provider,llm,temperature,prompt })
export function chat(
provider: Service,
llm: string,
temperature: number | null,
prompt: ChatMessage[],
) {
return invoke()<LightweightLlmCall>("chat", {
provider,
llm,
temperature,
prompt,
});
}

export function getApiCall(id: string) {
return invoke()<LlmCall>("get_api_call", { id })
return invoke()<LlmCall>("get_api_call", { id });
}

export function getApiCalls(offset: number) {
return invoke()<LightweightLlmCall[]>("get_api_calls", { offset })
return invoke()<LightweightLlmCall[]>("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 };
124 changes: 122 additions & 2 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ reqwest-middleware = "0.1.6"
tokio = { version = "1.35.1", features = ["macros"] }
chrono = { version = "0.4.31", features = ["serde"] }
libsqlite3-sys = { version = "0.27.0", features = ["bundled"] }
clap = { version = "4.5.4", features = ["derive"] }

[features]
# this feature is used for production builds or when `devPath` points to the filesystem
Expand Down
24 changes: 24 additions & 0 deletions src-tauri/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use clap::{Parser, Subcommand};

#[derive(Subcommand)]
pub enum Commands {
/// Run the GUI. This is the default command.
Gui {},
/// Export Specta bindings for development purposes
#[cfg(debug_assertions)]
ExportBindings {},
}

/// Zen and the Automation of Metaprogramming for the Masses
///
/// This is an experimental tool meant for automating programming-related activities,
/// although none have been implemented yet. Blog posts on progress can be found at
/// https://zamm.dev/
#[derive(Parser)]
#[command(name = "zamm")]
#[command(version)]
#[command(about = "Zen and the Automation of Metaprogramming for the Masses")]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
}
Loading
Loading