Skip to content

Commit

Permalink
fix: correct typos
Browse files Browse the repository at this point in the history
  • Loading branch information
upupnoah committed Aug 2, 2024
1 parent 4b6bbf1 commit ef138b8
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion examples/c01-conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::default();

let mut chat_req = ChatRequest::default().with_system("Answer in one sentence");
// Similar to put a first System Chat Message(s) (will be cummulative with sytem chat messages)
// Similar to putting a first System Chat Message(s) (will be cumulative with system chat messages)

for &question in questions {
chat_req = chat_req.append_message(ChatMessage::user(question));
Expand Down
4 changes: 2 additions & 2 deletions src/adapter/adapter_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pub enum AdapterKind {
Cohere,
Gemini,
Groq,
// Note: Variants will probalby be suffixed
// AnthropicBerock,
// Note: Variants will probably be suffixed
// AnthropicBedrock,
}

/// Serialization impls
Expand Down
2 changes: 1 addition & 1 deletion src/adapter/adapter_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub enum ServiceType {

// region: --- WebRequestData

// NOTE: This cannot really move to `webc` bcause it has to be public with the adapter and `webc` is private for now.
// NOTE: This cannot really move to `webc` because it has to be public with the adapter and `webc` is private for now.

pub struct WebRequestData {
pub url: String,
Expand Down
6 changes: 3 additions & 3 deletions src/adapter/adapters/gemini/adapter_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Adapter for GeminiAdapter {

// region: --- Support

/// Suppot GeminiAdapter functions
/// Support GeminiAdapter functions
impl GeminiAdapter {
pub(super) fn body_to_gemini_chat_response(model_info: &ModelInfo, mut body: Value) -> Result<GeminiChatResponse> {
// if the body has a `error` property, then, it is assumed to be an error
Expand Down Expand Up @@ -174,7 +174,7 @@ impl GeminiAdapter {
let MessageContent::Text(content) = msg.content;

match msg.role {
// for now, system go as "user" (later, we might have adapter_config.system_to_user_tmpl)
// for now, system go as "user" (later, we might have adapter_config.system_to_user_impl)
ChatRole::System => systems.push(content),
ChatRole::User => contents.push(json! ({"role": "user", "parts": [{"text": content}]})),
ChatRole::Assistant => contents.push(json! ({"role": "model", "parts": [{"text": content}]})),
Expand All @@ -197,7 +197,7 @@ impl GeminiAdapter {
}
}

// stuct Gemini
// struct Gemini

pub(super) struct GeminiChatResponse {
pub content: Option<String>,
Expand Down
4 changes: 2 additions & 2 deletions src/adapter/adapters/openai/adapter_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl OpenAIAdapter {
/// - All messages get added with the corresponding roles (does not support tools for now)
///
/// NOTE: here, the last `true` is for the ollama variant
/// It seems the Ollama compaitiblity layer does not work well with multiple System message.
/// It seems the Ollama compatibility layer does not work well with multiple System message.
/// So, when `true`, it will concatenate the system message as a single on at the beginning
fn into_openai_request_parts(model_info: ModelInfo, chat_req: ChatRequest) -> Result<OpenAIRequestParts> {
let mut system_messages: Vec<String> = Vec::new();
Expand All @@ -175,7 +175,7 @@ impl OpenAIAdapter {
match msg.role {
// for now, system and tool goes to system
ChatRole::System => {
// see note in the funtion comment
// see note in the function comment
if ollama_variant {
system_messages.push(content);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/adapter/adapters/openai/streamer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct OpenAIStreamer {
}

impl OpenAIStreamer {
// TODO: Problen need the ChatOptions `.capture_content` `.capture_usage`
// TODO: Problem need the ChatOptions `.capture_content` `.capture_usage`
pub fn new(inner: EventSource, model_info: ModelInfo, options_set: ChatOptionsSet<'_, '_>) -> Self {
Self {
inner,
Expand Down Expand Up @@ -119,7 +119,7 @@ impl futures::Stream for OpenAIStreamer {
&& self.options.capture_usage
{
let usage = message_data.x_take("usage").map(OpenAIAdapter::into_usage).unwrap_or_default(); // premissive for now
self.captured_data.usage = Some(usage); // premissive for now
self.captured_data.usage = Some(usage); // permissive for now
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/adapter/inter_stream.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Internal Stream Event Types which serve as an intermediary between the Provider event and the genai stream event.
//!
//! This allows to eventually have flexibility if we want to capture event accross providers that does not need to
//! This allows to eventually have flexibility if we want to capture event across providers that does not need to
//! be reflected in the public ChatStream event.
//!
//! NOTE: This might be removed at some point as it might not be needed, and going directly to the genai stream.
Expand Down
4 changes: 2 additions & 2 deletions src/chat/chat_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ pub struct ChatOptions {
/// Will be set for this request if Adapter/providers supports it.
pub temperature: Option<f64>,

/// Will be set of this request if Adaptper/provider supports it.
/// Will be set of this request if Adapter/provider supports it.
pub max_tokens: Option<u32>,

/// Will be set of this request if Adaptper/provider supports it.
/// Will be set of this request if Adapter/provider supports it.
pub top_p: Option<f64>,

/// (for steam only) Capture the meta usage when in stream mode
Expand Down
6 changes: 3 additions & 3 deletions src/chat/chat_res.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! This module contains all the types related to a Chat Reponse (except ChatStream which has it file).
//! This module contains all the types related to a Chat Response (except ChatStream which has it file).

use crate::chat::{ChatStream, MessageContent};

Expand All @@ -13,13 +13,13 @@ pub struct ChatResponse {
// Getters
impl ChatResponse {
/// Returns the eventual content as `&str` if it is of type `MessageContent::Text`
/// Ohterwise, return None
/// Otherwise, return None
pub fn content_text_as_str(&self) -> Option<&str> {
self.content.as_ref().and_then(MessageContent::text_as_str)
}

/// Consume the ChatResponse and returns the eventual String content of the `MessageContent::Text`
/// Ohterwise, return None
/// Otherwise, return None
pub fn content_text_into_string(self) -> Option<String> {
self.content.and_then(MessageContent::text_into_string)
}
Expand Down
6 changes: 3 additions & 3 deletions src/client/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::sync::Arc;

#[derive(Debug, Default)]
pub struct ClientBuilder {
apapter_config_by_kind: Option<HashMap<AdapterKind, AdapterConfig>>,
adapter_config_by_kind: Option<HashMap<AdapterKind, AdapterConfig>>,

web_client: Option<WebClient>,

Expand All @@ -29,7 +29,7 @@ impl ClientBuilder {
}

pub fn insert_adapter_config(mut self, kind: AdapterKind, adapter_config: AdapterConfig) -> Self {
self.apapter_config_by_kind
self.adapter_config_by_kind
.get_or_insert_with(HashMap::new)
.insert(kind, adapter_config);
self
Expand Down Expand Up @@ -64,7 +64,7 @@ impl ClientBuilder {
let inner = super::ClientInner {
web_client: self.web_client.unwrap_or_default(),
config: self.config.unwrap_or_default(),
apapter_config_by_kind: self.apapter_config_by_kind,
adapter_config_by_kind: self.adapter_config_by_kind,
};
Client { inner: Arc::new(inner) }
}
Expand Down
8 changes: 4 additions & 4 deletions src/client/client_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Client {
pub(super) inner: Arc<ClientInner>,
}

// region: --- Client Construstors
// region: --- Client C'o'n's't'r'u'c't'o'r's

impl Default for Client {
fn default() -> Self {
Expand All @@ -24,7 +24,7 @@ impl Client {
}
}

// endregion: --- Client Construstors
// endregion: --- Client Constructors

// region: --- Client Getters

Expand All @@ -39,7 +39,7 @@ impl Client {

/// Returns the eventual custom AdapterConfig that has been set for this client (in the builder phase)
pub(crate) fn custom_adapter_config(&self, adapter_kind: AdapterKind) -> Option<&AdapterConfig> {
self.inner.apapter_config_by_kind.as_ref()?.get(&adapter_kind)
self.inner.adapter_config_by_kind.as_ref()?.get(&adapter_kind)
}
}

Expand All @@ -50,7 +50,7 @@ impl Client {
#[derive(Debug)]
pub(super) struct ClientInner {
#[allow(unused)]
pub(super) apapter_config_by_kind: Option<HashMap<AdapterKind, AdapterConfig>>,
pub(super) adapter_config_by_kind: Option<HashMap<AdapterKind, AdapterConfig>>,

pub(super) web_client: WebClient,

Expand Down
2 changes: 1 addition & 1 deletion src/resolver/auth_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! - Contain a fixed auth value,
//! - Contain an `AuthResolverFnSync` trait object or closure that will be called to return the AuthData.
//!
//! Note: AuthData is typically a single value but can be Multi for future adapters (e.g., AWS Berock).
//! Note: AuthData is typically a single value but can be Multi for future adapters (e.g., AWS Bedrock).

use crate::adapter::AdapterKind;
use crate::resolver::{Error, Result};
Expand Down
14 changes: 7 additions & 7 deletions src/webc/web_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Stream for WebStream {
this.partial_message = Some(candidate_message);
}

// -- If we have a furst message, we nave to send it.
// -- If we have a first message, we have to send it.
if let Some(first_message) = first_message.take() {
return Poll::Ready(Some(Ok(first_message)));
} else {
Expand Down Expand Up @@ -170,7 +170,7 @@ struct BuffResponse {
///
/// IMPORTANT: Right now, it assumes each buff_string will contain the full main json object
/// for each array item (Which seems to be the case with Gemini)
/// This probaby need to be made more robust later
/// This probably need to be made more robust later
fn new_with_pretty_json_array(
buff_string: String,
_partial_message: &mut Option<String>,
Expand All @@ -179,7 +179,7 @@ fn new_with_pretty_json_array(

let mut messages: Vec<String> = Vec::new();

// -- Capther the array start/end and each eventual sub object (assuming only one sub objecct)
// -- Capture the array start/end and each eventual sub object (assuming only one sub object)
let (array_start, rest_str) = match buff_str.strip_prefix('[') {
Some(rest) => (Some("["), rest.trim()),
None => (None, buff_str),
Expand Down Expand Up @@ -240,10 +240,10 @@ fn process_buff_string_delimited(

for part in parts {
// if we already have a candidate, the candidate become the message
if let Some(canditate_message) = candidate_message.take() {
// if canditate is empty, we skip
if !canditate_message.is_empty() {
let message = canditate_message.to_string();
if let Some(candidate_message) = candidate_message.take() {
// if candidate is empty, we skip
if !candidate_message.is_empty() {
let message = candidate_message.to_string();
if first_message.is_none() {
first_message = Some(message);
} else {
Expand Down

0 comments on commit ef138b8

Please sign in to comment.