mirror of
https://github.com/bvanroll/unnamed_chatgpt_project.git
synced 2025-08-29 03:52:42 +00:00
maybe build on pc?
This commit is contained in:
@@ -40,14 +40,22 @@ fn main() {
|
|||||||
println!("there are {} humans to process", l - i);
|
println!("there are {} humans to process", l - i);
|
||||||
|
|
||||||
for mut human in &mut Humans {
|
for mut human in &mut Humans {
|
||||||
let (gender, age, country, job) = getHumanFromContext(human.bio.clone(), human.firstName.clone());
|
//let (gender, age, country, job) = getHumanFromContext(
|
||||||
human.gender = gender;
|
match getHumanFromContext(human.bio.clone(), human.firstName.clone()) {
|
||||||
human.age = age;
|
Ok((gender, age, country, job)) => {
|
||||||
human.country = country;
|
human.gender = gender;
|
||||||
human.job = job;
|
human.age = age;
|
||||||
println!("just did {} at index {}", human.firstName.clone(), i);
|
human.country = country;
|
||||||
println!("There are {} humans left to process", l - i);
|
human.job = job;
|
||||||
|
println!("just did {} at index {}", human.firstName.clone(), i);
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
println!("skipping {} because of {}", human.firstName.clone(), e.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println!("There are {} humans left to process", l - (i+1));
|
||||||
i = i+1;
|
i = i+1;
|
||||||
|
if (i > 100) { break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
let serialized: String = serde_json::to_string(&Humans).unwrap();
|
let serialized: String = serde_json::to_string(&Humans).unwrap();
|
||||||
@@ -56,7 +64,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn getHumanFromContext(context: String, firstName: String) -> (String, String, String, String) {
|
fn getHumanFromContext(context: String, firstName: String) -> Result<(String, String, String, String), Box<dyn std::error::Error>> {
|
||||||
//TODO use the other ai to get answers from a given context
|
//TODO use the other ai to get answers from a given context
|
||||||
let bertconfig = QuestionAnsweringConfig::new(
|
let bertconfig = QuestionAnsweringConfig::new(
|
||||||
ModelType::Bert,
|
ModelType::Bert,
|
||||||
@@ -68,7 +76,7 @@ fn getHumanFromContext(context: String, firstName: String) -> (String, String, S
|
|||||||
false,
|
false,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
let mut model = QuestionAnsweringModel::new(bertconfig).unwrap();
|
let mut model = QuestionAnsweringModel::new(bertconfig)?;
|
||||||
let mut genderQuestion = QaInput {
|
let mut genderQuestion = QaInput {
|
||||||
question: format!("What is {}'s gender?", firstName),
|
question: format!("What is {}'s gender?", firstName),
|
||||||
context: context.clone()
|
context: context.clone()
|
||||||
@@ -88,11 +96,11 @@ fn getHumanFromContext(context: String, firstName: String) -> (String, String, S
|
|||||||
|
|
||||||
let mut answers = model.predict(&[genderQuestion, ageQuestion, countryQuestion, jobQuestion], 1, 32);
|
let mut answers = model.predict(&[genderQuestion, ageQuestion, countryQuestion, jobQuestion], 1, 32);
|
||||||
let mut looper = answers.iter();
|
let mut looper = answers.iter();
|
||||||
let mut gender = looper.next().unwrap().first().unwrap().answer.clone();
|
let mut gender = looper.next().expect("euh").first();
|
||||||
let mut age = looper.next().unwrap().first().unwrap().answer.clone();
|
let mut age = looper.next().expect("euh").first();
|
||||||
let mut country= looper.next().unwrap().first().unwrap().answer.clone();
|
let mut country= looper.next().expect("euh").first();
|
||||||
let mut job = looper.next().unwrap().first().unwrap().answer.clone();
|
let mut job = looper.next().expect("euh").first();
|
||||||
|
|
||||||
|
|
||||||
return (gender, age, country, job)
|
return Ok((gender.unwrap().answer.clone(), age.unwrap().answer.clone(), country.unwrap().answer.clone(), job.unwrap().answer.clone()))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user