forked from saxenaakansha30/drupal-rag-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathllm_integration.py
More file actions
25 lines (20 loc) · 839 Bytes
/
llm_integration.py
File metadata and controls
25 lines (20 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from langchain.prompts import PromptTemplate
from langchain_community.chat_models import ChatOllama
class LlmIntegration:
def __init__(self):
self.prompt = PromptTemplate.from_template(
"""
<s> [INST] You are an assistant for question-answering tasks. Use the following pieces of retrieved context
to answer the question. If you don't know the answer, just say that you don't know. Use three sentences
maximum and keep the answer concise. [/INST] </s>
[INST] Question: {question}
Context: {context}
Answer: [/INST]
"""
)
def set_modal(self, model_name: str):
self.model = ChatOllama(model=model_name)
def get_modal(self):
return self.model
def get_prompt(self):
return self.prompt