mirror of
https://github.com/katanemo/plano.git
synced 2026-06-17 15:25:17 +02:00
refactor a bit
This commit is contained in:
parent
bd43b1793e
commit
413f36a918
2 changed files with 8 additions and 9 deletions
|
|
@ -36,22 +36,22 @@ pub fn extract_messages_for_hallucination(messages: &[Message]) -> Vec<String> {
|
|||
for message in messages.iter().rev() {
|
||||
if let Some(model) = message.model.as_ref() {
|
||||
if !model.starts_with(ARCH_MODEL_PREFIX) {
|
||||
if let Some(ContentType::Text(content)) = &message.content {
|
||||
if !content.starts_with(HALLUCINATION_TEMPLATE) {
|
||||
if let Some(content) = &message.content {
|
||||
if !content.to_string().starts_with(HALLUCINATION_TEMPLATE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if message.role == USER_ROLE {
|
||||
if let Some(ContentType::Text(content)) = &message.content {
|
||||
user_messages.push(content.clone());
|
||||
if let Some(content) = &message.content {
|
||||
user_messages.push(content.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if let Some(message) = messages.last() {
|
||||
if let Some(ContentType::Text(content)) = &message.content {
|
||||
user_messages.push(content.clone());
|
||||
if let Some(content) = &message.content {
|
||||
user_messages.push(content.to_string());
|
||||
}
|
||||
}
|
||||
user_messages.reverse(); // Reverse to maintain the original order
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ use crate::stream_context::{ResponseHandlerType, StreamCallContext, StreamContex
|
|||
use common::{
|
||||
api::open_ai::{
|
||||
self, ArchState, ChatCompletionStreamResponse, ChatCompletionTool, ChatCompletionsRequest,
|
||||
ContentType,
|
||||
},
|
||||
consts::{
|
||||
ARCH_FC_MODEL_NAME, ARCH_INTERNAL_CLUSTER_NAME, ARCH_ROUTING_HEADER,
|
||||
|
|
@ -238,12 +237,12 @@ impl HttpContext for StreamContext {
|
|||
Duration::from_secs(5),
|
||||
);
|
||||
|
||||
if let Some(ContentType::Text(content)) =
|
||||
if let Some(content) =
|
||||
self.user_prompt.as_ref().unwrap().content.as_ref()
|
||||
{
|
||||
let call_context = StreamCallContext {
|
||||
response_handler_type: ResponseHandlerType::ArchFC,
|
||||
user_message: Some(content.clone()),
|
||||
user_message: Some(content.to_string()),
|
||||
prompt_target_name: None,
|
||||
request_body: self.chat_completions_request.as_ref().unwrap().clone(),
|
||||
similarity_scores: None,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue