-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/setup-ci
- Loading branch information
Showing
15 changed files
with
1,090 additions
and
68 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,45 @@ | ||
use std::sync::Arc; | ||
|
||
use derive_builder::Builder; | ||
|
||
mod embed; | ||
mod simple_prompt; | ||
|
||
#[derive(Debug)] | ||
#[derive(Debug, Builder, Clone)] | ||
pub struct OpenAI { | ||
client: async_openai::Client<async_openai::config::OpenAIConfig>, | ||
embed_model: String, | ||
prompt_model: String, | ||
#[builder(default = "Arc::new(async_openai::Client::new())", setter(custom))] | ||
client: Arc<async_openai::Client<async_openai::config::OpenAIConfig>>, | ||
#[builder(default)] | ||
default_options: Options, | ||
} | ||
|
||
#[derive(Debug, Default, Clone, Builder)] | ||
#[builder(setter(into, strip_option))] | ||
pub struct Options { | ||
#[builder(default)] | ||
pub embed_model: Option<String>, | ||
#[builder(default)] | ||
pub prompt_model: Option<String>, | ||
} | ||
|
||
impl Options { | ||
pub fn builder() -> OptionsBuilder { | ||
OptionsBuilder::default() | ||
} | ||
} | ||
|
||
impl OpenAI { | ||
pub fn builder() -> OpenAIBuilder { | ||
OpenAIBuilder::default() | ||
} | ||
} | ||
|
||
impl OpenAIBuilder { | ||
pub fn client( | ||
&mut self, | ||
client: async_openai::Client<async_openai::config::OpenAIConfig>, | ||
) -> &mut Self { | ||
self.client = Some(Arc::new(client)); | ||
self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.