Spaces:
Sleeping
Sleeping
Update second.py
Browse files
second.py
CHANGED
|
@@ -6,14 +6,14 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
| 6 |
from langchain_groq import ChatGroq
|
| 7 |
from langchain.prompts import ChatPromptTemplate
|
| 8 |
|
| 9 |
-
# 環境変数からHugging Faceのトークンを取得
|
| 10 |
os.environ['HF_TOKEN'] = os.getenv('HUGGING_FACE_TOKEN')
|
| 11 |
os.environ["GROQ_API_KEY"] = os.getenv("GROQ_API_KEY")
|
| 12 |
|
| 13 |
# Hugging Faceのモデルとトークナイザーをロード
|
| 14 |
model_id = "meta-llama/Meta-Llama-3-8B-Instruct"
|
| 15 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id,
|
| 16 |
-
model = AutoModelForCausalLM.from_pretrained(model_id,
|
| 17 |
|
| 18 |
# Groqを使ったLangChainのChatGroqインスタンスを初期化
|
| 19 |
chat = ChatGroq(model_name=model_id, tokenizer=tokenizer)
|
|
@@ -43,4 +43,4 @@ if os.path.exists("output2.txt"):
|
|
| 43 |
print("Content of output2.txt:")
|
| 44 |
print(content)
|
| 45 |
else:
|
| 46 |
-
print("output2.txt does not exist.")
|
|
|
|
| 6 |
from langchain_groq import ChatGroq
|
| 7 |
from langchain.prompts import ChatPromptTemplate
|
| 8 |
|
| 9 |
+
# 環境変数からHugging FaceのトークンとGroq APIキーを取得
|
| 10 |
os.environ['HF_TOKEN'] = os.getenv('HUGGING_FACE_TOKEN')
|
| 11 |
os.environ["GROQ_API_KEY"] = os.getenv("GROQ_API_KEY")
|
| 12 |
|
| 13 |
# Hugging Faceのモデルとトークナイザーをロード
|
| 14 |
model_id = "meta-llama/Meta-Llama-3-8B-Instruct"
|
| 15 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, token=os.getenv('HF_TOKEN'))
|
| 16 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, token=os.getenv('HF_TOKEN'))
|
| 17 |
|
| 18 |
# Groqを使ったLangChainのChatGroqインスタンスを初期化
|
| 19 |
chat = ChatGroq(model_name=model_id, tokenizer=tokenizer)
|
|
|
|
| 43 |
print("Content of output2.txt:")
|
| 44 |
print(content)
|
| 45 |
else:
|
| 46 |
+
print("output2.txt does not exist.")
|