Skip to content

Commit 321ce84

Browse files
committed
✨ add openai billing function
1 parent d030b0b commit 321ce84

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ https://github.com/sloganking/quick-assistant/assets/16965931/a0c7469a-2c64-46e5
3030
- ⏱️ **Timers** with alarm sounds
3131
- 🎙️ **Change voice** or speaking speed on the fly
3232
- 🔕 **Mute/unmute** the voice output
33+
- 💸 **Open OpenAI billing** page in the browser
3334

3435
## Setup
3536

src/main.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ use tempfile::Builder;
2727
mod record;
2828
use crate::default_device_sink::{
2929
default_device_name as get_default_output_device,
30-
list_output_devices as list_audio_output_devices,
31-
set_output_device,
32-
DefaultDeviceSink,
30+
list_output_devices as list_audio_output_devices, set_output_device, DefaultDeviceSink,
3331
};
3432
use async_openai::{
3533
types::{
@@ -286,6 +284,10 @@ fn call_fn(
286284
Err(e) => Some(String::from("Showing logs folder failed with: ") + &e.to_string()), // If unwrap fails, return Some with the error message
287285
}
288286
}
287+
"open_openai_billing" => match open::that("https://platform.openai.com/usage?tab=month") {
288+
Ok(_) => None,
289+
Err(e) => Some(format!("Failed to open OpenAI billing page: {}", e)),
290+
},
289291
"sysinfo" => Some(get_system_info()),
290292

291293
"get_system_processes" => Some(get_system_processes()),
@@ -1352,6 +1354,16 @@ async fn main() -> Result<(), Box<dyn Error>> {
13521354
}))
13531355
.build().unwrap(),
13541356

1357+
ChatCompletionFunctionsArgs::default()
1358+
.name("open_openai_billing")
1359+
.description("Opens the OpenAI usage dashboard for this month in the default web browser.")
1360+
.parameters(json!({
1361+
"type": "object",
1362+
"properties": {},
1363+
"required": [],
1364+
}))
1365+
.build().unwrap(),
1366+
13551367
ChatCompletionFunctionsArgs::default()
13561368
.name("sysinfo")
13571369
.description("Returns this system's information.")
@@ -1510,7 +1522,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
15101522
"required": [],
15111523
}))
15121524
.build().unwrap(),
1513-
1525+
15141526
ChatCompletionFunctionsArgs::default()
15151527
.name("get_location")
15161528
.description("Returns an approximate location based on the machine's IP address.")

0 commit comments

Comments
 (0)