Skip to main content

mockql_core/llm_provider/http/
mod.rs

1// Copyright 2026 Expedia, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use 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/// Supported HTTP provider variants.
27#[derive(Debug, Clone)]
28pub enum HttpProvider {
29  /// GitHub Copilot HTTP provider.
30  GithubCopilot(GithubCopilotHttpProvider),
31  /// Gemini-compatible HTTP provider.
32  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}