Copilot fix o1 model (#30581)
Release Notes: - Fixed an issue where the `o1` model would not work when using Copilot Chat
This commit is contained in:
parent
3173f87dc3
commit
3ea86da16f
2 changed files with 135 additions and 138 deletions
|
@ -237,7 +237,6 @@ pub struct FunctionContent {
|
|||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
pub struct ResponseEvent {
|
||||
pub choices: Vec<ResponseChoice>,
|
||||
pub created: u64,
|
||||
pub id: String,
|
||||
}
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ impl LanguageModel for CopilotChatLanguageModel {
|
|||
}
|
||||
}
|
||||
|
||||
let copilot_request = match self.to_copilot_chat_request(request) {
|
||||
let copilot_request = match into_copilot_chat(&self.model, request) {
|
||||
Ok(request) => request,
|
||||
Err(err) => return futures::future::ready(Err(err)).boxed(),
|
||||
};
|
||||
|
@ -423,11 +423,10 @@ pub fn map_to_language_model_completion_events(
|
|||
.flat_map(futures::stream::iter)
|
||||
}
|
||||
|
||||
impl CopilotChatLanguageModel {
|
||||
pub fn to_copilot_chat_request(
|
||||
&self,
|
||||
fn into_copilot_chat(
|
||||
model: &copilot::copilot_chat::Model,
|
||||
request: LanguageModelRequest,
|
||||
) -> Result<CopilotChatRequest> {
|
||||
) -> Result<CopilotChatRequest> {
|
||||
let mut request_messages: Vec<LanguageModelRequestMessage> = Vec::new();
|
||||
for message in request.messages {
|
||||
if let Some(last_message) = request_messages.last_mut() {
|
||||
|
@ -471,7 +470,7 @@ impl CopilotChatLanguageModel {
|
|||
});
|
||||
}
|
||||
}
|
||||
MessageContent::Image(image) if self.model.supports_vision() => {
|
||||
MessageContent::Image(image) if model.supports_vision() => {
|
||||
content_parts.push(ChatMessageContent::Image {
|
||||
image_url: ImageUrl {
|
||||
url: image.to_base64_url(),
|
||||
|
@ -568,9 +567,9 @@ impl CopilotChatLanguageModel {
|
|||
Ok(CopilotChatRequest {
|
||||
intent: true,
|
||||
n: 1,
|
||||
stream: self.model.uses_streaming(),
|
||||
stream: model.uses_streaming(),
|
||||
temperature: 0.1,
|
||||
model: self.model.id().to_string(),
|
||||
model: model.id().to_string(),
|
||||
messages,
|
||||
tools,
|
||||
tool_choice: request.tool_choice.map(|choice| match choice {
|
||||
|
@ -579,7 +578,6 @@ impl CopilotChatLanguageModel {
|
|||
LanguageModelToolChoice::None => copilot::copilot_chat::ToolChoice::None,
|
||||
}),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct ConfigurationView {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue