Spaces:
Running
on
Zero
Running
on
Zero
File size: 992 Bytes
76df764 644789e 76df764 644789e 76df764 644789e 76df764 644789e 76df764 644789e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import os
from langchain_groq import ChatGroq
from langchain.agents import initialize_agent, AgentType
from memory import memory
from tools import tools # Import Flight Booking Tool
# Load API Key
API_KEY = os.getenv("API_KEY")
# Ensure API Key is set
if not API_KEY:
raise ValueError("API_KEY is not set. Please define it in your environment variables.")
# Initialize the LLM (Groq's Mixtral)
llm = ChatGroq(
groq_api_key=API_KEY,
model_name="mixtral-8x7b-32768",
temperature=0.7,
max_tokens=512,
)
# Initialize the conversational agent with Flight Booking Tool
agent = initialize_agent(
tools=tools,
llm=llm,
agent=AgentType.CONVERSATIONAL_REACT_DESCRIPTION,
verbose=True, # Hide debug output
memory=memory,
)
# π Custom Logging Function to Improve Execution
def log_agent_action(prompt, response):
print(f"\nπ’ **User Query:** {prompt}")
print(f"π΅ **Agent Thought Process:**")
print(f"β
**Final Response:** {response}")
|