Skip to content

Commit 87c2a2e

Browse files
authored
Merge pull request #31 from spiceai/jeadie/pub
Add `utoipa::ToSchema` to relevant types
2 parents 4dcd633 + 1a56314 commit 87c2a2e

6 files changed

Lines changed: 211 additions & 199 deletions

File tree

async-openai/src/client.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ impl<C: Config> Client<C> {
354354
}
355355

356356
/// Make a POST request to {path} and deserialize the response body
357-
pub async fn post<I, O>(
357+
#[allow(unused)]
358+
pub(crate) async fn post<I, O>(
358359
&self,
359360
path: &str,
360361
request: I,
@@ -563,7 +564,8 @@ impl<C: Config> Client<C> {
563564
}
564565

565566
/// Make HTTP POST request to receive SSE
566-
pub async fn post_stream<I, O>(
567+
#[allow(unused)]
568+
pub(crate) async fn post_stream<I, O>(
567569
&self,
568570
path: &str,
569571
request: I,

async-openai/src/types/mcp/mcp_.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use derive_builder::Builder;
22
use serde::{Deserialize, Serialize};
3+
use utoipa::ToSchema;
34

45
use crate::error::OpenAIError;
56

6-
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
7+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema)]
78
#[serde(rename_all = "snake_case")]
89
pub enum McpToolConnectorId {
910
ConnectorDropbox,
@@ -16,7 +17,7 @@ pub enum McpToolConnectorId {
1617
ConnectorSharepoint,
1718
}
1819

19-
#[derive(Debug, Serialize, Deserialize, Clone, Builder, PartialEq, Default)]
20+
#[derive(Debug, Serialize, Deserialize, Clone, Builder, PartialEq, Default, ToSchema)]
2021
#[builder(
2122
name = "MCPToolArgs",
2223
pattern = "mutable",
@@ -70,7 +71,7 @@ pub struct MCPTool {
7071
pub server_url: Option<String>,
7172
}
7273

73-
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
74+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, ToSchema)]
7475
#[serde(untagged)]
7576
pub enum MCPToolAllowedTools {
7677
/// A string array of allowed tool names
@@ -79,7 +80,7 @@ pub enum MCPToolAllowedTools {
7980
Filter(MCPToolFilter),
8081
}
8182

82-
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
83+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, ToSchema)]
8384
pub struct MCPToolFilter {
8485
/// Indicates whether or not a tool modifies data or is read-only.
8586
/// If an MCP server is annotated with [readOnlyHint](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
@@ -92,7 +93,7 @@ pub struct MCPToolFilter {
9293
}
9394

9495
/// Approval policy or filter for MCP tools.
95-
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
96+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, ToSchema)]
9697
#[serde(untagged)]
9798
pub enum MCPToolRequireApproval {
9899
/// Specify which of the MCP server's tools require approval. Can be
@@ -105,14 +106,14 @@ pub enum MCPToolRequireApproval {
105106
ApprovalSetting(MCPToolApprovalSetting),
106107
}
107108

108-
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
109+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, ToSchema)]
109110
#[serde(rename_all = "lowercase")]
110111
pub enum MCPToolApprovalSetting {
111112
Always,
112113
Never,
113114
}
114115

115-
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
116+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, ToSchema)]
116117
pub struct MCPToolApprovalFilter {
117118
/// A list of tools that always require approval.
118119
#[serde(skip_serializing_if = "Option::is_none")]
@@ -122,7 +123,7 @@ pub struct MCPToolApprovalFilter {
122123
pub never: Option<MCPToolFilter>,
123124
}
124125

125-
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
126+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, ToSchema)]
126127
pub struct MCPListToolsTool {
127128
/// The JSON schema describing the tool's input.
128129
pub input_schema: serde_json::Value,

async-openai/src/types/metadata.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ impl From<serde_json::Value> for Metadata {
1515
Self(value)
1616
}
1717
}
18+
19+
impl Metadata {
20+
pub fn as_value(&self) -> &serde_json::Value {
21+
&self.0
22+
}
23+
}

0 commit comments

Comments
 (0)