Update generator.py
Browse files- generator.py +2 -7
generator.py
CHANGED
@@ -1,13 +1,8 @@
|
|
1 |
import os
|
2 |
-
import streamlit as st
|
3 |
from langchain_community.llms import HuggingFaceEndpoint
|
4 |
from pydantic import ValidationError
|
5 |
|
6 |
-
|
7 |
-
"Has environment variables been set:",
|
8 |
-
os.environ["HUGGINGFACE_API_TOKEN"] == st.secrets["HUGGINGFACE_API_TOKEN"])
|
9 |
-
|
10 |
-
|
11 |
def load_llm(repo_id="mistralai/Mistral-7B-Instruct-v0.2"):
|
12 |
'''
|
13 |
Load the LLM from the HuggingFace model hub
|
@@ -18,7 +13,7 @@ def load_llm(repo_id="mistralai/Mistral-7B-Instruct-v0.2"):
|
|
18 |
'''
|
19 |
|
20 |
try:
|
21 |
-
|
22 |
llm = HuggingFaceEndpoint(
|
23 |
repo_id=repo_id,
|
24 |
model_kwargs={"max_length": 128, "api_token": secret_token},
|
|
|
1 |
import os
|
|
|
2 |
from langchain_community.llms import HuggingFaceEndpoint
|
3 |
from pydantic import ValidationError
|
4 |
|
5 |
+
secret_token = os.getenv("HUGGINGFACE_API_TOKEN")
|
|
|
|
|
|
|
|
|
6 |
def load_llm(repo_id="mistralai/Mistral-7B-Instruct-v0.2"):
|
7 |
'''
|
8 |
Load the LLM from the HuggingFace model hub
|
|
|
13 |
'''
|
14 |
|
15 |
try:
|
16 |
+
|
17 |
llm = HuggingFaceEndpoint(
|
18 |
repo_id=repo_id,
|
19 |
model_kwargs={"max_length": 128, "api_token": secret_token},
|