Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,11 +9,14 @@ from langchain_community.llms import HuggingFacePipeline
|
|
9 |
from langchain.retrievers import ParentDocumentRetriever
|
10 |
from langchain.storage import InMemoryStore
|
11 |
from langchain_chroma import Chroma
|
|
|
12 |
from langchain_core.prompts import ChatPromptTemplate, FewShotChatMessagePromptTemplate
|
13 |
from langchain_core.output_parsers import StrOutputParser
|
14 |
from langchain_core.runnables import RunnableLambda
|
15 |
from datetime import date
|
16 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
|
17 |
|
18 |
# Environment variables
|
19 |
os.environ['LANGCHAIN_TRACING_V2'] = 'true'
|
@@ -81,25 +84,16 @@ def get_chain(temperature):
|
|
81 |
|
82 |
# Replace the local OLMOLLM with the Hugging Face model
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
"text-generation",
|
93 |
-
model=model,
|
94 |
-
tokenizer=tokenizer,
|
95 |
-
max_length=2200, # Adjust based on your input length
|
96 |
-
max_new_tokens=100, # Number of tokens to generate
|
97 |
-
temperature=temperature # Adjust the creativity of the output
|
98 |
-
)
|
99 |
|
100 |
|
101 |
-
# Initialize the LangChain HuggingFacePipeline
|
102 |
-
llm = HuggingFacePipeline(pipeline=pipe)
|
103 |
|
104 |
|
105 |
# Initialize LangChain
|
|
|
9 |
from langchain.retrievers import ParentDocumentRetriever
|
10 |
from langchain.storage import InMemoryStore
|
11 |
from langchain_chroma import Chroma
|
12 |
+
from langchain.llms import LlamaCpp
|
13 |
from langchain_core.prompts import ChatPromptTemplate, FewShotChatMessagePromptTemplate
|
14 |
from langchain_core.output_parsers import StrOutputParser
|
15 |
from langchain_core.runnables import RunnableLambda
|
16 |
from datetime import date
|
17 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
18 |
+
from setup import OLMO_MODEL
|
19 |
+
model_path = OLMO_MODEL
|
20 |
|
21 |
# Environment variables
|
22 |
os.environ['LANGCHAIN_TRACING_V2'] = 'true'
|
|
|
84 |
|
85 |
# Replace the local OLMOLLM with the Hugging Face model
|
86 |
|
87 |
+
llm = LlamaCpp(
|
88 |
+
model_path=str(model_path),
|
89 |
+
callback_manager=callback_manager,
|
90 |
+
temperature=0.8,
|
91 |
+
max_tokens=3000,
|
92 |
+
verbose=False,
|
93 |
+
echo=False
|
94 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
|
|
|
|
|
97 |
|
98 |
|
99 |
# Initialize LangChain
|