vgecbot / test_json_spliting.py
harsh-dev's picture
docker deployment
4225666
from langchain_community.chat_models import ChatLlamaCpp
# Model path (update to your file)
model_file = "./ml_models/llm/DeepSeek-R1-Distill-Qwen-1.5B-Q4_K_M.gguf"
# Load model with your low-RAM params
llm = ChatLlamaCpp(
model_path=str(model_file),
n_ctx=8000,
n_batch=512,
n_threads=4,
temperature=0.2,
max_tokens=512,
stop=["<|end▁of▁sentence|>"],
verbose=True
)
# Example RAG-style prompt (adapt for Pleias: query + sources)
context = """
page_content: faculties: The faculty members include Professor Kajal S. Patel (Associate Professor, Ph.D.), Professor Hetal A. Joshiara (Associate Professor, Ph.D.), Professor Viral Borisagar (Associate Professor, Ph.D.), Professor Jalpa M. Ramavat (Assistant Professor, Ph.D.), Professor Nakul R. Dave (Assistant Professor, Ph. D.), Professor Amit H. Rathod (Assistant Professor, Ph.D.), Professor Nirav B. Suthar (Assistant Professor, M.E.), Professor Jaimin M. Shroff (Assistant Professor, M. Tech), Professor Jigna J. Jadav (Assistant Professor, Ph.D.), Professor Vinodray D. Thumar (Assistant Professor, Ph.D.), Professor Karan P. Bhatt (Assistant Professor, M.E.), Professor Avani Nakul Dave (Assistant Professor, M.E.), Professor Rahul K. Shah (Assistant Professor, M. Tech.), Professor Bhavinkumar N. Patel (Assistant Professor, M.E), and Mrs. Vital R. Patel (Computer Operator, D.E.)., from source: computer-engineering-department.json.
page_content: faculties: The faculty members include Professor Kajal S. Patel (Associate Professor, Ph.D.), Professor Hetal A. Joshiara (Associate Professor, Ph.D.), Professor Viral Borisagar (Associate Professor, Ph.D.), Professor Jalpa M. Ramavat (Assistant Professor, Ph.D.), Professor Nakul R. Dave (Assistant Professor, Ph. D.), Professor Amit H. Rathod (Assistant Professor, Ph.D.), Professor Nirav B. Suthar (Assistant Professor, M.E.), Professor Jaimin M. Shroff (Assistant Professor, M. Tech), Professor Jigna J. Jadav (Assistant Professor, Ph.D.), Professor Vinodray D. Thumar (Assistant Professor, Ph.D.), Professor Karan P. Bhatt (Assistant Professor, M.E.), Professor Avani Nakul Dave (Assistant Professor, M.E.), Professor Rahul K. Shah (Assistant Professor, M. Tech.), Professor Bhavinkumar N. Patel (Assistant Professor, M.E), and Mrs. Vital R. Patel (Computer Operator, D.E.)., from source: computer-science-engineering-data-science-department.json.
page_content: faculties: The faculty members include Professor Vibha D. Patel (Professor, Ph.D.), Professor Purvi N. Ramanuj (Associate Professor, Ph.D.), Professor Khushali R. Raval (Associate Professor, Ph.D.), Professor Vallabh G. Patel (Assistant Professor, M. E.), Professor Nikunj C. Gamit (Assistant Professor, M.Tech.), Professor Jashvant R. Dave (Assistant Professor, Ph. D.), Professor Naimisha S. Trivedi (Assistant Professor, M.Tech.), Professor Jignesh H. Vaniya (Assistant Professor, M.Tech.), Professor Chetna G. Chand (Assistant Professor, M.Tech), Professor Dipak C. Patel (Assistant Professor, Ph. D.), Professor Om P. Mehta (Assistant Professor, Ph.D.), Professor Manmitsinh C. Zala (Assistant Professor, M.E.), Ms. Rashmi H. Chauhan (Lab Assistant, D.E), and Mr. Jagdish S. Senma (Lab Assistant, D.E.)., from source: information-technology-department.json.
:"""
from langchain_core.messages import SystemMessage, HumanMessage
messages = [
SystemMessage(content="""
You are the official assistant of VGEC.
Answer ONLY using the provided context.
If the answer is not present, say:
'I cannot find the answer in the provided context.'
Do not explain your reasoning.
Give only the final answer.
"""),
HumanMessage(content=f"""
CONTEXT:
----------------
{context}
QUESTION: (Only do what question asks from context only)
List Faculties of Computer Department
""")
]
response = llm.invoke(messages)
print(response.content)
# # Invoke the model
# output = llm(
# prompt,
# temperature=0.1,
# stop=["</s>", "\n\n"] # Clean stops for structured output
# )
# print("Response:", output['choices'][0]['text'])