(
&self,
prompt: String,
max_tokens: Option<i64>,
temperature: Option<f64>,
enable_prompt_caching: bool,
py: Python<'_>,
)
| 810 | #[instrument(skip(self, py), fields(prompt_len = prompt.len()))] |
| 811 | #[pyo3(signature = (prompt, max_tokens=None, temperature=None, enable_prompt_caching=false))] |
| 812 | fn complete_full( |
| 813 | &self, |
| 814 | prompt: String, |
| 815 | max_tokens: Option<i64>, |
| 816 | temperature: Option<f64>, |
| 817 | enable_prompt_caching: bool, |
| 818 | py: Python<'_>, |
| 819 | ) -> PyResult<PyLlmResponse> { |
| 820 | // Validate input |
| 821 | if prompt.is_empty() { |
| 822 | return Err(validation_error( |
| 823 | "prompt", |
| 824 | Some(&prompt), |
| 825 | "Prompt cannot be empty", |
| 826 | )); |
| 827 | } |
| 828 | |
| 829 | let validated_max_tokens = max_tokens |
| 830 | .map(|t| { |
| 831 | if t <= 0 { |
| 832 | Err(validation_error( |
| 833 | "max_tokens", |
| 834 | Some(&t.to_string()), |
| 835 | "max_tokens must be positive", |
| 836 | )) |
| 837 | } else if t > 100_000 { |
| 838 | Err(validation_error( |
| 839 | "max_tokens", |
| 840 | Some(&t.to_string()), |
| 841 | "max_tokens cannot exceed 100,000", |
| 842 | )) |
| 843 | } else { |
| 844 | Ok(t as u32) |
| 845 | } |
| 846 | }) |
| 847 | .transpose()?; |
| 848 | |
| 849 | let validated_temperature = temperature |
| 850 | .map(|t| { |
| 851 | if !(0.0..=2.0).contains(&t) { |
| 852 | Err(validation_error( |
| 853 | "temperature", |
| 854 | Some(&t.to_string()), |
| 855 | "temperature must be between 0.0 and 2.0", |
| 856 | )) |
| 857 | } else { |
| 858 | Ok(t as f32) |
| 859 | } |
| 860 | }) |
| 861 | .transpose()?; |
| 862 | |
| 863 | // CRITICAL FIX: Release GIL during async execution for true parallelism |
| 864 | let response = py.allow_threads(|| { |
| 865 | get_runtime().block_on(Self::execute_with_resilience_full( |
| 866 | Arc::clone(&self.provider), |
| 867 | Arc::clone(&self.circuit_breaker), |
| 868 | Arc::clone(&self.stats), |
| 869 | self.config.clone(), |
nothing calls this directly
no test coverage detected