wt002 commited on
Commit
ab507e0
·
verified ·
1 Parent(s): db3a218

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +8 -12
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
- qwen_model = HuggingFaceHub(
467
- repo_id="Qwen/Qwen2.5-Coder-32B-Instruct", # Specify the model from Hugging Face
468
- api_key=hf_token, # Pass the API token for access
469
- model_kwargs={"temperature": 0.7} # Adjust temperature as needed
 
 
 
 
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(