pub struct CreateRunRequest {
pub model: Option<String>,
pub instructions: Option<String>,
pub tools: Option<Vec<HashMap<String, String>>>,
pub metadata: Option<HashMap<String, String>>,
/* private fields */
}
Expand description
Represents a request to create a new run.
Fields§
§model: Option<String>
Optional model to be used for the run.
instructions: Option<String>
Optional instructions for the run.
tools: Option<Vec<HashMap<String, String>>>
Optional tools to be used during the run.
metadata: Option<HashMap<String, String>>
Optional metadata for the run.
Implementations§
Source§impl CreateRunRequest
impl CreateRunRequest
Sourcepub fn new(assistant_id: String) -> Self
pub fn new(assistant_id: String) -> Self
Creates a new CreateRunRequest
with the specified assistant ID.
Examples found in repository?
examples/assistant.rs (line 44)
13async fn main() -> Result<(), Box<dyn std::error::Error>> {
14 let client = Client::from_env().unwrap();
15
16 let mut tools = HashMap::new();
17 tools.insert("type".to_string(), "code_interpreter".to_string());
18
19 let req = AssistantRequest::new(Model::GPT4(GPT4::GPT40125Preview));
20 let req = req
21 .clone()
22 .description("this is a test assistant".to_string());
23 let req = req.clone().instructions("You are a personal math tutor. When asked a question, write and run Python code to answer the question.".to_string());
24 let req = req.clone().tools(vec![tools]);
25 println!("{:?}", req);
26
27 let result = client.create_assistant(req).await?;
28 println!("{:?}", result.id);
29
30 let thread_req = CreateThreadRequest::new();
31 let thread_result = client.create_thread(thread_req).await?;
32 println!("{:?}", thread_result.id.clone());
33
34 let message_req = CreateMessageRequest::new(
35 MessageRole::User,
36 "`I need to solve the equation 3x + 11 = 14. Can you help me?".to_string(),
37 );
38
39 let message_result = client
40 .create_message(thread_result.id.clone(), message_req)
41 .await?;
42 println!("{:?}", message_result.id.clone());
43
44 let run_req = CreateRunRequest::new(result.id);
45 let run_result = client.create_run(thread_result.id.clone(), run_req).await?;
46
47 loop {
48 let run_result = client
49 .retrieve_run(thread_result.id.clone(), run_result.id.clone())
50 .await?;
51 if run_result.status == "completed" {
52 break;
53 } else {
54 println!("waiting...");
55 std::thread::sleep(std::time::Duration::from_secs(1));
56 }
57 }
58
59 let list_message_result = client.list_messages(thread_result.id.clone()).await?;
60 for data in list_message_result.data {
61 for content in data.content {
62 println!(
63 "{:?}: {:?} {:?}",
64 data.role, content.text.value, content.text.annotations
65 );
66 }
67 }
68
69 Ok(())
70}
Trait Implementations§
Source§impl Clone for CreateRunRequest
impl Clone for CreateRunRequest
Source§fn clone(&self) -> CreateRunRequest
fn clone(&self) -> CreateRunRequest
Returns a duplicate 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 CreateRunRequest
impl Debug for CreateRunRequest
Auto Trait Implementations§
impl Freeze for CreateRunRequest
impl RefUnwindSafe for CreateRunRequest
impl Send for CreateRunRequest
impl Sync for CreateRunRequest
impl Unpin for CreateRunRequest
impl UnwindSafe for CreateRunRequest
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