Skip to content

Commit

Permalink
improve formatting of digest
Browse files Browse the repository at this point in the history
  • Loading branch information
FredrikAugust committed Apr 25, 2024
1 parent 93ac0e9 commit 08f5430
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ env_logger = "0.11.3"
async-trait = "0.1.80"
reqwest = { version = "0.12.4", features = ["json"] }
serde_json = "1.0.116"
serde = "1.0.198"
serde = "1.0.198"
url = "2.5.0"
9 changes: 6 additions & 3 deletions src/chat/api.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
use chatgpt::prelude::ChatGPT;
use anyhow::Result;
use log::info;
use url::Url;

pub async fn generate_brief_summary_of_pull_requests(client: ChatGPT, pull_requests: &Vec<octocrab::models::pulls::PullRequest>) -> Result<String> {
let mut prompt = "Please add emojis to all subsequent bullet points based on what type of change it is. \
You will be provided with a set of pull requests that have been completed the working day. \
I want you to aggregate this into a bullet list highlighting the main changes. \
Avoid using technical language where possible. \
This will be posted to Slack so use the appropriate formatting. \
Group into sensible categories such as bug fixes, new features, etc. \
Group the changes by the PR title which introduced them. \
Example: *<PR url|PR title>* followed by bullet points explaining the changes introduced. \
You do not need to include any other text such as 'Here are the changes'. \
Each bullet point should be at most one sentence to keep it concise. \
Each bullet point should be a human readable sentence. \
Do not include links to the pull requests, just a brief summary. \
The PR header should not be a bullet point. \
Do not include these instructions in the output. \
Here is the content which you should summarise:".to_string();

for pull_request in pull_requests {
let title = pull_request.clone().title.clone().expect("Title should be set on the pull request");
let body = pull_request.clone().body.unwrap_or("No body provided".to_string());
let url = pull_request.clone().html_url.unwrap_or(Url::parse("https://github.com").unwrap());

info!("Adding pull request to prompt: {}", &title);

prompt += format!("\n-----\nPull request title: {title}\nPull request body: {body}").as_str();
prompt += format!("\n-----\nPull request title: {title}\nPull request URL: {url}\nPull request body: {body}").as_str();
}

let response = client.send_message(prompt).await?;
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn configure_chatgpt() -> Result<ChatGPT> {
Ok(ChatGPT::new_with_config(
chatgpt_token,
// We want to use GPT-4 with an increased timeout as we're passing quite a lot of data
ModelConfigurationBuilder::default().engine(ChatGPTEngine::Gpt4).timeout(time::Duration::from_secs(30)).build()?,
ModelConfigurationBuilder::default().engine(ChatGPTEngine::Gpt4).timeout(time::Duration::from_secs(60)).build()?,
)?)
}

Expand Down

0 comments on commit 08f5430

Please sign in to comment.