Update main.py
Browse files
main.py
CHANGED
@@ -431,22 +431,18 @@ async def start():
|
|
431 |
|
432 |
os.environ['HUGGINGFACEHUB_API_TOKEN'] = os.environ['HUGGINGFACEHUB_API_TOKEN']
|
433 |
#repo_id = "mistralai/Mistral-7B-Instruct-v0.3"
|
434 |
-
import torch
|
435 |
-
from transformers import pipeline
|
436 |
-
from langchain_huggingface.llms import HuggingFacePipeline
|
437 |
-
repo_id = "meta-llama/Llama-3.1-8B-Instruct"
|
438 |
#model = HuggingFaceEndpoint(
|
439 |
# repo_id=repo_id,
|
440 |
# max_new_tokens=6000,
|
441 |
# temperature=1.0,
|
442 |
# streaming=True
|
443 |
#)
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
)
|
450 |
if not cl.user_session.get("saveMemory"):
|
451 |
cl.user_session.set("saveMemory", "")
|
452 |
cl.user_session.set("memory", ConversationBufferMemory(return_messages=True))
|
|
|
431 |
|
432 |
os.environ['HUGGINGFACEHUB_API_TOKEN'] = os.environ['HUGGINGFACEHUB_API_TOKEN']
|
433 |
#repo_id = "mistralai/Mistral-7B-Instruct-v0.3"
|
|
|
|
|
|
|
|
|
434 |
#model = HuggingFaceEndpoint(
|
435 |
# repo_id=repo_id,
|
436 |
# max_new_tokens=6000,
|
437 |
# temperature=1.0,
|
438 |
# streaming=True
|
439 |
#)
|
440 |
+
from transformers import LlamaTokenizerFast, MistralForCausalLM
|
441 |
+
import torch
|
442 |
+
tokenizer = LlamaTokenizerFast.from_pretrained('mistralai/Mistral-Small-Instruct-2409')
|
443 |
+
tokenizer.pad_token = tokenizer.eos_token
|
444 |
+
|
445 |
+
model = MistralForCausalLM.from_pretrained('mistralai/Mistral-Small-Instruct-2409', torch_dtype=torch.bfloat16)
|
446 |
if not cl.user_session.get("saveMemory"):
|
447 |
cl.user_session.set("saveMemory", "")
|
448 |
cl.user_session.set("memory", ConversationBufferMemory(return_messages=True))
|