Update main.py
Browse files
main.py
CHANGED
@@ -431,14 +431,23 @@ 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 |
repo_id = "meta-llama/Llama-3.2-3B-Instruct"
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
streaming=True
|
441 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
442 |
if not cl.user_session.get("saveMemory"):
|
443 |
cl.user_session.set("saveMemory", "")
|
444 |
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 |
+
import torch
|
435 |
+
from transformers import pipeline
|
436 |
+
from langchain_huggingface.llms import HuggingFacePipeline
|
437 |
repo_id = "meta-llama/Llama-3.2-3B-Instruct"
|
438 |
+
pipe = pipeline(
|
439 |
+
"text-generation",
|
440 |
+
model=repo_id,
|
441 |
+
torch_dtype=torch.bfloat16,
|
442 |
+
device_map="auto",
|
|
|
443 |
)
|
444 |
+
#model = HuggingFaceEndpoint(
|
445 |
+
# repo_id=repo_id,
|
446 |
+
# max_new_tokens=6000,
|
447 |
+
# temperature=1.0,
|
448 |
+
# streaming=True
|
449 |
+
#)
|
450 |
+
model = HuggingFacePipeline(pipeline=pipe)
|
451 |
if not cl.user_session.get("saveMemory"):
|
452 |
cl.user_session.set("saveMemory", "")
|
453 |
cl.user_session.set("memory", ConversationBufferMemory(return_messages=True))
|