Skip to content

Commit d6c4b8f

Browse files
authored
Merge pull request #61 from demml/update-pyo3
bump pyo3
2 parents e6a5e29 + 8410006 commit d6c4b8f

28 files changed

Lines changed: 525 additions & 698 deletions

File tree

Cargo.lock

Lines changed: 249 additions & 422 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ default-members = [
99
]
1010

1111
[workspace.package]
12-
version = "0.20.0"
12+
version = "0.21.0"
1313
authors = ["demml <support@demmlai.com>"]
1414
edition = "2021"
1515
license = "MIT"
1616
repository = "https://github.com/demml/potatohead"
1717

1818
[workspace.dependencies]
19-
baked-potato = { path = "crates/baked_potato", version = "0.20.0" }
20-
potato-agent = { path = "crates/potato_agent", version = "0.20.0" }
21-
potato-provider = { path = "crates/potato_provider", version = "0.20.0" }
22-
potatohead-macro = { path = "crates/potato_macro", version = "0.20.0" }
23-
potato-type = { path = "crates/potato_type", version = "0.20.0" }
24-
potato-workflow = { path = "crates/potato_workflow", version = "0.20.0" }
25-
potato-util = { path = "crates/potato_util", version = "0.20.0" }
26-
potato-head = { path = "crates/potato_head", version = "0.20.0" }
27-
potato-state = { path = "crates/potato_state", version = "0.20.0" }
28-
potato-spec = { path = "crates/potato_spec", version = "0.20.0" }
19+
baked-potato = { path = "crates/baked_potato", version = "0.21.0" }
20+
potato-agent = { path = "crates/potato_agent", version = "0.21.0" }
21+
potato-provider = { path = "crates/potato_provider", version = "0.21.0" }
22+
potatohead-macro = { path = "crates/potato_macro", version = "0.21.0" }
23+
potato-type = { path = "crates/potato_type", version = "0.21.0" }
24+
potato-workflow = { path = "crates/potato_workflow", version = "0.21.0" }
25+
potato-util = { path = "crates/potato_util", version = "0.21.0" }
26+
potato-head = { path = "crates/potato_head", version = "0.21.0" }
27+
potato-state = { path = "crates/potato_state", version = "0.21.0" }
28+
potato-spec = { path = "crates/potato_spec", version = "0.21.0" }
2929

3030
anyhow = "1.0.93"
3131
async-trait = "0.*"
@@ -35,7 +35,7 @@ colored_json = "5.*"
3535
http = "1.*"
3636
gcloud-auth = { version = "1.*" }
3737
mockito = "1.*"
38-
pyo3 = { version = "0.27.2", features = ["abi3-py310", "extension-module", "anyhow", "serde", "chrono"] }
38+
pyo3 = { version = "0.28.*", features = ["abi3-py310", "extension-module", "anyhow", "serde", "chrono"] }
3939
pythonize = { version = "0.*" }
4040
rand = "0.9.*"
4141
regex = "1.*"

crates/baked_potato/src/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ impl Default for LLMApiMock {
487487
}
488488
}
489489

490-
#[pyclass]
490+
#[pyclass(skip_from_py_object)]
491491
#[allow(dead_code)]
492492
pub struct LLMTestServer {
493493
openai_server: Option<LLMApiMock>,

crates/potato_agent/src/agents/agent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ impl<'de> Deserialize<'de> for Agent {
921921
}
922922
}
923923

