From 89c9c1040e9f467e607fed32e4a0dbaa51ef285c Mon Sep 17 00:00:00 2001 From: gngpp Date: Wed, 22 Nov 2023 12:19:20 +0800 Subject: [PATCH] fix(toapi): Fix duplicate reply content --- openai/src/chatgpt/model/resp.rs | 4 ++++ openai/src/serve/proxy/toapi/mod.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/openai/src/chatgpt/model/resp.rs b/openai/src/chatgpt/model/resp.rs index 4c2ca0241..b310ffbd1 100644 --- a/openai/src/chatgpt/model/resp.rs +++ b/openai/src/chatgpt/model/resp.rs @@ -211,6 +211,10 @@ impl ConvoResponse { .collect() } + pub fn raw_messages(&self) -> &[String] { + self.message.content.parts.as_slice() + } + pub fn message_id(&self) -> &str { &self.message.id } diff --git a/openai/src/serve/proxy/toapi/mod.rs b/openai/src/serve/proxy/toapi/mod.rs index 7192e0d22..80ed93d3e 100644 --- a/openai/src/serve/proxy/toapi/mod.rs +++ b/openai/src/serve/proxy/toapi/mod.rs @@ -311,7 +311,7 @@ async fn event_convert_handler( set_role: &mut bool, convo: ConvoResponse, ) -> anyhow::Result { - let messages = convo.messages(); + let messages = convo.raw_messages(); let message = messages .first() .ok_or(anyhow::anyhow!("message is empty"))?;