mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-01 07:58:23 +00:00
include outputs in table, cleanup bugs
This commit is contained in:
1 parent
5d111f0a68
commit
a08bc3fa64
2 files changed
+45
-2
No files matched your search
+22
-1
@@ -64,10 +64,31 @@ pub async fn process_single_item(target: &NewsStoryProductionItem, job_state: &A
|
||||
Ok(rendition_data) => rendition_data,
|
||||
};
|
||||
|
||||
let categorization = rendition_data.response.trim();
|
||||
|
||||
// NB: GPT often completes the prompt we used itself, so we grab the last line (presumably output)
|
||||
let categorization = categorization.split("\n")
|
||||
.map(|line| line.trim().to_string())
|
||||
.filter(|line| line.len() > 5)
|
||||
.last()
|
||||
.unwrap_or("".to_string());
|
||||
|
||||
if categorization.len() < 5 {
|
||||
update_news_story_llm_categorization_status(Args {
|
||||
news_story_token: &target.news_story_token,
|
||||
is_successful: false,
|
||||
maybe_categorization: None,
|
||||
llm_categorization_attempts,
|
||||
sqlite_pool: &job_state.sqlite_pool,
|
||||
}).await?; // NB: If these queries fail, we could get stuck in retry hell.
|
||||
|
||||
return Err(anyhow!("too short"));
|
||||
}
|
||||
|
||||
update_news_story_llm_categorization_status(Args {
|
||||
news_story_token: &target.news_story_token,
|
||||
is_successful: true,
|
||||
maybe_categorization: None,
|
||||
maybe_categorization: Some(categorization.to_string()),
|
||||
llm_categorization_attempts,
|
||||
sqlite_pool: &job_state.sqlite_pool,
|
||||
}).await?; // NB: If these queries fail, we could get stuck in retry hell.
|
||||
|
||||
+23
-1
@@ -68,10 +68,32 @@ pub async fn process_single_item(target: &NewsStoryProductionItem, job_state: &A
|
||||
Ok(rendition_data) => rendition_data,
|
||||
};
|
||||
|
||||
let title_summary = rendition_data.response.trim();
|
||||
|
||||
// NB: GPT often completes the prompt we used itself, so we grab the last line (presumably output)
|
||||
let title_summary = title_summary.split("\n")
|
||||
.map(|line| line.trim().to_string())
|
||||
.filter(|line| line.len() > 5)
|
||||
.last()
|
||||
.unwrap_or("".to_string());
|
||||
|
||||
// NB: GPT often includes quotes in the output.
|
||||
let title_summary = title_summary.replace("\"", "");
|
||||
|
||||
if title_summary.len() < 5 {
|
||||
update_news_story_llm_title_summary_status(Args {
|
||||
news_story_token: &target.news_story_token,
|
||||
is_successful: false,
|
||||
maybe_title_summary: None,
|
||||
llm_title_summary_attempts,
|
||||
sqlite_pool: &job_state.sqlite_pool,
|
||||
}).await?; // NB: If these queries fail, we could get stuck in retry hell.
|
||||
}
|
||||
|
||||
update_news_story_llm_title_summary_status(Args {
|
||||
news_story_token: &target.news_story_token,
|
||||
is_successful: true,
|
||||
maybe_title_summary: None,
|
||||
maybe_title_summary: Some(title_summary.to_string()),
|
||||
llm_title_summary_attempts,
|
||||
sqlite_pool: &job_state.sqlite_pool,
|
||||
}).await?; // NB: If these queries fail, we could get stuck in retry hell.
|
||||
|
||||
Reference in new issue
Block a user