tuitbot_core/toolkit/profile_inference/
mod.rs1mod heuristics;
12mod llm_enrichment;
13
14#[cfg(test)]
15mod tests;
16
17use serde::{Deserialize, Serialize};
18
19use crate::x_api::types::{Tweet, User};
20
21pub use heuristics::extract_heuristics;
23pub use llm_enrichment::enrich_with_llm;
24
25#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
27#[serde(rename_all = "snake_case")]
28pub enum Confidence {
29 High,
30 Medium,
31 Low,
32}
33
34#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
36#[serde(rename_all = "snake_case")]
37pub enum Provenance {
38 Bio,
39 Tweets,
40 BioAndTweets,
41 ProfileUrl,
42 DisplayName,
43 Default,
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48pub struct InferredField<T: Serialize> {
49 pub value: T,
50 pub confidence: Confidence,
51 pub provenance: Provenance,
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56pub struct InferredProfile {
57 pub account_type: InferredField<String>,
58 pub product_name: InferredField<String>,
59 pub product_description: InferredField<String>,
60 pub product_url: InferredField<Option<String>>,
61 pub target_audience: InferredField<String>,
62 pub product_keywords: InferredField<Vec<String>>,
63 pub industry_topics: InferredField<Vec<String>>,
64 pub brand_voice: InferredField<Option<String>>,
65}
66
67pub struct ProfileInput {
69 pub user: User,
70 pub tweets: Vec<Tweet>,
71}
72
73pub fn compute_base_confidence(bio_len: usize, tweet_count: usize) -> Confidence {
80 if bio_len > 20 && tweet_count >= 10 {
81 Confidence::High
82 } else if bio_len > 0 || tweet_count >= 5 {
83 Confidence::Medium
84 } else {
85 Confidence::Low
86 }
87}