pub struct ChatArguments {Show 13 fields
pub model: String,
pub messages: Vec<Message>,
pub temperature: Option<f32>,
pub top_p: Option<f32>,
pub n: Option<u32>,
pub stream: Option<bool>,
pub stop: Option<String>,
pub max_tokens: Option<u32>,
pub presence_penalty: Option<f32>,
pub frequency_penalty: Option<f32>,
pub user: Option<String>,
pub response_format: Option<ResponseFormat>,
pub image_generation: Option<ImageGeneration>,
}
Fields§
§model: String
§messages: Vec<Message>
§temperature: Option<f32>
§top_p: Option<f32>
§n: Option<u32>
§stream: Option<bool>
§stop: Option<String>
§max_tokens: Option<u32>
§presence_penalty: Option<f32>
§frequency_penalty: Option<f32>
§user: Option<String>
§response_format: Option<ResponseFormat>
§image_generation: Option<ImageGeneration>
Implementations§
Source§impl ChatArguments
impl ChatArguments
Sourcepub fn new(model: impl AsRef<str>, messages: Vec<Message>) -> ChatArguments
pub fn new(model: impl AsRef<str>, messages: Vec<Message>) -> ChatArguments
Examples found in repository?
examples/chat_example.rs (lines 7-13)
5async fn main() {
6 let client = openai_rust::Client::new(&std::env::var("OPENAI_API_KEY").unwrap());
7 let args = openai_rust::chat::ChatArguments::new(
8 "gpt-3.5-turbo",
9 vec![openai_rust::chat::Message {
10 role: "user".to_owned(),
11 content: "Hello GPT!".to_owned(),
12 }],
13 );
14 let res = client.create_chat(args, None).await.unwrap();
15 println!("{}", res);
16}
More examples
examples/chat_stream_example.rs (lines 9-15)
7async fn main() {
8 let client = openai_rust::Client::new(&std::env::var("OPENAI_API_KEY").unwrap());
9 let args = openai_rust::chat::ChatArguments::new(
10 "gpt-3.5-turbo",
11 vec![openai_rust::chat::Message {
12 role: "user".to_owned(),
13 content: "Hello GPT!".to_owned(),
14 }],
15 );
16 let mut res = client.create_chat_stream(args, None).await.unwrap();
17 while let Some(chunk) = res.next().await {
18 print!("{}", chunk.unwrap());
19 std::io::stdout().flush().unwrap();
20 }
21}
Trait Implementations§
Source§impl Clone for ChatArguments
impl Clone for ChatArguments
Source§fn clone(&self) -> ChatArguments
fn clone(&self) -> ChatArguments
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ChatArguments
impl Debug for ChatArguments
Auto Trait Implementations§
impl Freeze for ChatArguments
impl RefUnwindSafe for ChatArguments
impl Send for ChatArguments
impl Sync for ChatArguments
impl Unpin for ChatArguments
impl UnwindSafe for ChatArguments
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more