BlueGit

ict rusty-teams

Files

rusty-teams / crates / core / src / copilot.rs

copilot.rs

feat(chat): Copilot pane for chats
metis Daniel Däschle · pushed by metis · 3 weeks ago
720aead3 History
copilot.rs 747 B Download Raw
1use chatsvc::copilot::CopilotAsk;
2use chrono::Local;
3
4use crate::engine::SyncEngine;
5use crate::error::Result;
6use crate::remote::Remote;
7
8const COPILOT_LOCALE: &str = "en-us";
9const SECONDS_PER_HOUR: i32 = 3600;
10
11impl<R: Remote> SyncEngine<R> {
12 pub async fn ask_copilot(&self, chat_id: &str, prompt: &str) -> Result<String> {
13 let ask = CopilotAsk {
14 user_id: self.my_user_id().await?,
15 tenant_id: self.my_tenant_id(chat_id).await?,
16 chat_id: chat_id.to_owned(),
17 prompt: prompt.to_owned(),
18 locale: COPILOT_LOCALE.to_owned(),
19 utc_offset_hours: Local::now().offset().local_minus_utc() / SECONDS_PER_HOUR,
20 };
21 self.remote.ask_copilot(&ask).await
22 }
23}