Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -464,12 +464,24 @@ hf_token = os.getenv("HF_TOKEN")
|
|
| 464 |
|
| 465 |
|
| 466 |
# Initialize the desired model and parameters
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 471 |
)
|
| 472 |
|
|
|
|
|
|
|
|
|
|
| 473 |
|
| 474 |
|
| 475 |
# Initialize the LangChain agent with the tool(s) and the model
|
|
|
|
| 464 |
|
| 465 |
|
| 466 |
# Initialize the desired model and parameters
|
| 467 |
+
model_name = "mistralai/Mistral-7B-Instruct-v0.1"
|
| 468 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 469 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 470 |
+
|
| 471 |
+
# Create a text generation pipeline
|
| 472 |
+
pipe = pipeline(
|
| 473 |
+
"text-generation",
|
| 474 |
+
model=model,
|
| 475 |
+
tokenizer=tokenizer,
|
| 476 |
+
max_new_tokens=512,
|
| 477 |
+
temperature=0.7,
|
| 478 |
+
top_p=0.95,
|
| 479 |
+
repetition_penalty=1.15
|
| 480 |
)
|
| 481 |
|
| 482 |
+
# Create LangChain LLM wrapper
|
| 483 |
+
llm = HuggingFacePipeline(pipeline=pipe)
|
| 484 |
+
|
| 485 |
|
| 486 |
|
| 487 |
# Initialize the LangChain agent with the tool(s) and the model
|