| 1 | use chatsvc::copilot::CopilotAsk; |
| 2 | use chrono::Local; |
| 3 | |
| 4 | use crate::engine::SyncEngine; |
| 5 | use crate::error::Result; |
| 6 | use crate::remote::Remote; |
| 7 | |
| 8 | const COPILOT_LOCALE: &str = "en-us"; |
| 9 | const SECONDS_PER_HOUR: i32 = 3600; |
| 10 | |
| 11 | impl<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 | } |