Skip to main content

gproxy_protocol/adapt/generate/claude_responses/
synthesis.rs

1use super::*;
2
3impl ClaudeViaResponses {
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: c::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(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(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: c::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(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(Some(false));
40        Ok(prepared)
41    }
42}
43
44impl ResponsesViaClaude {
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: r::GenerateContentRequestBody,
49        endpoint: Endpoint,
50        identities: GenerationIdentity,
51        state: &super::super::GenerationStateAccess<'_, S>,
52        context: p::ClaudeRequestContext,
53    ) -> Result<Self, TransformError> {
54        let original = input.into_declared();
55        let mut buffered = original.clone();
56        buffered.stream = Some(Some(false));
57        let mut prepared =
58            Self::prepare_with_state(buffered, endpoint, identities, state, context).await?;
59        prepared.original_request = original;
60        prepared.target_request.stream = Some(false);
61        Ok(prepared)
62    }
63    /// Prepare a buffered upstream result for later native stream synthesis,
64    /// retaining the original client stream flag and all declared controls.
65    pub async fn prepare_for_stream_synthesis_with_capabilities<
66        S: crate::capability::StateStore,
67        R: crate::capability::ResourceAccess,
68    >(
69        input: r::GenerateContentRequestBody,
70        endpoint: Endpoint,
71        identities: GenerationIdentity,
72        state: &super::super::GenerationStateAccess<'_, S>,
73        resources: &super::super::GenerationResources<'_, R>,
74        context: p::ClaudeRequestContext,
75    ) -> Result<Self, TransformError> {
76        let original = input.into_declared();
77        let mut buffered = original.clone();
78        buffered.stream = Some(Some(false));
79        let mut prepared = Self::prepare_with_capabilities(
80            buffered, endpoint, identities, state, resources, context,
81        )
82        .await?;
83        prepared.original_request = original;
84        prepared.target_request.stream = Some(false);
85        Ok(prepared)
86    }
87}