Skip to main content

opal/ai/
types.rs

1use std::path::PathBuf;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum AiProviderKind {
5    Ollama,
6    Claude,
7    Codex,
8}
9
10#[derive(Debug, Clone)]
11pub struct AiRequest {
12    pub provider: AiProviderKind,
13    pub prompt: String,
14    pub system: Option<String>,
15    pub host: Option<String>,
16    pub model: Option<String>,
17    pub command: Option<String>,
18    pub args: Vec<String>,
19    pub workdir: Option<PathBuf>,
20    pub save_path: Option<PathBuf>,
21}
22
23#[derive(Debug, Clone)]
24pub enum AiChunk {
25    Text(String),
26}
27
28#[derive(Debug, Clone)]
29pub struct AiResult {
30    pub provider: AiProviderKind,
31    pub text: String,
32    pub saved_path: Option<PathBuf>,
33}
34
35#[derive(Debug, Clone)]
36pub struct AiError {
37    pub message: String,
38}
39
40impl std::fmt::Display for AiError {
41    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42        f.write_str(&self.message)
43    }
44}
45
46impl std::error::Error for AiError {}