Spaces:
Running
Running
Create cleaner_chain.py
Browse files- cleaner_chain.py +23 -0
cleaner_chain.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# cleaner_chain.py
|
2 |
+
import os
|
3 |
+
from langchain.chains import LLMChain
|
4 |
+
from langchain_groq import ChatGroq
|
5 |
+
from prompts import cleaner_prompt
|
6 |
+
|
7 |
+
class CleanerChain(LLMChain):
|
8 |
+
def merge(self, kb: str, web: str) -> str:
|
9 |
+
return self.run({"kb_answer": kb, "web_answer": web})
|
10 |
+
|
11 |
+
def get_cleaner_chain() -> CleanerChain:
|
12 |
+
"""
|
13 |
+
Builds the 'CleanerChain' that merges CSV answer + web result.
|
14 |
+
"""
|
15 |
+
chat_groq_model = ChatGroq(
|
16 |
+
model="Gemma2-9b-It",
|
17 |
+
groq_api_key=os.environ["GROQ_API_KEY"]
|
18 |
+
)
|
19 |
+
chain = CleanerChain(
|
20 |
+
llm=chat_groq_model,
|
21 |
+
prompt=cleaner_prompt
|
22 |
+
)
|
23 |
+
return chain
|