chATLAS_Chains 0.1.4__tar.gz → 0.1.5__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 (39) hide show
  1. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/PKG-INFO +5 -1
  2. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/README.md +4 -0
  3. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/chains/advanced.py +10 -2
  4. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/chains/basic.py +8 -1
  5. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/llm/model_selection.py +2 -2
  6. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains.egg-info/PKG-INFO +5 -1
  7. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/pyproject.toml +1 -1
  8. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/tests/test_chains.py +28 -13
  9. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/LICENSE +0 -0
  10. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/__init__.py +0 -0
  11. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/chains/__init__.py +0 -0
  12. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/chains/basic_graph.py +0 -0
  13. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/chains/enhanced_agentic_graph.py +0 -0
  14. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/chains/websearch_retrieval_chain.py +0 -0
  15. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/documents/rerank.py +0 -0
  16. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/documents/rrf.py +0 -0
  17. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/llm/__init__.py +0 -0
  18. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/llm/groq.py +0 -0
  19. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/log.py +0 -0
  20. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/prompt/__init__.py +0 -0
  21. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/prompt/doc_joiners.py +0 -0
  22. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/prompt/starters.py +0 -0
  23. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/query/query_rewriting.py +0 -0
  24. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/search/__init__.py +0 -0
  25. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/search/basic.py +0 -0
  26. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/utils/__init__.py +0 -0
  27. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/utils/doc_utils.py +0 -0
  28. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains/vectorstore.py +0 -0
  29. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains.egg-info/SOURCES.txt +0 -0
  30. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains.egg-info/dependency_links.txt +0 -0
  31. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains.egg-info/requires.txt +0 -0
  32. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/chATLAS_Chains.egg-info/top_level.txt +0 -0
  33. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/setup.cfg +0 -0
  34. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/tests/__init__.py +0 -0
  35. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/tests/conftest.py +0 -0
  36. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/tests/test_groq.py +0 -0
  37. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/tests/test_llm.py +0 -0
  38. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/tests/test_search.py +0 -0
  39. {chatlas_chains-0.1.4 → chatlas_chains-0.1.5}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chATLAS_Chains
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: A modular Python package for implementing Retrieval Augmented Generation chains for the chATLAS project.
5
5
  Author-email: Joe Egan <joseph.caimin.egan@cern.ch>
6
6
  License: Apache-2.0
@@ -91,6 +91,10 @@ CREATE EXTENSION IF NOT EXISTS vector;
91
91
  ```
92
92
  ## CHANGELOG
93
93
 
94
+ #### 0.1.5
95
+
96
+ Fix missing `retry_config` argument in `advanced_rag` caused by early PyPI upload
97
+
94
98
  #### 0.1.4
95
99
 
96
100
  Support for Groq-hosted models
@@ -65,6 +65,10 @@ CREATE EXTENSION IF NOT EXISTS vector;
65
65
  ```
66
66
  ## CHANGELOG
67
67
 
68
+ #### 0.1.5
69
+
70
+ Fix missing `retry_config` argument in `advanced_rag` caused by early PyPI upload
71
+
68
72
  #### 0.1.4
69
73
 
70
74
  Support for Groq-hosted models
@@ -22,6 +22,7 @@ from langgraph.graph.state import CompiledStateGraph
22
22
 
23
23
  from chATLAS_Chains.documents.rerank import rerank_documents
24
24
  from chATLAS_Chains.documents.rrf import reciprocal_rank_fusion, split_docs_by_retriever
25
+ from chATLAS_Chains.llm.groq import RetryConfig
25
26
  from chATLAS_Chains.llm.model_selection import GROQ_PRODUCTION_MODELS, get_chat_model
26
27
  from chATLAS_Chains.prompt.starters import CHAT_PROMPT_TEMPLATE
27
28
  from chATLAS_Chains.query.query_rewriting import rewrite_query
