Spaces:
Running
Running
Update agent.py
Browse files
agent.py
CHANGED
@@ -463,20 +463,16 @@ from langchain_community.llms import HuggingFaceHub
|
|
463 |
hf_token = os.getenv("HF_TOKEN")
|
464 |
|
465 |
# Load the Qwen2.5-Coder-32B-Instruct model using HuggingFaceHub
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
|
|
|
|
|
|
|
|
470 |
)
|
471 |
|
472 |
-
# Example usage with LangChain
|
473 |
-
tools = [
|
474 |
-
Tool(
|
475 |
-
name="code_tool",
|
476 |
-
func=qwen_model.run, # Use the run method for inference
|
477 |
-
description="Use this tool for code generation or similar tasks"
|
478 |
-
)
|
479 |
-
]
|
480 |
|
481 |
# Initialize the LangChain agent with the tool(s) and the model
|
482 |
agent = initialize_agent(
|
|
|
463 |
hf_token = os.getenv("HF_TOKEN")
|
464 |
|
465 |
# Load the Qwen2.5-Coder-32B-Instruct model using HuggingFaceHub
|
466 |
+
from langchain_huggingface import HuggingFaceEndpoint
|
467 |
+
|
468 |
+
# Initialize the HuggingFaceEndpoint with the desired model and parameters
|
469 |
+
llm = HuggingFaceEndpoint(
|
470 |
+
repo_id="Qwen/Qwen2.5-Coder-32B-Instruct",
|
471 |
+
task="text-generation",
|
472 |
+
huggingfacehub_api_token=hf_token,
|
473 |
+
model_kwargs={"temperature": 0.7, "max_length": 1024}
|
474 |
)
|
475 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
476 |
|
477 |
# Initialize the LangChain agent with the tool(s) and the model
|
478 |
agent = initialize_agent(
|