(
&self,
prompt: String,
max_tokens: Option<i64>,
temperature: Option<f64>,
enable_prompt_caching: bool,
py: Python<'a>,
)
| 881 | #[instrument(skip(self, py), fields(prompt_len = prompt.len()))] |
| 882 | #[pyo3(signature = (prompt, max_tokens=None, temperature=None, enable_prompt_caching=false))] |
| 883 | fn complete_full_async<'a>( |
| 884 | &self, |
| 885 | prompt: String, |
| 886 | max_tokens: Option<i64>, |
| 887 | temperature: Option<f64>, |
| 888 | enable_prompt_caching: bool, |
| 889 | py: Python<'a>, |
| 890 | ) -> PyResult<Bound<'a, PyAny>> { |
| 891 | // Validate input |
| 892 | if prompt.is_empty() { |
| 893 | return Err(validation_error( |
| 894 | "prompt", |
| 895 | Some(&prompt), |
| 896 | "Prompt cannot be empty", |
| 897 | )); |
| 898 | } |
| 899 | |
| 900 | let validated_max_tokens = max_tokens |
| 901 | .map(|t| { |
| 902 | if t <= 0 { |
| 903 | Err(validation_error( |
| 904 | "max_tokens", |
| 905 | Some(&t.to_string()), |
| 906 | "max_tokens must be positive", |
| 907 | )) |
| 908 | } else if t > 100_000 { |
| 909 | Err(validation_error( |
| 910 | "max_tokens", |
| 911 | Some(&t.to_string()), |
| 912 | "max_tokens cannot exceed 100,000", |
| 913 | )) |
| 914 | } else { |
| 915 | Ok(t as u32) |
| 916 | } |
| 917 | }) |
| 918 | .transpose()?; |
| 919 | |
| 920 | let validated_temperature = temperature |
| 921 | .map(|t| { |
| 922 | if !(0.0..=2.0).contains(&t) { |
| 923 | Err(validation_error( |
| 924 | "temperature", |
| 925 | Some(&t.to_string()), |
| 926 | "temperature must be between 0.0 and 2.0", |
| 927 | )) |
| 928 | } else { |
| 929 | Ok(t as f32) |
| 930 | } |
| 931 | }) |
| 932 | .transpose()?; |
| 933 | |
| 934 | let provider = Arc::clone(&self.provider); |
| 935 | let circuit_breaker = Arc::clone(&self.circuit_breaker); |
| 936 | let stats = Arc::clone(&self.stats); |
| 937 | let config = self.config.clone(); |
| 938 | |
| 939 | pyo3_async_runtimes::tokio::future_into_py(py, async move { |
| 940 | let response = Self::execute_with_resilience_full( |
nothing calls this directly
no test coverage detected