Skip to content

Rust wrapper over chat APIs from HuggingFace and various reverse engineering python code/libraries

Notifications You must be signed in to change notification settings

Miezhiko/chat.rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chat.rs

mawa

Requirements:

Silly usage example

if let Ok(gpt4free_result) =
  chat::chat( payload, "bot name" ) {
    return Some(gpt4free_result);
  }
};

Current state

static GENERATORS: Lazy<Vec<Arc<dyn Generator + Send + Sync>>> =
  Lazy::new(|| {
    vec![ ... ]
  });

pub async fn generate(msg: &str, bot_name: &str, fancy: bool) -> anyhow::Result<String> {
  for gen in &*GENERATORS {
    if let Ok(result) = gen.call(msg, fancy, bot_name).await {
      return Ok(result);
    }
  }
  Err( anyhow::anyhow!("All generators failed") )
}

pub async fn generate_all<'a>(msg: &str, bot_name: &str, fancy: bool)
                                -> Vec<(&'a str, anyhow::Result<String>)> {
  let genz = (&*GENERATORS).into_iter().map(
    |gen| async move { ( gen.name()
                       , gen.call(msg, fancy, bot_name).await )
                     }
  );
  future::join_all(genz).await
}

About

Rust wrapper over chat APIs from HuggingFace and various reverse engineering python code/libraries

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published