Skip to content

Commit 9274131

Browse files
authored
Fix chunking strategy serialization and field visibility (64bit#288)
* Fix AssistantVectorStoreChunkingStrategy rename and make StaticChunkingStrategy fields public * Fix VectorStoreChunkingStrategy rename * Fix chunking stategy static field name --------- Co-authored-by: Niklas <71767810+niklass-l@users.noreply.github.com>
1 parent adaf26e commit 9274131

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

async-openai/src/types/assistant.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,24 @@ pub struct AssistantVectorStore {
6060
pub enum AssistantVectorStoreChunkingStrategy {
6161
/// The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
6262
#[default]
63+
#[serde(rename = "auto")]
6364
Auto,
64-
Static(StaticChunkingStrategy),
65+
#[serde(rename = "static")]
66+
Static {
67+
#[serde(rename = "static")]
68+
config: StaticChunkingStrategy,
69+
},
6570
}
6671

6772
/// Static Chunking Strategy
6873
#[derive(Clone, Serialize, Debug, Deserialize, PartialEq, Default)]
6974
pub struct StaticChunkingStrategy {
7075
/// The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
71-
max_chunk_size_tokens: u16,
76+
pub max_chunk_size_tokens: u16,
7277
/// The number of tokens that overlap between chunks. The default value is `400`.
7378
///
7479
/// Note that the overlap must not exceed half of `max_chunk_size_tokens`.
75-
chunk_overlap_tokens: u16,
80+
pub chunk_overlap_tokens: u16,
7681
}
7782

7883
/// Represents an `assistant` that can call the model and use tools.

async-openai/src/types/vector_store.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,13 @@ pub struct CreateVectorStoreRequest {
3939
pub enum VectorStoreChunkingStrategy {
4040
/// The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
4141
#[default]
42+
#[serde(rename = "auto")]
4243
Auto,
43-
Static(StaticChunkingStrategy),
44+
#[serde(rename = "static")]
45+
Static {
46+
#[serde(rename = "static")]
47+
config: StaticChunkingStrategy,
48+
},
4449
}
4550

4651
/// Vector store expiration policy

0 commit comments

Comments
 (0)