intelligence-suite 0.2.2__tar.gz → 0.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/CodeIntelligence/rag_server.py +7 -1
  2. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/DocIntelligence/doc_server.py +7 -1
  3. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/MentorIntelligence/mentor_server.py +7 -1
  4. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/PKG-INFO +23 -1
  5. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/README.md +22 -0
  6. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_core/config.py +20 -0
  7. intelligence_suite-0.2.4/intelligence_core/llm/__init__.py +145 -0
  8. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_suite.egg-info/PKG-INFO +23 -1
  9. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/pyproject.toml +1 -1
  10. intelligence_suite-0.2.2/intelligence_core/llm/__init__.py +0 -65
  11. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/CodeIntelligence/__init__.py +0 -0
  12. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/CodeIntelligence/embed_chunks.py +0 -0
  13. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/CodeIntelligence/parse_repo.py +0 -0
  14. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/CodeIntelligence/parsers/__init__.py +0 -0
  15. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/CodeIntelligence/parsers/go_parser.py +0 -0
  16. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/CodeIntelligence/parsers/markdown_parser.py +0 -0
  17. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/CodeIntelligence/parsers/python_parser.py +0 -0
  18. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/CodeIntelligence/parsers/sql_parser.py +0 -0
  19. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/CodeIntelligence/parsers/typescript_parser.py +0 -0
  20. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/CodeIntelligence/parsers/yaml_parser.py +0 -0
  21. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/DocIntelligence/__init__.py +0 -0
  22. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/DocIntelligence/embed_docs.py +0 -0
  23. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/DocIntelligence/ingest_docs.py +0 -0
  24. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/DocIntelligence/parsers/__init__.py +0 -0
  25. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/DocIntelligence/parsers/docx_parser.py +0 -0
  26. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/DocIntelligence/parsers/markdown_parser.py +0 -0
  27. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/DocIntelligence/parsers/pdf_parser.py +0 -0
  28. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/DocIntelligence/parsers/txt_parser.py +0 -0
  29. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/DocIntelligence/parsers/xlsx_parser.py +0 -0
  30. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/LICENSE +0 -0
  31. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/MentorIntelligence/__init__.py +0 -0
  32. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/MentorIntelligence/content/__init__.py +0 -0
  33. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/MentorIntelligence/content/ingest_practices.py +0 -0
  34. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/MentorIntelligence/orchestrator.py +0 -0
  35. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/MentorIntelligence/path_builder.py +0 -0
  36. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/MentorIntelligence/profile_detector.py +0 -0
  37. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/MentorIntelligence/session_manager.py +0 -0
  38. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_core/__init__.py +0 -0
  39. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_core/chunk.py +0 -0
  40. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_core/embedder.py +0 -0
  41. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_core/escalation.py +0 -0
  42. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_core/llm/claude.py +0 -0
  43. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_core/llm/ollama.py +0 -0
  44. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_core/llm/openai_compat.py +0 -0
  45. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_core/llm/protocol.py +0 -0
  46. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_core/retriever.py +0 -0
  47. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_core/server_base.py +0 -0
  48. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_core/store.py +0 -0
  49. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_suite.egg-info/SOURCES.txt +0 -0
  50. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_suite.egg-info/dependency_links.txt +0 -0
  51. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_suite.egg-info/entry_points.txt +0 -0
  52. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_suite.egg-info/requires.txt +0 -0
  53. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_suite.egg-info/top_level.txt +0 -0
  54. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_ui/__init__.py +0 -0
  55. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_ui/chat_app.py +0 -0
  56. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/intelligence_ui/templates.py +0 -0
  57. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/setup.cfg +0 -0
  58. {intelligence_suite-0.2.2 → intelligence_suite-0.2.4}/tests/test_intelligence_suite.py +0 -0
@@ -8,12 +8,18 @@ from intelligence_core.embedder import get_embedder
8
8
  from intelligence_core.store import ChromaStore
9
9
  from intelligence_core.server_base import create_app
10
10
  from intelligence_core.config import settings
11
+ from intelligence_core.llm import get_module_llm_provider
11
12
 
12
13
 
13
14
  def build_app():
14
15
  store = ChromaStore(collection_name="code_intelligence")
15
16
  retriever = Retriever(embedder=get_embedder(), store=store)
16
- return create_app(title="CodeIntelligence RAG Server", retriever=retriever, module="code")
17
+ return create_app(
18
+ title="CodeIntelligence RAG Server",
19
+ retriever=retriever,
20
+ module="code",
21
+ llm_provider=get_module_llm_provider("ci"),
22
+ )
17
23
 
18
24
 
