ragit 0.3__py3-none-any.whl → 0.10.1__py3-none-any.whl

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.
ragit/__init__.py CHANGED
@@ -1,2 +1,128 @@
1
- # __init__.py
2
- from .main import VectorDBManager
1
+ #
2
+ # Copyright RODMENA LIMITED 2025
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ #
5
+ """
6
+ Ragit - RAG toolkit for document Q&A and hyperparameter optimization.
7
+
8
+ Quick Start
9
+ -----------
10
+ >>> from ragit import RAGAssistant
11
+ >>>
12
+ >>> # With custom embedding function (retrieval-only)
13
+ >>> def my_embed(text: str) -> list[float]:
14
+ ... # Your embedding implementation
15
+ ... pass
16
+ >>> assistant = RAGAssistant("docs/", embed_fn=my_embed)
17
+ >>> results = assistant.retrieve("How do I create a REST API?")
18
+ >>>
19
+ >>> # With Ollama
20
+ >>> from ragit.providers import OllamaProvider
21
+ >>> assistant = RAGAssistant("docs/", provider=OllamaProvider())
22
+ >>> answer = assistant.ask("How do I create a REST API?")
23
+
24
+ Optimization
25
+ ------------
26
+ >>> from ragit import RagitExperiment, Document, BenchmarkQuestion
27
+ >>>
28
+ >>> docs = [Document(id="doc1", content="...")]
29
+ >>> benchmark = [BenchmarkQuestion(question="What is X?", ground_truth="...")]
30
+ >>>
31
+ >>> # With explicit provider
32
+ >>> experiment = RagitExperiment(docs, benchmark, provider=OllamaProvider())
33
+ >>> results = experiment.run()
34
+ >>> print(results[0]) # Best configuration
35
+ """
36
+
37
+ import logging
38
+ import os
39
+
40
+ from ragit.version import __version__
41
+
42
+ # Set up logging
43
+ logger = logging.getLogger("ragit")
44
+ logger.setLevel(os.getenv("RAGIT_LOG_LEVEL", "INFO"))
45
+
46
+ if not logger.handlers:
47
+ formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
48
+ handler = logging.StreamHandler()
49
+ handler.setFormatter(formatter)
50
+ logger.addHandler(handler)
51
+
52
+ # Public API (imports after logging setup)
53
+ from ragit.assistant import RAGAssistant # noqa: E402
54
+ from ragit.core.experiment.experiment import ( # noqa: E402
55
+ BenchmarkQuestion,
56
+ Chunk,
57
+ Document,
58
+ RAGConfig,
59
+ RagitExperiment,
60
+ )
61
+ from ragit.core.experiment.results import EvaluationResult, ExperimentResults # noqa: E402
62
+ from ragit.exceptions import ( # noqa: E402
63
+ ConfigurationError,
64
+ EvaluationError,
65
+ ExceptionAggregator,
66
+ GenerationError,
67
+ IndexingError,
68
+ ProviderError,
69
+ RagitError,
70
+ RetrievalError,
71
+ )
72
+ from ragit.loaders import ( # noqa: E402
73
+ chunk_by_separator,
74
+ chunk_document,
75
+ chunk_rst_sections,
76
+ chunk_text,
77
+ deduplicate_documents,
78
+ generate_document_id,
79
+ load_directory,
80
+ load_text,
81
+ )
82
+ from ragit.monitor import ExecutionMonitor # noqa: E402
83
+ from ragit.providers import ( # noqa: E402
84
+ BaseEmbeddingProvider,
85
+ BaseLLMProvider,
86
+ FunctionProvider,
87
+ OllamaProvider,
88
+ )
89
+
90
+ __all__ = [
91
+ "__version__",
92
+ # High-level API
93
+ "RAGAssistant",
94
+ # Document loading
95
+ "load_text",
96
+ "load_directory",
97
+ "chunk_text",
98
+ "chunk_document",
99
+ "chunk_by_separator",
100
+ "chunk_rst_sections",
101
+ "generate_document_id",
102
+ "deduplicate_documents",
103
+ # Core classes
104
+ "Document",
105
+ "Chunk",
106
+ # Providers
107
+ "OllamaProvider",
108
+ "FunctionProvider",
109
+ "BaseLLMProvider",
110
+ "BaseEmbeddingProvider",
111
+ # Exceptions
112
+ "RagitError",
113
+ "ConfigurationError",
114
+ "ProviderError",
115
+ "IndexingError",
116
+ "RetrievalError",
117
+ "GenerationError",
118
+ "EvaluationError",
119
+ "ExceptionAggregator",
120
+ # Monitoring
121
+ "ExecutionMonitor",
122
+ # Optimization
123
+ "RagitExperiment",
124
+ "BenchmarkQuestion",
125
+ "RAGConfig",
126
+ "EvaluationResult",
127
+ "ExperimentResults",
128
+ ]