diff --git a/src/automation/compact_prompt.rs b/src/automation/compact_prompt.rs index 55a540305..7b11704ff 100644 --- a/src/automation/compact_prompt.rs +++ b/src/automation/compact_prompt.rs @@ -101,21 +101,24 @@ async fn compact_prompt_for_bots( messages_since_summary ); - let mut messages = Vec::new(); - messages.push(serde_json::json!({ - "role": "system", - "content": "Please summarize the following conversation between a user and a bot" - })); - + let mut conversation = String::new(); + conversation.push_str("Please summarize this conversation between user and bot: \n\n [[[***** \n"); + for (role, content) in history.iter().skip(start_index) { if role == "compact" { continue; } - messages.push(serde_json::json!({ - "role": role, - "content": content - })); + conversation.push_str(&format!("{}: {}\n", + if role == "user" { "User" } else { "Bot" }, + content + )); } + conversation.push_str("\n *****]]] \n Give me full points only, no explanations."); + + let messages = vec![serde_json::json!({ + "role": "user", + "content": conversation + })]; let llm_provider = state.llm_provider.clone(); trace!("Starting summarization for session {}", session.id); diff --git a/src/llm/mod.rs b/src/llm/mod.rs index 3c8610196..734d2b8cc 100644 --- a/src/llm/mod.rs +++ b/src/llm/mod.rs @@ -45,7 +45,7 @@ impl LLMProvider for OpenAIClient { let default_messages = serde_json::json!([{"role": "user", "content": prompt}]); let response = self .client - .post(&format!("{}/v1/chat/completions/", self.base_url)) + .post(&format!("{}/v1/chat/completions", self.base_url)) .header("Authorization", format!("Bearer {}", self.api_key)) .json(&serde_json::json!({ "model": "gpt-3.5-turbo",