19
25
  app = build_app()
@@ -8,12 +8,18 @@ from intelligence_core.store import ChromaStore
8
8
  from intelligence_core.embedder import get_embedder
9
9
  from intelligence_core.server_base import create_app
10
10
  from intelligence_core.config import settings
11
+ from intelligence_core.llm import get_module_llm_provider
11
12
 
12
13
 
13
14
  def build_app():
14
15
  store = ChromaStore(collection_name="doc_intelligence")
15
16
  retriever = Retriever(embedder=get_embedder(), store=store)
16
- return create_app(title="DocIntelligence RAG Server", retriever=retriever, module="doc")
17
+ return create_app(
18
+ title="DocIntelligence RAG Server",
19
+ retriever=retriever,
20
+ module="doc",
21
+ llm_provider=get_module_llm_provider("di"),
22
+ )
17
23
 
18
24
 
19
25
  app = build_app()
@@ -86,7 +86,13 @@ def build_app() -> FastAPI:
86
86
  orchestrator = MentorOrchestrator(code_retriever, doc_retriever, mentor_retriever)
87
87
 
88
88
  base_retriever = Retriever(embedder=embedder, store=ChromaStore("mentor_intelligence"))
89
- app = create_app(title="MentorIntelligence Server", retriever=base_retriever, module="mentor")
89
+ from intelligence_core.llm import get_module_llm_provider
90
+ app = create_app(
91
+ title="MentorIntelligence Server",
92
+ retriever=base_retriever,
93
+ module="mentor",
94
+ llm_provider=get_module_llm_provider("mi"),
95
+ )
90
96
 
91
97
  @app.post("/api/v1/mentor/onboard", response_model=OnboardResponse)
92
98
  def onboard(req: OnboardRequest):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: intelligence-suite
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Modular knowledge retrieval suite: code, docs, APIs — all on-premise
5
5
  Author-email: ViciusLio <viciuslios@gmail.com>
6
6
  License-Expression: MIT
@@ -654,6 +654,28 @@ Switch backend with a single env var — no code changes required.
654
654
  > Any OpenAI-compatible server works with `LLM_BACKEND=openai` or `vllm` by pointing
655
655
  > `OPENAI_BASE_URL` at the correct endpoint.
656
656
 
657
+ ### Per-module LLM routing
658
+
659
+ Each module can use a **different LLM backend and model** independently.
660
+ Set any combination of `CI_LLM_*`, `DI_LLM_*`, `MI_LLM_*` in `.env` — leave empty to fall back to the global `LLM_BACKEND`:
661
+
662
+ ```env
663
+ # CodeIntelligence → vLLM GPU server with code-specialised model
664
+ CI_LLM_BACKEND=openai
665
+ CI_LLM_MODEL=codellama:34b
666
+ CI_LLM_BASE_URL=http://gpu-server:8000/v1
667
+
668
+ # DocIntelligence → local Mistral (better multilingual / Italian)
669
+ DI_LLM_BACKEND=ollama
670
+ DI_LLM_MODEL=mistral:7b
671
+
672
+ # MentorIntelligence → Claude API (best pedagogical quality)
673
+ MI_LLM_BACKEND=claude
674
+ MI_LLM_MODEL=claude-sonnet-4-5
675
+ ```
676
+
677
+ Any OpenAI-compatible endpoint (vLLM, Groq, Mistral AI, LM Studio, Azure…) works by setting `*_LLM_BACKEND=openai` and `*_LLM_BASE_URL` to the endpoint.
678
+
657
679
  ### Escalation
658
680
 
659
681
  When retrieval confidence < `ESCALATION_THRESHOLD` and `ANTHROPIC_API_KEY` is set,
@@ -595,6 +595,28 @@ Switch backend with a single env var — no code changes required.
595
595
  > Any OpenAI-compatible server works with `LLM_BACKEND=openai` or `vllm` by pointing
596
596
  > `OPENAI_BASE_URL` at the correct endpoint.
597
597
 
598
+ ### Per-module LLM routing
599
+
600
+ Each module can use a **different LLM backend and model** independently.
601
+ Set any combination of `CI_LLM_*`, `DI_LLM_*`, `MI_LLM_*` in `.env` — leave empty to fall back to the global `LLM_BACKEND`:
602
+
603
+ ```env
604
+ # CodeIntelligence → vLLM GPU server with code-specialised model
605
+ CI_LLM_BACKEND=openai
606
+ CI_LLM_MODEL=codellama:34b
607
+ CI_LLM_BASE_URL=http://gpu-server:8000/v1
608
+
609
+ # DocIntelligence → local Mistral (better multilingual / Italian)
610
+ DI_LLM_BACKEND=ollama
611
+ DI_LLM_MODEL=mistral:7b
612
+
613
+ # MentorIntelligence → Claude API (best pedagogical quality)
614
+ MI_LLM_BACKEND=claude
615
+ MI_LLM_MODEL=claude-sonnet-4-5
616
+ ```
617
+
618
+ Any OpenAI-compatible endpoint (vLLM, Groq, Mistral AI, LM Studio, Azure…) works by setting `*_LLM_BACKEND=openai` and `*_LLM_BASE_URL` to the endpoint.
619
+
598
620
  ### Escalation
