-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support assistants api and fix two markdown links error
- Loading branch information
1 parent
7e98344
commit c828f39
Showing
6 changed files
with
434 additions
and
2 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//! Build assistants that can call models and use tools to perform tasks. | ||
//! | ||
//! [Get started with the Assistants API](https://platform.openai.com/docs/assistants) | ||
use crate::client::OpenAI; | ||
use crate::interfaces::assistants; | ||
use crate::shared::response_wrapper::OpenAIResponse; | ||
|
||
pub struct Assistants<'a> { | ||
openai: &'a OpenAI, | ||
} | ||
|
||
impl<'a> Assistants<'a> { | ||
pub fn new(openai: &'a OpenAI) -> Self { | ||
Self { openai } | ||
} | ||
|
||
/// Create an assistant with a model and instructions. | ||
pub async fn create_assistant( | ||
&self, | ||
req: &assistants::AssistantRequest, | ||
) -> OpenAIResponse<assistants::AssistantResponse> { | ||
self.openai.post("/assistants", req).await | ||
} | ||
|
||
/// Returns a list of assistants. | ||
pub async fn list_assistants( | ||
&self, | ||
req: &assistants::ListAssistantRequest, | ||
) -> OpenAIResponse<assistants::ListAssistantResponse> { | ||
self.openai.get("/assistants", req).await | ||
} | ||
|
||
/// Retrieves an assistant. | ||
pub async fn retrieve_assistant( | ||
&self, | ||
assistant_id: &str, | ||
) -> OpenAIResponse<assistants::AssistantResponse> { | ||
self.openai | ||
.get(&format!("/assistants/{assistant_id}"), &()) | ||
.await | ||
} | ||
|
||
/// Modifies an assistant. | ||
pub async fn modify_assistant( | ||
&self, | ||
assistant_id: &str, | ||
req: &assistants::AssistantRequest, | ||
) -> OpenAIResponse<assistants::AssistantResponse> { | ||
self.openai | ||
.post(&format!("/assistants/{assistant_id}"), req) | ||
.await | ||
} | ||
|
||
/// Delete an assistant. | ||
pub async fn delete_assistant( | ||
&self, | ||
assistant_id: &str, | ||
) -> OpenAIResponse<assistants::DeleteAssistantResponse> { | ||
self.openai | ||
.delete(&format!("/assistants/{assistant_id}"), &()) | ||
.await | ||
} | ||
} |
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,3 +1,4 @@ | ||
pub mod assistants; | ||
pub mod audio; | ||
pub mod batch; | ||
pub mod chat; | ||
|
Oops, something went wrong.