Spaces:
Sleeping
Sleeping
luanpoppe
commited on
Commit
·
8b9c100
1
Parent(s):
7d2e972
fix: tentando fix do model
Browse files- langchain_backend/utils.py +15 -2
langchain_backend/utils.py
CHANGED
@@ -6,6 +6,7 @@ from langchain_openai import OpenAIEmbeddings
|
|
6 |
from langchain_text_splitters import RecursiveCharacterTextSplitter
|
7 |
from langchain.chains.combine_documents import create_stuff_documents_chain
|
8 |
from langchain_core.prompts import ChatPromptTemplate
|
|
|
9 |
|
10 |
os.environ.get("OPENAI_API_KEY")
|
11 |
|
@@ -28,9 +29,21 @@ def create_retriever(documents):
|
|
28 |
|
29 |
return retriever
|
30 |
|
31 |
-
def create_prompt_llm_chain(system_prompt,
|
32 |
print('model: ', model)
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
system_prompt = system_prompt + "\n\n" + "{context}"
|
36 |
prompt = ChatPromptTemplate.from_messages(
|
|
|
6 |
from langchain_text_splitters import RecursiveCharacterTextSplitter
|
7 |
from langchain.chains.combine_documents import create_stuff_documents_chain
|
8 |
from langchain_core.prompts import ChatPromptTemplate
|
9 |
+
from langchain_huggingface import HuggingFaceEndpoint
|
10 |
|
11 |
os.environ.get("OPENAI_API_KEY")
|
12 |
|
|
|
29 |
|
30 |
return retriever
|
31 |
|
32 |
+
def create_prompt_llm_chain(system_prompt, modelParam="gpt-4o-mini"):
|
33 |
print('model: ', model)
|
34 |
+
if modelParam == "gpt-4o-mini":
|
35 |
+
model = ChatOpenAI(model=modelParam)
|
36 |
+
else:
|
37 |
+
os.environ.get("HUGGINGFACEHUB_API_TOKEN")
|
38 |
+
|
39 |
+
llm = HuggingFaceEndpoint(
|
40 |
+
repo_id="meta-llama/Meta-Llama-3-8B-Instruct",
|
41 |
+
task="text-generation",
|
42 |
+
max_new_tokens=100,
|
43 |
+
do_sample=False,
|
44 |
+
)
|
45 |
+
result = llm.invoke("Hugging Face is")
|
46 |
+
print('result: ', result)
|
47 |
|
48 |
system_prompt = system_prompt + "\n\n" + "{context}"
|
49 |
prompt = ChatPromptTemplate.from_messages(
|