@@ -55,6 +56,7 @@ def advanced_rag(
55
56
  pinecone_api_key: str | None = None,
56
57
  rrf_constant: float = 60.0,
57
58
  rrf_weights: dict[str, float] | None = None,
59
+ retry_config: RetryConfig | None = None,
58
60
  ) -> CompiledStateGraph:
59
61
  """
60
62
  Advanced Agentic RAG graph with optional query rewriting, dual-stage reranking and self-evaluation.
@@ -73,7 +75,8 @@ def advanced_rag(
73
75
  :param rerank_model: Name of the Pinecone reranker model to use.
74
76
  :param pinecone_api_key: Pinecone API key. If None, will use PINECONE_API_KEY environment variable.
75
77
  :param rrf_constant: Constant to use for RRF (Reciprocal Rank Fusion) calculations.
76
- :rrf_weights: How to weight the RRF score for each retriever. Default is 1.0 for all.
78
+ :param rrf_weights: How to weight the RRF score for each retriever. Default is 1.0 for all.
79
+ :param retry_config: Optional RetryConfig for Groq API calls
77
80
 
78
81
  :return: A compiled LangGraph with the chosen features
79
82
 
@@ -88,7 +91,7 @@ def advanced_rag(
88
91
  searcher = search_runnable(vectorstore)
89
92
 
90
93
  # Initialise models
91
- model = get_chat_model(model_name, max_tokens, temperature, use_preview_models)
94
+ model = get_chat_model(model_name, max_tokens, temperature, use_preview_models, retry_config)
92
95
 
93
96
  if enable_query_rewriting:
94
97
  query_rewriting_model_instance = get_chat_model(
@@ -264,6 +267,11 @@ if __name__ == "__main__":
264
267
 
265
268
  twiki = get_vectorstore("twiki_prod")
266
269
 
270
+ retry_config = RetryConfig(
271
+ max_retries=1,
272
+ max_delay=120.0,
273
+ )
274
+
267
275
  # Create the hybrid graph
268
276
  graph = advanced_rag(
269
277
  vectorstore=[twiki],
@@ -4,6 +4,7 @@ from typing import Optional
4
4
  from langchain_core.prompts import ChatPromptTemplate
5
5
  from langchain_core.runnables import RunnableSerializable
6
6
 
7
+ from chATLAS_Chains.llm.groq import RetryConfig
7
8
  from chATLAS_Chains.llm.model_selection import get_chat_model
8
9
  from chATLAS_Chains.search.basic import search_runnable
9
10
  from chATLAS_Chains.utils.doc_utils import combine_documents
@@ -16,6 +17,8 @@ def basic_retrieval_chain(
16
17
  model_name: str,
17
18
  max_tokens: int | None = None,
18
19
  temperature: float | None = None,
20
+ use_preview_models: bool = False,
21
+ retry_config: RetryConfig | None = None,
19
22
  ) -> RunnableSerializable:
20
23
  """
21
24
  Baseline RAG retrieval chain. Searches one or several vectorstores in parallel, passes retrieved documents to the model