599
621
 
600
622
  When retrieval confidence < `ESCALATION_THRESHOLD` and `ANTHROPIC_API_KEY` is set,
@@ -56,6 +56,26 @@ class Settings(BaseSettings):
56
56
  """Expand ~ and resolve to an absolute path so CWD never matters."""
57
57
  return str(Path(v).expanduser().resolve())
58
58
 
59
+ # ── Per-module LLM overrides ───────────────────────────────────────────────
60
+ # Leave empty to use the global LLM_BACKEND / OLLAMA_MODEL / OPENAI_* settings.
61
+ # Set any combination to route a specific module to a different backend or model.
62
+ #
63
+ # CodeIntelligence (CI_LLM_*)
64
+ ci_llm_backend: str = "" # e.g. "ollama" | "openai" | "vllm" | "claude"
65
+ ci_llm_model: str = "" # e.g. "qwen2.5-coder:7b"
66
+ ci_llm_base_url: str = "" # e.g. "http://gpu-server:8000/v1"
67
+ ci_llm_api_key: str = ""
68
+ # DocIntelligence (DI_LLM_*)
69
+ di_llm_backend: str = "" # e.g. "ollama" | "openai" | "claude"
70
+ di_llm_model: str = "" # e.g. "mistral:7b"
71
+ di_llm_base_url: str = ""
72
+ di_llm_api_key: str = ""
73
+ # MentorIntelligence (MI_LLM_*)
74
+ mi_llm_backend: str = "" # e.g. "claude"
75
+ mi_llm_model: str = "" # e.g. "claude-sonnet-4-5"
76
+ mi_llm_base_url: str = ""
77
+ mi_llm_api_key: str = ""
78
+
59
79
  # ── Server ports (one per module, avoids conflicts when running together) ──
60
80
  ci_port: int = 8080 # CodeIntelligence
61
81
  di_port: int = 8081 # DocIntelligence
