Commons & STP
This commit is contained in:
parent
47084819e0
commit
958cf8829a
9 changed files with 1188 additions and 0 deletions
189
types/src/enums.rs
Normal file
189
types/src/enums.rs
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
use std::fmt;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ToDoStatus {
|
||||
Pending,
|
||||
InProgress,
|
||||
Completed,
|
||||
Blocked,
|
||||
}
|
||||
|
||||
impl Default for ToDoStatus {
|
||||
fn default() -> Self {
|
||||
ToDoStatus::Pending
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ToDoStatus {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
ToDoStatus::Pending => write!(f, "pending"),
|
||||
ToDoStatus::InProgress => write!(f, "in_progress"),
|
||||
ToDoStatus::Completed => write!(f, "completed"),
|
||||
ToDoStatus::Blocked => write!(f, "blocked"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::str::FromStr for ToDoStatus {
|
||||
type Err = String;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"pending" => Ok(ToDoStatus::Pending),
|
||||
"in_progress" => Ok(ToDoStatus::InProgress),
|
||||
"completed" => Ok(ToDoStatus::Completed),
|
||||
"blocked" => Ok(ToDoStatus::Blocked),
|
||||
_ => Err(format!("unknown status: {}", s)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum TaskStatus {
|
||||
Pending,
|
||||
Running,
|
||||
Completed,
|
||||
Failed,
|
||||
}
|
||||
|
||||
impl Default for TaskStatus {
|
||||
fn default() -> Self {
|
||||
TaskStatus::Pending
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for TaskStatus {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
TaskStatus::Pending => write!(f, "pending"),
|
||||
TaskStatus::Running => write!(f, "running"),
|
||||
TaskStatus::Completed => write!(f, "completed"),
|
||||
TaskStatus::Failed => write!(f, "failed"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::str::FromStr for TaskStatus {
|
||||
type Err = String;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"pending" => Ok(TaskStatus::Pending),
|
||||
"running" => Ok(TaskStatus::Running),
|
||||
"completed" => Ok(TaskStatus::Completed),
|
||||
"failed" => Ok(TaskStatus::Failed),
|
||||
_ => Err(format!("unknown status: {}", s)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ModelType {
|
||||
Llm,
|
||||
CodeGen,
|
||||
Vision,
|
||||
Audio,
|
||||
Text,
|
||||
Embedding,
|
||||
}
|
||||
|
||||
impl fmt::Display for ModelType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
ModelType::Llm => write!(f, "llm"),
|
||||
ModelType::CodeGen => write!(f, "codegen"),
|
||||
ModelType::Vision => write!(f, "vision"),
|
||||
ModelType::Audio => write!(f, "audio"),
|
||||
ModelType::Text => write!(f, "text"),
|
||||
ModelType::Embedding => write!(f, "embedding"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::str::FromStr for ModelType {
|
||||
type Err = String;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"llm" => Ok(ModelType::Llm),
|
||||
"codegen" => Ok(ModelType::CodeGen),
|
||||
"vision" => Ok(ModelType::Vision),
|
||||
"audio" => Ok(ModelType::Audio),
|
||||
"text" => Ok(ModelType::Text),
|
||||
"embedding" => Ok(ModelType::Embedding),
|
||||
_ => Err(format!("unknown model type: {}", s)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum DocType {
|
||||
ApiDoc,
|
||||
Readme,
|
||||
CodeComment,
|
||||
Architecture,
|
||||
Other(String),
|
||||
}
|
||||
|
||||
impl fmt::Display for DocType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
DocType::ApiDoc => write!(f, "api_doc"),
|
||||
DocType::Readme => write!(f, "readme"),
|
||||
DocType::CodeComment => write!(f, "code_comment"),
|
||||
DocType::Architecture => write!(f, "architecture"),
|
||||
DocType::Other(s) => write!(f, "other:{}", s),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum PromptType {
|
||||
Authority,
|
||||
Confirm,
|
||||
Select,
|
||||
}
|
||||
|
||||
impl fmt::Display for PromptType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
PromptType::Authority => write!(f, "authority"),
|
||||
PromptType::Confirm => write!(f, "confirm"),
|
||||
PromptType::Select => write!(f, "select"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum PromptOption {
|
||||
Accept,
|
||||
Deny,
|
||||
AcceptAlways,
|
||||
Forbid,
|
||||
Yes,
|
||||
No,
|
||||
OptionA,
|
||||
OptionB,
|
||||
OptionC,
|
||||
}
|
||||
|
||||
impl fmt::Display for PromptOption {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
PromptOption::Accept => write!(f, "accept"),
|
||||
PromptOption::Deny => write!(f, "deny"),
|
||||
PromptOption::AcceptAlways => write!(f, "accept_always"),
|
||||
PromptOption::Forbid => write!(f, "forbid"),
|
||||
PromptOption::Yes => write!(f, "yes"),
|
||||
PromptOption::No => write!(f, "no"),
|
||||
PromptOption::OptionA => write!(f, "option_a"),
|
||||
PromptOption::OptionB => write!(f, "option_b"),
|
||||
PromptOption::OptionC => write!(f, "option_c"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum TaskResultType {
|
||||
Success,
|
||||
Error,
|
||||
Split,
|
||||
}
|
||||
Loading…
Reference in a new issue