Activity
Mon
Wed
Fri
Sun
Dec
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
What is this?
Less
More

Memberships

AI Developer Accelerator

Public • 3.7k • Free

Generative AI

Public • 232 • Free

ChatGPT Users

Public • 11.3k • Free

Data Alchemy

Public • 21.7k • Free

1 contribution to AI Developer Accelerator
Need help in fixing bug
I am watching the youtube tutorial on LangChain. In the agent and tools section, I used ChatGroq class to use Groq models instead of using OpenAI model and I got an Runtime error. The rest of the codes remain same. Here is the youtube video link https://youtu.be/yF9kGESAi3M Here is my code: from dotenv import load_dotenv from langchain import hub from langchain.agents import AgentExecutor, create_react_agent from langchain_core.tools import Tool from langchain_groq import ChatGroq # Load environment variables from .env file load_dotenv() # Define a very simple tool function that returns the current time def get_current_time(*args, **kwargs): """Returns the current time in H:MM AM/PM format.""" import datetime # Import datetime module to get current time now = datetime.datetime.now() # Get current time return now.strftime("%I:%M %p") # Format time in H:MM AM/PM format # List of tools available to the agent tools = [ Tool( name="Time", # Name of the tool func=get_current_time, # Function that the tool will execute # Description of the tool description="Useful for when you need to know the current time", ), ] # Pull the prompt template from the hub # ReAct = Reason and Action # https://smith.langchain.com/hub/hwchase17/react prompt = hub.pull("hwchase17/react") # Initialize a ChatOpenAI model llm = ChatGroq(model="llama3-groq-8b-8192-tool-use-preview", temperature=0) # Create the ReAct agent using the create_react_agent function agent = create_react_agent( llm=llm, tools=tools, prompt=prompt, stop_sequence=True, ) # Create an agent executor from the agent and tools agent_executor = AgentExecutor.from_agent_and_tools( agent=agent, tools=tools, verbose=True, ) # Run the agent with a test query response = agent_executor.invoke({"input": "What time is it?"}) # Print the response from the agent print("response:", response)
1
0
Need help in fixing bug
1-1 of 1
Muntasir Ahmed
1
4points to level up
@muntasir-ahmed-2943
I am an AI developer specialization in NLP and Generative AI. I love to learn new technologies and build scalable apps using cutting edge techs.

Active 35d ago
Joined Sep 1, 2024
powered by