Spaces:
Running
Running
Update rag/rag_production.py
Browse files- rag/rag_production.py +5 -4
rag/rag_production.py
CHANGED
|
@@ -18,8 +18,9 @@ logger = logging.getLogger(__name__)
|
|
| 18 |
rag_prompt_template = '''
|
| 19 |
You are a legal assistant trained to answer questions using legal documents.
|
| 20 |
|
| 21 |
-
If the answer cannot be determined from the available legal text, you must answer without include
|
| 22 |
-
According to Article <article>, Chapter <chapter>, <title>
|
|
|
|
| 23 |
> The answer cannot be determined from the available legal text.
|
| 24 |
|
| 25 |
Otherwise, you must STRICTLY follow this 3-step structure:
|
|
@@ -37,7 +38,7 @@ Otherwise, you must STRICTLY follow this 3-step structure:
|
|
| 37 |
- Do NOT repeat or paraphrase the law reference later.
|
| 38 |
- Do NOT invent any legal information — use ONLY the provided context and metadata.
|
| 39 |
- Do NOT add phrase like 'The most relevant point is that' when mentioning the context.
|
| 40 |
-
- If the context is insufficient, respond with:
|
| 41 |
> "The answer cannot be determined from the available legal text."
|
| 42 |
---
|
| 43 |
|
|
@@ -62,7 +63,7 @@ prompt = ChatPromptTemplate.from_messages([
|
|
| 62 |
('user', "Context:\n{context}\n\nQuestion:\n{input}\n\nAnswer:")
|
| 63 |
])
|
| 64 |
|
| 65 |
-
def get_rag_chain(model_name='llama-3.3-70b-versatile', k=
|
| 66 |
db = get_vectorstore()
|
| 67 |
|
| 68 |
groq_api_key = os.getenv('GROQ_API_KEY')
|
|
|
|
| 18 |
rag_prompt_template = '''
|
| 19 |
You are a legal assistant trained to answer questions using legal documents.
|
| 20 |
|
| 21 |
+
If the answer cannot be determined from the available legal text, you must answer without include this phrase:
|
| 22 |
+
> According to Article <article>, Chapter <chapter>, <title>
|
| 23 |
+
For example:
|
| 24 |
> The answer cannot be determined from the available legal text.
|
| 25 |
|
| 26 |
Otherwise, you must STRICTLY follow this 3-step structure:
|
|
|
|
| 38 |
- Do NOT repeat or paraphrase the law reference later.
|
| 39 |
- Do NOT invent any legal information — use ONLY the provided context and metadata.
|
| 40 |
- Do NOT add phrase like 'The most relevant point is that' when mentioning the context.
|
| 41 |
+
- If the context is insufficient, nrever include the legal citation and respond with:
|
| 42 |
> "The answer cannot be determined from the available legal text."
|
| 43 |
---
|
| 44 |
|
|
|
|
| 63 |
('user', "Context:\n{context}\n\nQuestion:\n{input}\n\nAnswer:")
|
| 64 |
])
|
| 65 |
|
| 66 |
+
def get_rag_chain(model_name='llama-3.3-70b-versatile', k=3):
|
| 67 |
db = get_vectorstore()
|
| 68 |
|
| 69 |
groq_api_key = os.getenv('GROQ_API_KEY')
|