mockql_core/llm_provider/http/
mod.rs1use crate::GraphQLResponse;
16use crate::ProviderError;
17use crate::graphql::mock_response_prompt::MockResponsePrompt;
18use crate::llm_provider::http::gemini::GeminiCompatibleHttpProvider;
19use crate::llm_provider::http::github_copilot::GithubCopilotHttpProvider;
20use reqwest::Client;
21use std::env;
22
23pub mod gemini;
24pub mod github_copilot;
25
26#[derive(Debug, Clone)]
28pub enum HttpProvider {
29 GithubCopilot(GithubCopilotHttpProvider),
31 Gemini(GeminiCompatibleHttpProvider),
33}
34
35impl HttpProvider {
36 pub(crate) async fn run(
37 &self,
38 prompt: &MockResponsePrompt,
39 client: &Client,
40 ) -> Result<GraphQLResponse, ProviderError> {
41 if env::var("MOCKQL_DEBUG").is_ok()
42 && let Ok(markdown) = prompt.to_markdown()
43 {
44 let _ = std::fs::write("prompt.dbg.txt", markdown);
45 }
46 match self {
47 Self::GithubCopilot(github_copilot) => github_copilot.run(prompt, client).await,
48 Self::Gemini(gemini) => gemini.run(prompt, client).await,
49 }
50 }
51}