1616#ifndef VIX_AI_AGENT_MODEL_OLLAMAPROVIDER_HPP
1717#define VIX_AI_AGENT_MODEL_OLLAMAPROVIDER_HPP
1818
19+ #include < memory>
1920#include < string>
2021#include < string_view>
2122
2223#include < vix/ai/agent/AgentConfig.hpp>
2324#include < vix/ai/agent/model/ModelProvider.hpp>
2425#include < vix/ai/agent/model/ModelRequest.hpp>
2526#include < vix/ai/agent/model/ModelResponse.hpp>
27+ #include < vix/net/http/Client.hpp>
2628
2729namespace vix ::ai::agent
2830{
@@ -35,25 +37,62 @@ namespace vix::ai::agent
3537 * http://127.0.0.1:11434
3638 *
3739 * The provider is local-first and suitable for offline developer workflows.
40+ *
41+ * The HTTP transport is abstracted through vix::net::http::Client.
42+ * By default, the provider creates a curl-backed HTTP client, but callers
43+ * may inject another implementation later without changing the provider API.
3844 */
3945 class OllamaProvider final : public ModelProvider
4046 {
4147 public:
4248 /* *
4349 * @brief Construct an Ollama provider from AgentConfig.
4450 *
51+ * The endpoint and default model are read from the agent configuration.
52+ * A default HTTP client is created automatically when none is injected.
53+ *
4554 * @param config Agent configuration.
4655 */
4756 explicit OllamaProvider (AgentConfig config);
4857
4958 /* *
5059 * @brief Construct an Ollama provider from endpoint and default model.
5160 *
61+ * A default HTTP client is created automatically when none is injected.
62+ *
5263 * @param endpoint Ollama server endpoint.
5364 * @param default_model Default model name.
5465 */
5566 OllamaProvider (std::string endpoint, std::string default_model);
5667
68+ /* *
69+ * @brief Construct an Ollama provider from AgentConfig and HTTP client.
70+ *
71+ * This overload allows tests or advanced users to inject a custom HTTP
72+ * client implementation.
73+ *
74+ * @param config Agent configuration.
75+ * @param http_client HTTP client used to send Ollama requests.
76+ */
77+ OllamaProvider (
78+ AgentConfig config,
79+ std::shared_ptr<vix::net::http::Client> http_client);
80+
81+ /* *
82+ * @brief Construct an Ollama provider from endpoint, model and HTTP client.
83+ *
84+ * This overload allows the provider to use a custom HTTP transport while
85+ * keeping the provider logic independent from the concrete backend.
86+ *
87+ * @param endpoint Ollama server endpoint.
88+ * @param default_model Default model name.
89+ * @param http_client HTTP client used to send Ollama requests.
90+ */
91+ OllamaProvider (
92+ std::string endpoint,
93+ std::string default_model,
94+ std::shared_ptr<vix::net::http::Client> http_client);
95+
5796 /* *
5897 * @brief Return provider name.
5998 */
@@ -91,6 +130,23 @@ namespace vix::ai::agent
91130 */
92131 [[nodiscard]] const std::string &default_model () const noexcept ;
93132
133+ /* *
134+ * @brief Return the HTTP client used by the provider.
135+ */
136+ [[nodiscard]] std::shared_ptr<vix::net::http::Client>
137+ http_client () const noexcept ;
138+
139+ /* *
140+ * @brief Replace the HTTP client used by the provider.
141+ *
142+ * If the provided client is null, the provider recreates its default
143+ * curl-backed HTTP client.
144+ *
145+ * @param client HTTP client implementation.
146+ */
147+ void set_http_client (
148+ std::shared_ptr<vix::net::http::Client> client);
149+
94150 private:
95151 /* *
96152 * @brief Build the effective model name for a request.
@@ -104,10 +160,16 @@ namespace vix::ai::agent
104160 [[nodiscard]] std::string effective_prompt (
105161 const ModelRequest &request) const ;
106162
163+ /* *
164+ * @brief Ensure the provider has a usable HTTP client.
165+ */
166+ void ensure_http_client ();
167+
107168 private:
108169 std::string endpoint_{" http://127.0.0.1:11434" };
109170 std::string default_model_{" llama3" };
110171 AgentConfig config_{};
172+ std::shared_ptr<vix::net::http::Client> http_client_{};
111173 };
112174
113175} // namespace vix::ai::agent
0 commit comments