Working on thread titles
This commit is contained in:
@@ -290,7 +290,7 @@ pub async fn generate_response(ctx: &Context, msg: &Message, oai: &OAI, pool: &P
|
||||
// Stop the typing indicator and send the response
|
||||
typing.stop();
|
||||
match msg.channel_id.create_public_thread(&ctx.http, msg.id, |thread| {
|
||||
thread.name("Siren Response").kind(ChannelType::PublicThread)
|
||||
thread.name(truncate(&parsed_content, 99)).kind(ChannelType::PublicThread)
|
||||
}).await {
|
||||
Ok(c) => {
|
||||
if let Err(why) = c.say(&ctx.http, response).await {
|
||||
@@ -304,3 +304,25 @@ pub async fn generate_response(ctx: &Context, msg: &Message, oai: &OAI, pool: &P
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
fn truncate(s: &str, max_chars: usize) -> &str {
|
||||
match s.char_indices().nth(max_chars) {
|
||||
None => s,
|
||||
Some((idx, _)) => &s[..idx],
|
||||
}
|
||||
}
|
||||
|
||||
// fn summarization_model() -> Result<SummarizationModel, RustBertError> {
|
||||
// let config_resource = RemoteResource::from_pretrained(T5ConfigResources::T5_SMALL);
|
||||
// let vocab_resource = RemoteResource::from_pretrained(T5VocabResources::T5_SMALL);
|
||||
// let weights_resource = RemoteResource::from_pretrained(T5ModelResources::T5_SMALL);
|
||||
|
||||
// let summarization_config = SummarizationConfig::new(
|
||||
// ModelType::T5,
|
||||
// ModelResource::Torch(Box::new(weights_resource)),
|
||||
// config_resource,
|
||||
// vocab_resource,
|
||||
// None
|
||||
// );
|
||||
// return SummarizationModel::new(summarization_config);
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user