@@ -0,0 +1,145 @@
1
+ """LLM provider factory for Intelligence Suite.
2
+
3
+ Supported backends
4
+ ------------------
5
+ ollama Local Ollama server (default, zero cost, no API key)
6
+ openai OpenAI Chat Completions API
7
+ vllm vLLM local GPU server (OpenAI-compatible)
8
+ claude Anthropic Claude API
9
+
10
+ Any other OpenAI-compatible server (Groq, Mistral AI, LM Studio, Together AI, …)
11
+ can be used with ``LLM_BACKEND=openai`` by changing ``OPENAI_BASE_URL``.
12
+
13
+ Per-module routing
14
+ ------------------
15
+ Each module can override the global backend/model independently:
16
+
17
+ CI_LLM_BACKEND=openai CI_LLM_MODEL=codellama:34b
18
+ CI_LLM_BASE_URL=http://gpu:8000/v1
19
+
20
+ DI_LLM_BACKEND=ollama DI_LLM_MODEL=mistral:7b
21
+
22
+ MI_LLM_BACKEND=claude MI_LLM_MODEL=claude-sonnet-4-5
23
+
24
+ Leave any variable empty to fall back to the global LLM_BACKEND settings.
25
+
26
+ Usage
27
+ -----
28
+ from intelligence_core.llm import get_llm_provider, get_module_llm_provider
29
+
30
+ llm = get_llm_provider() # global settings
31
+ llm = get_module_llm_provider("ci") # CodeIntelligence — with per-module override
32
+ llm = get_module_llm_provider("di") # DocIntelligence
33
+ llm = get_module_llm_provider("mi") # MentorIntelligence
34
+ """
35
+
36
+ from __future__ import annotations
37
+ import logging
38
+
39
+ from intelligence_core.llm.protocol import LLMProvider, SYSTEM_PROMPT_DEFAULT
40
+
41
+ logger = logging.getLogger(__name__)
42
+
43
+
44
+ def get_llm_provider(
45
+ backend: str | None = None,
46
+ *,
47
+ model: str | None = None,
48
+ base_url: str | None = None,
49
+ api_key: str | None = None,
50
+ ) -> LLMProvider:
51
+ """
52
+ Factory: return the configured LLM provider.
53
+
54
+ Args:
55
+ backend: Override ``LLM_BACKEND`` from settings.
56
+ Values: ``"ollama"`` | ``"openai"`` | ``"vllm"`` | ``"claude"``
57
+ model: Override the model name (OLLAMA_MODEL / OPENAI_MODEL / CLAUDE_MODEL).
58
+ base_url: Override the API base URL (OPENAI_BASE_URL / OLLAMA_BASE_URL).
59
+ api_key: Override the API key (OPENAI_API_KEY / ANTHROPIC_API_KEY).
60
+
61
+ Returns:
62
+ An object satisfying the :class:`LLMProvider` protocol.
63
+ """
64
+ from intelligence_core.config import settings
65
+
66
+ _backend = backend or settings.llm_backend
67
+
68
+ if _backend in ("openai", "vllm"):
69
+ from intelligence_core.llm.openai_compat import OpenAICompatProvider
70
+ return OpenAICompatProvider(
71
+ base_url=base_url or settings.openai_base_url,
72
+ api_key=api_key or settings.openai_api_key,
73
+ model=model or settings.openai_model,
74
+ backend_hint=_backend,
75
+ )
76
+
77
+ if _backend == "claude":
78
+ from intelligence_core.llm.claude import ClaudeProvider
79
+ return ClaudeProvider(
80
+ api_key=api_key or settings.anthropic_api_key,
81
+ model=model or settings.claude_model,
82
+ )
83
+
84
+ # default: ollama
85
+ from intelligence_core.llm.ollama import OllamaProvider
86
+ return OllamaProvider(
87
+ base_url=base_url or settings.ollama_base_url,
88
+ model=model or settings.ollama_model,
89
+ )
90
+
91
+
92
+ def get_module_llm_provider(module: str) -> LLMProvider:
93
+ """
94
+ Get the LLM provider for a specific module, applying per-module env overrides.
95
+
96
+ Module prefixes
97
+ ---------------
98
+ "ci" → CodeIntelligence (CI_LLM_BACKEND, CI_LLM_MODEL, CI_LLM_BASE_URL, CI_LLM_API_KEY)
99
+ "di" → DocIntelligence (DI_LLM_BACKEND, DI_LLM_MODEL, DI_LLM_BASE_URL, DI_LLM_API_KEY)
100
+ "mi" → MentorIntelligence (MI_LLM_BACKEND, MI_LLM_MODEL, MI_LLM_BASE_URL, MI_LLM_API_KEY)
101
+
102
+ Any variable left empty falls back to the global LLM_BACKEND / model / URL / key.
103
+
104
+ Example .env
105
+ ------------
106
+ # Route CodeIntelligence to a vLLM GPU server
107
+ CI_LLM_BACKEND=openai
108
+ CI_LLM_MODEL=codellama:34b
109
+ CI_LLM_BASE_URL=http://gpu-server:8000/v1
110
+
111
+ # Route DocIntelligence to a local Mistral (better multilingual)
112
+ DI_LLM_BACKEND=ollama
113
+ DI_LLM_MODEL=mistral:7b
114
+
115
+ # Route MentorIntelligence to Claude (best pedagogical quality)
116
+ MI_LLM_BACKEND=claude
117
+ MI_LLM_MODEL=claude-sonnet-4-5
118
+ """
119
+ from intelligence_core.config import settings
120
+
121
+ prefix = module.lower() # "ci", "di", "mi"
122
+
123
+ backend = getattr(settings, f"{prefix}_llm_backend", "") or None
124
+ model = getattr(settings, f"{prefix}_llm_model", "") or None
125
+ base_url = getattr(settings, f"{prefix}_llm_base_url", "") or None
126
+ api_key = getattr(settings, f"{prefix}_llm_api_key", "") or None
127
+
128
+ if any([backend, model, base_url, api_key]):
129
+ logger.info(
130
+ "Module [%s] LLM override → backend=%s model=%s base_url=%s",
131
+ module.upper(),
132
+ backend or "(global)",
133
+ model or "(global)",
134
+ base_url or "(global)",
135
+ )
136
+
137
+ return get_llm_provider(backend, model=model, base_url=base_url, api_key=api_key)
138
+
139
+
140
+ __all__ = [
141
+ "LLMProvider",
142
+ "SYSTEM_PROMPT_DEFAULT",
143
+ "get_llm_provider",
144
+ "get_module_llm_provider",
145
+ ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: intelligence-suite
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Modular knowledge retrieval suite: code, docs, APIs — all on-premise
5
5
  Author-email: ViciusLio <viciuslios@gmail.com>
6
6
  License-Expression: MIT
@@ -654,6 +654,28 @@ Switch backend with a single env var — no code changes required.
654
654
  > Any OpenAI-compatible server works with `LLM_BACKEND=openai` or `vllm` by pointing
655
655
  > `OPENAI_BASE_URL` at the correct endpoint.
656
656
 
657
+ ### Per-module LLM routing
658
+
659
+ Each module can use a **different LLM backend and model** independently.
660
+ Set any combination of `CI_LLM_*`, `DI_LLM_*`, `MI_LLM_*` in `.env` — leave empty to fall back to the global `LLM_BACKEND`:
661
+
662
+ ```env
663
+ # CodeIntelligence → vLLM GPU server with code-specialised model
664
+ CI_LLM_BACKEND=openai
665
+ CI_LLM_MODEL=codellama:34b
666
+ CI_LLM_BASE_URL=http://gpu-server:8000/v1
667
+
668
+ # DocIntelligence → local Mistral (better multilingual / Italian)
669
+ DI_LLM_BACKEND=ollama
670
+ DI_LLM_MODEL=mistral:7b
671
+
672
+ # MentorIntelligence → Claude API (best pedagogical quality)
673
+ MI_LLM_BACKEND=claude
674
+ MI_LLM_MODEL=claude-sonnet-4-5
675
+ ```
676
+
677
+ Any OpenAI-compatible endpoint (vLLM, Groq, Mistral AI, LM Studio, Azure…) works by setting `*_LLM_BACKEND=openai` and `*_LLM_BASE_URL` to the endpoint.
678
+
657
679
  ### Escalation
658
680
 
659
681
  When retrieval confidence < `ESCALATION_THRESHOLD` and `ANTHROPIC_API_KEY` is set,
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "intelligence-suite"
7
- version = "0.2.2"
7
+ version = "0.2.4"
8
8
  description = "Modular knowledge retrieval suite: code, docs, APIs — all on-premise"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -1,65 +0,0 @@
1
- """LLM provider factory for Intelligence Suite.
2
-
3
- Supported backends
4
- ------------------
5
- ollama Local Ollama server (default, zero cost, no API key)
6
- openai OpenAI Chat Completions API
7
- vllm vLLM local GPU server (OpenAI-compatible)
8
- claude Anthropic Claude API
9
-
10
- Any other OpenAI-compatible server (Groq, Mistral AI, LM Studio, Together AI, …)
11
- can be used with ``LLM_BACKEND=openai`` by changing ``OPENAI_BASE_URL``.
12
-
13
- Usage
14
- -----
15
- from intelligence_core.llm import get_llm_provider
16
-
17
- llm = get_llm_provider() # reads LLM_BACKEND from .env
18
- answer = llm.generate(question, context)
19
- """
20
-
21
- from __future__ import annotations
22
-
23
- from intelligence_core.llm.protocol import LLMProvider, SYSTEM_PROMPT_DEFAULT
24
-
25
-
26
- def get_llm_provider(backend: str | None = None) -> LLMProvider:
27
- """
28
- Factory: return the configured LLM provider.
29
-
30
- Args:
31
- backend: Override ``LLM_BACKEND`` from settings.
32
- Values: ``"ollama"`` | ``"openai"`` | ``"vllm"`` | ``"claude"``
33
-
34
- Returns:
35
- An object satisfying the :class:`LLMProvider` protocol.
36
- """
37
- from intelligence_core.config import settings
38
-
39
- _backend = backend or settings.llm_backend
40
-
41
- if _backend in ("openai", "vllm"):
42
- from intelligence_core.llm.openai_compat import OpenAICompatProvider
43
- return OpenAICompatProvider(
44
- base_url=settings.openai_base_url,
45
- api_key=settings.openai_api_key,
46
- model=settings.openai_model,
47
- backend_hint=_backend,
48
- )
49
-
50
- if _backend == "claude":
51
- from intelligence_core.llm.claude import ClaudeProvider
52
- return ClaudeProvider(
53
- api_key=settings.anthropic_api_key,
54
- model=settings.claude_model,
55
- )
56
-
57
- # default: ollama
58
- from intelligence_core.llm.ollama import OllamaProvider
59
- return OllamaProvider(
60
- base_url=settings.ollama_base_url,
61
- model=settings.ollama_model,
62
- )
63
-
64
-
65
- __all__ = ["LLMProvider", "SYSTEM_PROMPT_DEFAULT", "get_llm_provider"]