924-
#[pyclass(name = "Agent")]
924+
#[pyclass(from_py_object, name = "Agent")]
925925
#[derive(Debug, Clone)]
926926
pub struct PyAgent {
927927
pub agent: Arc<Agent>,

crates/potato_agent/src/agents/task.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use pyo3::prelude::*;
66
use serde::{Deserialize, Serialize};
77
use serde_json::Value;
88
use tracing::{error, instrument};
9-
#[pyclass(eq)]
9+
#[pyclass(from_py_object, eq)]
1010
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1111
pub enum TaskStatus {
1212
Pending,
@@ -15,7 +15,7 @@ pub enum TaskStatus {
1515
Failed,
1616
}
1717

18-
#[pyclass]
18+
#[pyclass(skip_from_py_object)]
1919
#[derive(Debug, Serialize)]
2020
pub struct WorkflowTask {
2121
#[pyo3(get)]
@@ -51,7 +51,7 @@ impl WorkflowTask {
5151
}
5252
}
5353

54-
#[pyclass]
54+
#[pyclass(from_py_object)]
5555
#[derive(Debug, Serialize, Deserialize, Clone)]
5656
pub struct Task {
5757
#[pyo3(get)]

crates/potato_agent/src/agents/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl AgentResponse {
5252
}
5353
}
5454

55-
#[pyclass(name = "AgentResponse")]
55+
#[pyclass(skip_from_py_object, name = "AgentResponse")]
5656
#[derive(Debug, Serialize)]
5757
pub struct PyAgentResponse {
5858
pub inner: AgentResponse,

crates/potato_provider/src/providers/embed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl EmbeddingResponse {
251251
}
252252
}
253253

254-
#[pyclass(name = "Embedder")]
254+
#[pyclass(from_py_object, name = "Embedder")]
255255
#[derive(Debug, Clone)]
256256
pub struct PyEmbedder {
257257
pub embedder: Arc<Embedder>,

crates/potato_type/src/anthropic/v1/request.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub const SEARCH_RESULT_LOCATION_TYPE: &str = "search_result_location";
4848
pub const WEB_SEARCH_TOOL_RESULT_ERROR_TYPE: &str = "web_search_tool_result_error";
4949

5050
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
51-
#[pyclass]
51+
#[pyclass(from_py_object)]
5252
pub struct CitationCharLocationParam {
5353
#[pyo3(get, set)]
5454
pub cited_text: String,
@@ -87,7 +87,7 @@ impl CitationCharLocationParam {
8787
}
8888

8989
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
90-
#[pyclass]
90+
#[pyclass(from_py_object)]
9191
pub struct CitationPageLocationParam {
9292
#[pyo3(get, set)]
9393
pub cited_text: String,
@@ -126,7 +126,7 @@ impl CitationPageLocationParam {
126126
}
127127

128128
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
129-
#[pyclass]
129+
#[pyclass(from_py_object)]
130130
pub struct CitationContentBlockLocationParam {
131131
#[pyo3(get, set)]
132132
pub cited_text: String,
@@ -165,7 +165,7 @@ impl CitationContentBlockLocationParam {
165165
}
166166

167167
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
168-
#[pyclass]
168+
#[pyclass(from_py_object)]
169169
pub struct CitationWebSearchResultLocationParam {
170170
#[pyo3(get, set)]
171171
pub cited_text: String,
@@ -195,7 +195,7 @@ impl CitationWebSearchResultLocationParam {
195195
}
196196

197197
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
198-
#[pyclass]
198+
#[pyclass(from_py_object)]
199199
pub struct CitationSearchResultLocationParam {
200200
#[pyo3(get, set)]
201201
pub cited_text: String,
@@ -249,7 +249,7 @@ pub enum TextCitationParam {
249249
}
250250

251251
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
252-
#[pyclass]
252+
#[pyclass(from_py_object)]
253253
pub struct TextBlockParam {
254254
#[pyo3(get, set)]
255255
pub text: String,
@@ -329,7 +329,7 @@ impl TextBlockParam {
329329
}
330330

331331
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
332-
#[pyclass]
332+
#[pyclass(from_py_object)]
333333
pub struct Base64ImageSource {
334334
#[pyo3(get, set)]
335335
pub media_type: String,
@@ -357,7 +357,7 @@ impl Base64ImageSource {
357357
}
358358

359359
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
360-
#[pyclass]
360+
#[pyclass(from_py_object)]
361361
pub struct UrlImageSource {
362362
#[pyo3(get, set)]
363363
pub url: String,
@@ -385,7 +385,7 @@ pub enum ImageSource {
385385
}
386386

387387
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
388-
#[pyclass]
388+
#[pyclass(from_py_object)]
389389
pub struct ImageBlockParam {
390390
pub source: ImageSource,
391391
#[serde(skip_serializing_if = "Option::is_none")]
@@ -432,7 +432,7 @@ impl ImageBlockParam {
432432
}
433433

434434
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
435-
#[pyclass]
435+
#[pyclass(from_py_object)]
436436
pub struct Base64PDFSource {
437437
#[pyo3(get, set)]
438438
pub media_type: String,
@@ -456,7 +456,7 @@ impl Base64PDFSource {
456456
}
457457

458458
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
459-
#[pyclass]
459+
#[pyclass(from_py_object)]
460460
pub struct UrlPDFSource {
461461
#[pyo3(get, set)]
462462
pub url: String,
@@ -477,7 +477,7 @@ impl UrlPDFSource {
477477
}
478478

479479
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
480-
#[pyclass]
480+
#[pyclass(from_py_object)]
481481
pub struct PlainTextSource {
482482
#[pyo3(get, set)]
483483
pub media_type: String,
@@ -501,7 +501,7 @@ impl PlainTextSource {
501501
}
502502

503503
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
504-
#[pyclass]
504+
#[pyclass(from_py_object)]
505505
pub struct CitationsConfigParams {
506506
#[pyo3(get, set)]
507507
pub enabled: Option<bool>,
@@ -516,7 +516,7 @@ pub enum DocumentSource {
516516
}
517517

518518
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
519-
#[pyclass]
519+
#[pyclass(from_py_object)]
520520
pub struct DocumentBlockParam {
521521
pub source: DocumentSource,
522522
#[serde(skip_serializing_if = "Option::is_none")]
@@ -567,7 +567,7 @@ impl DocumentBlockParam {
567567
}
568568

569569
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
570-
#[pyclass]
570+
#[pyclass(from_py_object)]
571571
pub struct SearchResultBlockParam {
572572
#[pyo3(get, set)]
573573
pub content: Vec<TextBlockParam>,
@@ -607,7 +607,7 @@ impl SearchResultBlockParam {
607607
}
608608

609609
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
610-
#[pyclass]
610+
#[pyclass(from_py_object)]
611611
pub struct ThinkingBlockParam {
612612
#[pyo3(get, set)]
613613
pub thinking: String,
@@ -632,7 +632,7 @@ impl ThinkingBlockParam {
632632
}
633633

634634
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
635-
#[pyclass]
635+
#[pyclass(from_py_object)]
636636
pub struct RedactedThinkingBlockParam {
637637
#[pyo3(get, set)]
638638
pub data: String,
@@ -653,7 +653,7 @@ impl RedactedThinkingBlockParam {
653653
}
654654

655655
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
656-
#[pyclass]
656+
#[pyclass(from_py_object)]
657657
pub struct ToolUseBlockParam {
658658
#[pyo3(get, set)]
659659
pub id: String,
@@ -705,7 +705,7 @@ pub enum ToolResultContentEnum {
705705
}
706706

707707
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
708-
#[pyclass]
708+
#[pyclass(from_py_object)]
709709
pub struct ToolResultBlockParam {
710710
#[pyo3(get, set)]
711711
pub tool_use_id: String,
@@ -822,7 +822,7 @@ impl ToolResultBlockParam {
822822
}
823823

824824
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
825-
#[pyclass]
825+
#[pyclass(from_py_object)]
826826
pub struct ServerToolUseBlockParam {
827827
#[pyo3(get, set)]
828828
pub id: String,
@@ -863,7 +863,7 @@ impl ServerToolUseBlockParam {
863863
}
864864

865865
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
866-
#[pyclass]
866+
#[pyclass(from_py_object)]
867867
pub struct WebSearchResultBlockParam {
868868
#[pyo3(get, set)]
869869
pub encrypted_content: String,
@@ -899,7 +899,7 @@ impl WebSearchResultBlockParam {
899899
}
900900

901901
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
902-
#[pyclass]
902+
#[pyclass(from_py_object)]
903903
pub struct WebSearchToolResultBlockParam {
904904
#[pyo3(get, set)]
905905
pub tool_use_id: String,
@@ -1156,7 +1156,7 @@ impl ContentBlockParam {
11561156
}
11571157

11581158
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1159-
#[pyclass]
1159+
#[pyclass(from_py_object)]
11601160
pub struct MessageParam {
11611161
pub content: Vec<ContentBlockParam>,
11621162
#[pyo3(get)]
@@ -1417,7 +1417,7 @@ impl MessageConversion for MessageParam {
14171417
}
14181418

14191419
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1420-
#[pyclass]
1420+
#[pyclass(from_py_object)]
14211421
pub struct Metadata {
14221422
#[serde(skip_serializing_if = "Option::is_none")]
14231423
pub user_id: Option<String>,
@@ -1433,7 +1433,7 @@ impl Metadata {
14331433
}
14341434

14351435
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1436-
#[pyclass]
1436+
#[pyclass(from_py_object)]
14371437
pub struct CacheControl {
14381438
#[serde(rename = "type")]
14391439
pub cache_type: String, // "ephemeral"
@@ -1451,7 +1451,7 @@ impl CacheControl {
14511451
}
14521452

14531453
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1454-
#[pyclass(name = "AnthropicTool")]
1454+
#[pyclass(from_py_object, name = "AnthropicTool")]
14551455
pub struct Tool {
14561456
pub name: String,
14571457
#[serde(skip_serializing_if = "Option::is_none")]
@@ -1497,7 +1497,7 @@ impl Tool {
14971497
}
14981498

14991499
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1500-
#[pyclass(name = "AnthropicThinkingConfig")]
1500+
#[pyclass(from_py_object, name = "AnthropicThinkingConfig")]
15011501
pub struct ThinkingConfig {
15021502
#[pyo3(get)]
15031503
pub r#type: String,
@@ -1520,7 +1520,7 @@ impl ThinkingConfig {
15201520
}
15211521

15221522
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1523-
#[pyclass(name = "AnthropicToolChoice")]
1523+
#[pyclass(from_py_object, name = "AnthropicToolChoice")]
15241524
pub struct ToolChoice {
15251525
#[pyo3(get)]
15261526
pub r#type: String, // "auto", "any", "tool", "none"
@@ -1566,7 +1566,7 @@ impl ToolChoice {
15661566
}
15671567

15681568
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1569-
#[pyclass]
1569+
#[pyclass(from_py_object)]
15701570
#[serde(default)]
15711571
pub struct AnthropicSettings {
15721572
#[pyo3(get)]
@@ -1829,7 +1829,7 @@ impl RequestAdapter for AnthropicMessageRequestV1 {
18291829
}
18301830

18311831
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1832-
#[pyclass]
1832+
#[pyclass(from_py_object)]
18331833
pub struct SystemPrompt {
18341834
#[pyo3(get)]
18351835
#[serde(flatten)]

0 commit comments

Comments
 (0)