Skip to content

Commit c388b0f

Browse files
64bitifsheldon
authored andcommitted
spec sync: Uploads + Administration APIs (64bit#286)
* uploads API * moderations API update * CreateFineTuningJobRequest comment docs updated * added Audit Logs API * organization invite API updated * organization users API updated * updated project APIs * fix project archive url * update Client to create audit_logs, invites, users, and projects API groups * updated ProjectUsers APIs * addeds project service account APIs * ProjectServiceAccounts api group * added project api keys APIs * updated README * updated spec from upstream https://github.com/openai/openai-openapi/blob/d033c364c6574068ee89f3d5f845a4830bddd503/openapi.yaml * fix PromptTokensDetails and CompletionTokensDetails * update function-call and function-call-stream examples to use non-deprecated model: gpt-4o-mini * fix moderation types * update moderation example * add missing doc comments * fix: add missing pub modifier (cherry picked from commit f388518)
1 parent 4605113 commit c388b0f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+10092
-5292
lines changed

async-openai-wasm/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ a `x.y.z` version.
3232
- [x] Images
3333
- [x] Models
3434
- [x] Moderations
35-
- [ ] Organizations | Administration
35+
- [x] Organizations | Administration
3636
- [x] Realtime API types (Beta)
37-
- [ ] Uploads
37+
- [x] Uploads
3838
- [x] **WASM support**
3939
- SSE streaming on available APIs
4040
- Ergonomic builder pattern for all request objects.
@@ -78,7 +78,7 @@ $Env:OPENAI_API_KEY='sk-...'
7878
## Realtime API
7979

8080
Only types for Realtime API are implemented, and can be enabled with feature flag `realtime`
81-
These types may change when OpenAI releases official specs for them.
81+
These types may change if/when OpenAI releases official specs for them.
8282

8383
Again, the types do not bundle with a specific WS implementation. Need to convert a client event into a WS message by yourself, which is just simple `your_ws_impl::Message::Text(some_client_event.into_text())`.
8484

async-openai-wasm/src/assistant_files.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use serde::Serialize;
22

33
use crate::{
4-
Client,
54
config::Config,
65
error::OpenAIError,
76
types::{
87
AssistantFileObject, CreateAssistantFileRequest, DeleteAssistantFileResponse,
98
ListAssistantFilesResponse,
109
},
10+
Client,
1111
};
1212

1313
/// Files attached to an assistant.

async-openai-wasm/src/assistants.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use serde::Serialize;
22

33
use crate::{
4-
AssistantFiles,
5-
Client,
64
config::Config,
7-
error::OpenAIError, types::{
5+
error::OpenAIError,
6+
types::{
87
AssistantObject, CreateAssistantRequest, DeleteAssistantResponse, ListAssistantsResponse,
98
ModifyAssistantRequest,
109
},
10+
AssistantFiles, Client,
1111
};
1212

1313
/// Build assistants that can call models and use tools to perform tasks.

async-openai-wasm/src/audio.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use bytes::Bytes;
22

33
use crate::{
4-
Client,
54
config::Config,
65
error::OpenAIError,
76
types::{
@@ -10,6 +9,7 @@ use crate::{
109
CreateTranslationRequest, CreateTranslationResponseJson,
1110
CreateTranslationResponseVerboseJson,
1211
},
12+
Client,
1313
};
1414

1515
/// Turn audio into text or text into audio.

async-openai-wasm/src/audit_logs.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use serde::Serialize;
2+
3+
use crate::{config::Config, error::OpenAIError, types::ListAuditLogsResponse, Client};
4+
5+
/// Logs of user actions and configuration changes within this organization.
6+
/// To log events, you must activate logging in the [Organization Settings](https://platform.openai.com/settings/organization/general).
7+
/// Once activated, for security reasons, logging cannot be deactivated.
8+
pub struct AuditLogs<'c, C: Config> {
9+
client: &'c Client<C>,
10+
}
11+
12+
impl<'c, C: Config> AuditLogs<'c, C> {
13+
pub fn new(client: &'c Client<C>) -> Self {
14+
Self { client }
15+
}
16+
17+
/// List user actions and configuration changes within this organization.
18+
pub async fn get<Q>(&self, query: &Q) -> Result<ListAuditLogsResponse, OpenAIError>
19+
where
20+
Q: Serialize + ?Sized,
21+
{
22+
self.client
23+
.get_with_query("/organization/audit_logs", query)
24+
.await
25+
}
26+
}

async-openai-wasm/src/batches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use serde::Serialize;
22

33
use crate::{
4-
Client,
54
config::Config,
65
error::OpenAIError,
76
types::{Batch, BatchRequest, ListBatchesResponse},
7+
Client,
88
};
99

1010
/// Create large batches of API requests for asynchronous processing. The Batch API returns completions within 24 hours for a 50% discount.

async-openai-wasm/src/chat.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use crate::{
2-
Client,
32
config::Config,
43
error::OpenAIError,
54
types::{
6-
ChatCompletionResponseStream, CreateChatCompletionRequest, CreateChatCompletionResponse
5+
ChatCompletionResponseStream, CreateChatCompletionRequest, CreateChatCompletionResponse,
76
},
7+
Client,
88
};
99

1010
/// Given a list of messages comprising a conversation, the model will return a response.
@@ -32,7 +32,6 @@ impl<'c, C: Config> Chat<'c, C> {
3232
self.client.post("/chat/completions", request).await
3333
}
3434

35-
3635
/// Creates a completion for the chat message
3736
///
3837
/// partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message.

0 commit comments

Comments
 (0)