Update casing of "OpenAI" in identifiers to match Rust conventions (#6940)
This PR updates the casing of "OpenAI" when used in Rust identifiers to match the [Rust naming guidelines](https://rust-lang.github.io/api-guidelines/naming.html): > In `UpperCamelCase`, acronyms and contractions of compound words count as one word: use `Uuid` rather than `UUID`, `Usize` rather than `USize` or `Stdin` rather than `StdIn`. Release Notes: - N/A
This commit is contained in:
@@ -7,7 +7,7 @@ mod streaming_diff;
|
||||
use ai::providers::open_ai::Role;
|
||||
use anyhow::Result;
|
||||
pub use assistant_panel::AssistantPanel;
|
||||
use assistant_settings::OpenAIModel;
|
||||
use assistant_settings::OpenAiModel;
|
||||
use chrono::{DateTime, Local};
|
||||
use collections::HashMap;
|
||||
use fs::Fs;
|
||||
@@ -68,7 +68,7 @@ struct SavedConversation {
|
||||
messages: Vec<SavedMessage>,
|
||||
message_metadata: HashMap<MessageId, MessageMetadata>,
|
||||
summary: String,
|
||||
model: OpenAIModel,
|
||||
model: OpenAiModel,
|
||||
}
|
||||
|
||||
impl SavedConversation {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
assistant_settings::{AssistantDockPosition, AssistantSettings, OpenAIModel},
|
||||
assistant_settings::{AssistantDockPosition, AssistantSettings, OpenAiModel},
|
||||
codegen::{self, Codegen, CodegenKind},
|
||||
prompts::generate_content_prompt,
|
||||
Assist, CycleMessageRole, InlineAssist, MessageId, MessageMetadata, MessageStatus,
|
||||
@@ -10,7 +10,7 @@ use ai::prompts::repository_context::PromptCodeSnippet;
|
||||
use ai::{
|
||||
auth::ProviderCredential,
|
||||
completion::{CompletionProvider, CompletionRequest},
|
||||
providers::open_ai::{OpenAICompletionProvider, OpenAIRequest, RequestMessage},
|
||||
providers::open_ai::{OpenAiCompletionProvider, OpenAiRequest, RequestMessage},
|
||||
};
|
||||
use anyhow::{anyhow, Result};
|
||||
use chrono::{DateTime, Local};
|
||||
@@ -123,7 +123,7 @@ impl AssistantPanel {
|
||||
.unwrap_or_default();
|
||||
// Defaulting currently to GPT4, allow for this to be set via config.
|
||||
let completion_provider =
|
||||
OpenAICompletionProvider::new("gpt-4".into(), cx.background_executor().clone())
|
||||
OpenAiCompletionProvider::new("gpt-4".into(), cx.background_executor().clone())
|
||||
.await;
|
||||
|
||||
// TODO: deserialize state.
|
||||
@@ -717,7 +717,7 @@ impl AssistantPanel {
|
||||
content: prompt,
|
||||
});
|
||||
|
||||
let request = Box::new(OpenAIRequest {
|
||||
let request = Box::new(OpenAiRequest {
|
||||
model: model.full_name().into(),
|
||||
messages,
|
||||
stream: true,
|
||||
@@ -1393,7 +1393,7 @@ struct Conversation {
|
||||
pending_summary: Task<Option<()>>,
|
||||
completion_count: usize,
|
||||
pending_completions: Vec<PendingCompletion>,
|
||||
model: OpenAIModel,
|
||||
model: OpenAiModel,
|
||||
token_count: Option<usize>,
|
||||
max_token_count: usize,
|
||||
pending_token_count: Task<Option<()>>,
|
||||
@@ -1501,7 +1501,7 @@ impl Conversation {
|
||||
};
|
||||
let model = saved_conversation.model;
|
||||
let completion_provider: Arc<dyn CompletionProvider> = Arc::new(
|
||||
OpenAICompletionProvider::new(
|
||||
OpenAiCompletionProvider::new(
|
||||
model.full_name().into(),
|
||||
cx.background_executor().clone(),
|
||||
)
|
||||
@@ -1626,7 +1626,7 @@ impl Conversation {
|
||||
Some(self.max_token_count as isize - self.token_count? as isize)
|
||||
}
|
||||
|
||||
fn set_model(&mut self, model: OpenAIModel, cx: &mut ModelContext<Self>) {
|
||||
fn set_model(&mut self, model: OpenAiModel, cx: &mut ModelContext<Self>) {
|
||||
self.model = model;
|
||||
self.count_remaining_tokens(cx);
|
||||
cx.notify();
|
||||
@@ -1679,7 +1679,7 @@ impl Conversation {
|
||||
return Default::default();
|
||||
}
|
||||
|
||||
let request: Box<dyn CompletionRequest> = Box::new(OpenAIRequest {
|
||||
let request: Box<dyn CompletionRequest> = Box::new(OpenAiRequest {
|
||||
model: self.model.full_name().to_string(),
|
||||
messages: self
|
||||
.messages(cx)
|
||||
@@ -1962,7 +1962,7 @@ impl Conversation {
|
||||
content: "Summarize the conversation into a short title without punctuation"
|
||||
.into(),
|
||||
}));
|
||||
let request: Box<dyn CompletionRequest> = Box::new(OpenAIRequest {
|
||||
let request: Box<dyn CompletionRequest> = Box::new(OpenAiRequest {
|
||||
model: self.model.full_name().to_string(),
|
||||
messages: messages.collect(),
|
||||
stream: true,
|
||||
|
||||
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
||||
use settings::Settings;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
|
||||
pub enum OpenAIModel {
|
||||
pub enum OpenAiModel {
|
||||
#[serde(rename = "gpt-3.5-turbo-0613")]
|
||||
ThreePointFiveTurbo,
|
||||
#[serde(rename = "gpt-4-0613")]
|
||||
@@ -14,28 +14,28 @@ pub enum OpenAIModel {
|
||||
FourTurbo,
|
||||
}
|
||||
|
||||
impl OpenAIModel {
|
||||
impl OpenAiModel {
|
||||
pub fn full_name(&self) -> &'static str {
|
||||
match self {
|
||||
OpenAIModel::ThreePointFiveTurbo => "gpt-3.5-turbo-0613",
|
||||
OpenAIModel::Four => "gpt-4-0613",
|
||||
OpenAIModel::FourTurbo => "gpt-4-1106-preview",
|
||||
OpenAiModel::ThreePointFiveTurbo => "gpt-3.5-turbo-0613",
|
||||
OpenAiModel::Four => "gpt-4-0613",
|
||||
OpenAiModel::FourTurbo => "gpt-4-1106-preview",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn short_name(&self) -> &'static str {
|
||||
match self {
|
||||
OpenAIModel::ThreePointFiveTurbo => "gpt-3.5-turbo",
|
||||
OpenAIModel::Four => "gpt-4",
|
||||
OpenAIModel::FourTurbo => "gpt-4-turbo",
|
||||
OpenAiModel::ThreePointFiveTurbo => "gpt-3.5-turbo",
|
||||
OpenAiModel::Four => "gpt-4",
|
||||
OpenAiModel::FourTurbo => "gpt-4-turbo",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cycle(&self) -> Self {
|
||||
match self {
|
||||
OpenAIModel::ThreePointFiveTurbo => OpenAIModel::Four,
|
||||
OpenAIModel::Four => OpenAIModel::FourTurbo,
|
||||
OpenAIModel::FourTurbo => OpenAIModel::ThreePointFiveTurbo,
|
||||
OpenAiModel::ThreePointFiveTurbo => OpenAiModel::Four,
|
||||
OpenAiModel::Four => OpenAiModel::FourTurbo,
|
||||
OpenAiModel::FourTurbo => OpenAiModel::ThreePointFiveTurbo,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ pub struct AssistantSettings {
|
||||
pub dock: AssistantDockPosition,
|
||||
pub default_width: Pixels,
|
||||
pub default_height: Pixels,
|
||||
pub default_open_ai_model: OpenAIModel,
|
||||
pub default_open_ai_model: OpenAiModel,
|
||||
}
|
||||
|
||||
/// Assistant panel settings
|
||||
@@ -79,7 +79,7 @@ pub struct AssistantSettingsContent {
|
||||
/// The default OpenAI model to use when starting new conversations.
|
||||
///
|
||||
/// Default: gpt-4-1106-preview
|
||||
pub default_open_ai_model: Option<OpenAIModel>,
|
||||
pub default_open_ai_model: Option<OpenAiModel>,
|
||||
}
|
||||
|
||||
impl Settings for AssistantSettings {
|
||||
|
||||
@@ -4,7 +4,7 @@ use ai::prompts::file_context::FileContext;
|
||||
use ai::prompts::generate::GenerateInlineContent;
|
||||
use ai::prompts::preamble::EngineerPreamble;
|
||||
use ai::prompts::repository_context::{PromptCodeSnippet, RepositoryContext};
|
||||
use ai::providers::open_ai::OpenAILanguageModel;
|
||||
use ai::providers::open_ai::OpenAiLanguageModel;
|
||||
use language::{BufferSnapshot, OffsetRangeExt, ToOffset};
|
||||
use std::cmp::{self, Reverse};
|
||||
use std::ops::Range;
|
||||
@@ -131,7 +131,7 @@ pub fn generate_content_prompt(
|
||||
project_name: Option<String>,
|
||||
) -> anyhow::Result<String> {
|
||||
// Using new Prompt Templates
|
||||
let openai_model: Arc<dyn LanguageModel> = Arc::new(OpenAILanguageModel::load(model));
|
||||
let openai_model: Arc<dyn LanguageModel> = Arc::new(OpenAiLanguageModel::load(model));
|
||||
let lang_name = if let Some(language_name) = language_name {
|
||||
Some(language_name.to_string())
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user