@@ -30,13 +33,17 @@ def basic_retrieval_chain(
30
33
  :type max_tokens: int | None
31
34
  :param temperature: The temperature to use for the model's response generation. Defaults to None.
32
35
  :type temperature: float | None
36
+ :param use_preview_models: Whether to allow the use of preview models from Groq. Defaults to False.
37
+ :type use_preview_models: bool
38
+ :param retry_config: Configuration for retrying requests to the model in case of failures. Defaults to None, which will use the default retry configuration.
39
+ :type retry_config: RetryConfig | None
33
40
 
34
41
  :return: A LangChain RunnableSerializable chain that performs retrieval and response generation.
35
42
  :rtype: RunnableSerializable
36
43
 
37
44
  """
38
45
  prompt_template = ChatPromptTemplate.from_template(prompt)
39
- model = get_chat_model(model_name, max_tokens, temperature)
46
+ model = get_chat_model(model_name, max_tokens, temperature, use_preview_models, retry_config)
40
47
 
41
48
  search = search_runnable(vectorstore)
42
49
 
@@ -26,8 +26,8 @@ GROQ_PREVIEW_MODELS = [
26
26
  "meta-llama/llama-prompt-guard-2-22m",
27
27
  "meta-llama/llama-prompt-guard-2-86m",
28
28
  "moonshotai/kimi-k2-instruct",
29
- # "playai-tts", # text to audio model
30
- # "playai-tts-arabic", # text to audio model
29
+ # "playai-tts", # text to audio model
30
+ # "playai-tts-arabic", # text to audio model
31
31
  "qwen/qwen3-32b",
32
32
  "gemma2-9b-it",
33
33
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chATLAS_Chains
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: A modular Python package for implementing Retrieval Augmented Generation chains for the chATLAS project.
5
5
  Author-email: Joe Egan <joseph.caimin.egan@cern.ch>
6
6
  License: Apache-2.0
@@ -91,6 +91,10 @@ CREATE EXTENSION IF NOT EXISTS vector;
91
91
  ```
92
92
  ## CHANGELOG
93
93
 
94
+ #### 0.1.5
95
+
96
+ Fix missing `retry_config` argument in `advanced_rag` caused by early PyPI upload
97
+
94
98
  #### 0.1.4
95
99
 
96
100
  Support for Groq-hosted models
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "chATLAS_Chains"
7
- version = "0.1.4"
7
+ version = "0.1.5"
8
8
  description = "A modular Python package for implementing Retrieval Augmented Generation chains for the chATLAS project."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -13,16 +13,19 @@ from pydantic import ValidationError
13
13
 
14
14
  from chATLAS_Chains.chains.advanced import advanced_rag
15
15
  from chATLAS_Chains.chains.basic import basic_retrieval_chain
16
+ from chATLAS_Chains.llm.groq import RetryConfig
16
17
  from chATLAS_Chains.llm.model_selection import GROQ_PRODUCTION_MODELS
17
18
  from chATLAS_Chains.prompt.starters import CHAT_PROMPT_TEMPLATE
18
19
  from chATLAS_Chains.vectorstore import get_vectorstore
19
20
 
20
21
 
21
- def test_basic_retrieval_chain_returns_runnablesequence(twiki_vectorstore):
22
- """
23
- Test the search_runnable function with a populated vector store.
24
- """
22
+ @pytest.fixture
23
+ def retry_config():
24
+ """Retry config to use in tests"""
25
+ return RetryConfig(max_retries=2, max_delay=120.0)
26
+
25
27
 
28
+ def test_basic_retrieval_chain_returns_runnablesequence(twiki_vectorstore):
26
29
  chain = basic_retrieval_chain(prompt=CHAT_PROMPT_TEMPLATE, vectorstore=twiki_vectorstore, model_name="gpt-4o-mini")
27
30
 
28
31
  assert isinstance(chain, RunnableSequence)
@@ -30,7 +33,7 @@ def test_basic_retrieval_chain_returns_runnablesequence(twiki_vectorstore):
30
33
 
31
34
  def test_search_runnable_returns_runnablesequence_with_list_of_vectorstores(three_vectorstores):
32
35
  chain = basic_retrieval_chain(prompt=CHAT_PROMPT_TEMPLATE, vectorstore=three_vectorstores, model_name="gpt-4o-mini")
33
- print(type(chain))
36
+
34
37
  assert isinstance(chain, RunnableSequence)
35
38
 
36
39
 
@@ -43,9 +46,12 @@ def test_search_runnable_error_on_invalid_input():
43
46
  )
44
47
 
45
48
 
46
- def test_basic_retrieval_chain_returns_docs_and_answer(twiki_vectorstore):
49
+ def test_basic_retrieval_chain_returns_docs_and_answer(twiki_vectorstore, retry_config):
47
50
  chain = basic_retrieval_chain(
48
- prompt=CHAT_PROMPT_TEMPLATE, vectorstore=twiki_vectorstore, model_name=GROQ_PRODUCTION_MODELS[0]
51
+ prompt=CHAT_PROMPT_TEMPLATE,
52
+ vectorstore=twiki_vectorstore,
53
+ model_name=GROQ_PRODUCTION_MODELS[0],
54
+ retry_config=retry_config,
49
55
  )
50
56
  output = chain.invoke("What is the Higgs boson?")
51
57
 
@@ -55,9 +61,12 @@ def test_basic_retrieval_chain_returns_docs_and_answer(twiki_vectorstore):
55
61
  assert isinstance(output["docs"], list)
56
62
 
57
63
 
58
- def test_basic_retrieval_chain_multiple_vectorstores(three_vectorstores):
64
+ def test_basic_retrieval_chain_multiple_vectorstores(three_vectorstores, retry_config):
59
65
  chain = basic_retrieval_chain(
60
- prompt=CHAT_PROMPT_TEMPLATE, vectorstore=three_vectorstores, model_name=GROQ_PRODUCTION_MODELS[0]
66
+ prompt=CHAT_PROMPT_TEMPLATE,
67
+ vectorstore=three_vectorstores,
68
+ model_name=GROQ_PRODUCTION_MODELS[0],
69
+ retry_config=retry_config,
61
70
  )
62
71
  output = chain.invoke("What is the Higgs boson?")
63
72
 
@@ -73,7 +82,7 @@ def test_basic_retrieval_chain_multiple_vectorstores(three_vectorstores):
73
82
  )
74
83
 
75
84
 
76
- def test_advanced_rag_chain(twiki_vectorstore):
85
+ def test_advanced_rag_chain(twiki_vectorstore, retry_config):
77
86
  # TODO: this is required currently requried for search to work
78
87
  search_kwargs = {
79
88
  "k_text": 3,
@@ -83,7 +92,10 @@ def test_advanced_rag_chain(twiki_vectorstore):
83
92
  }
84
93
 
85
94
  chain = advanced_rag(
86
- prompt=CHAT_PROMPT_TEMPLATE, vectorstore=twiki_vectorstore, model_name=GROQ_PRODUCTION_MODELS[0]
95
+ prompt=CHAT_PROMPT_TEMPLATE,
96
+ vectorstore=twiki_vectorstore,
97
+ model_name=GROQ_PRODUCTION_MODELS[0],
98
+ retry_config=retry_config,
87
99
  )
88
100
  output = chain.invoke(
89
101
  {"question": "What is the Higgs boson?", "search_kwargs": search_kwargs},
@@ -113,7 +125,7 @@ def test_advanced_rag_chain(twiki_vectorstore):
113
125
  assert isinstance(output["docs"][0], Document)
114
126
 
115
127
 
116
- def test_advanced_rag_chain_multiple_vectorstores(three_vectorstores):
128
+ def test_advanced_rag_chain_multiple_vectorstores(three_vectorstores, retry_config):
117
129
  search_kwargs = {
118
130
  "k_text": 3,
119
131
  "k": 15,
@@ -122,7 +134,10 @@ def test_advanced_rag_chain_multiple_vectorstores(three_vectorstores):
122
134
  }
123
135
 
124
136
  chain = advanced_rag(
125
- prompt=CHAT_PROMPT_TEMPLATE, vectorstore=three_vectorstores, model_name=GROQ_PRODUCTION_MODELS[0]
137
+ prompt=CHAT_PROMPT_TEMPLATE,
138
+ vectorstore=three_vectorstores,
139
+ model_name=GROQ_PRODUCTION_MODELS[0],
140
+ retry_config=retry_config,
126
141
  )
127
142
  output = chain.invoke(
128
143
  {"question": "What is the Higgs boson?", "search_kwargs": search_kwargs},
File without changes
File without changes