Skip to main content

gproxy_protocol/adapt/generate/chat_claude/
synthesis.rs

1use super::*;
2
3impl ChatViaClaude {
4    /// Prepare a buffered upstream result for later native stream synthesis,
5    /// retaining the original client stream flag and all declared controls.
6    pub async fn prepare_for_stream_synthesis<S: crate::capability::StateStore>(
7        input: h::GenerateContentRequestBody,
8        endpoint: Endpoint,
9        identities: GenerationIdentity,
10        state: &super::super::GenerationStateAccess<'_, S>,
11    ) -> Result<Self, TransformError> {
12        let original = input.into_declared();
13        let mut buffered = original.clone();
14        buffered.stream = Some(Some(false));
15        let mut prepared = Self::prepare_with_state(buffered, endpoint, identities, state).await?;
16        prepared.original_request = original;
17        prepared.target_request.stream = Some(false);
18        Ok(prepared)
19    }
20    /// Prepare a buffered upstream result for later native stream synthesis,
21    /// retaining the original client stream flag and all declared controls.
22    pub async fn prepare_for_stream_synthesis_with_capabilities<
23        S: crate::capability::StateStore,
24        R: crate::capability::ResourceAccess,
25    >(
26        input: h::GenerateContentRequestBody,
27        endpoint: Endpoint,
28        identities: GenerationIdentity,
29        state: &super::super::GenerationStateAccess<'_, S>,
30        resources: &super::super::GenerationResources<'_, R>,
31    ) -> Result<Self, TransformError> {
32        let original = input.into_declared();
33        let mut buffered = original.clone();
34        buffered.stream = Some(Some(false));
35        let mut prepared =
36            Self::prepare_with_capabilities(buffered, endpoint, identities, state, resources)
37                .await?;
38        prepared.original_request = original;
39        prepared.target_request.stream = Some(false);
40        Ok(prepared)
41    }
42}
43
44impl ClaudeViaChat {
45    /// Prepare a buffered upstream result for later native stream synthesis,
46    /// retaining the original client stream flag and all declared controls.
47    pub async fn prepare_for_stream_synthesis<S: crate::capability::StateStore>(
48        input: c::GenerateContentRequestBody,
49        endpoint: Endpoint,
50        identities: GenerationIdentity,
51        state: &super::super::GenerationStateAccess<'_, S>,
52    ) -> Result<Self, TransformError> {
53        let original = input.into_declared();
54        let mut buffered = original.clone();
55        buffered.stream = Some(false);
56        let mut prepared = Self::prepare_with_state(buffered, endpoint, identities, state).await?;
57        prepared.original_request = original;
58        prepared.target_request.stream = Some(Some(false));
59        Ok(prepared)
60    }
61    /// Prepare a buffered upstream result for later native stream synthesis,
62    /// retaining the original client stream flag and all declared controls.
63    pub async fn prepare_for_stream_synthesis_with_capabilities<
64        S: crate::capability::StateStore,
65        R: crate::capability::ResourceAccess,
66    >(
67        input: c::GenerateContentRequestBody,
68        endpoint: Endpoint,
69        identities: GenerationIdentity,
70        state: &super::super::GenerationStateAccess<'_, S>,
71        resources: &super::super::GenerationResources<'_, R>,
72    ) -> Result<Self, TransformError> {
73        let original = input.into_declared();
74        let mut buffered = original.clone();
75        buffered.stream = Some(false);
76        let mut prepared =
77            Self::prepare_with_capabilities(buffered, endpoint, identities, state, resources)
78                .await?;
79        prepared.original_request = original;
80        prepared.target_request.stream = Some(Some(false));
81        Ok(prepared)
82    }
83}