From ff894d47a8fbb81f066572361b89db3d866f5fc1 Mon Sep 17 00:00:00 2001 From: Sakalya Date: Tue, 3 Dec 2024 00:18:53 +0530 Subject: [PATCH] Updated and fixed the issues in Agent code --- ai_agent_tutorials/ai_coding_agent/app.py | 18 ++++++++++-------- .../ai_coding_agent/autotabml_agents.py | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ai_agent_tutorials/ai_coding_agent/app.py b/ai_agent_tutorials/ai_coding_agent/app.py index daeb71e..b769e94 100644 --- a/ai_agent_tutorials/ai_coding_agent/app.py +++ b/ai_agent_tutorials/ai_coding_agent/app.py @@ -35,7 +35,7 @@ def save_uploaded_file(uploaded_file): # load the .env file load_dotenv() # Set up Groq API key -groq_api_key = os.environ.get("GROQ_API_KEY") # os.environ["GROQ_API_KEY"] = +groq_api_key = os.getenv("GROQ_API_KEY") # os.environ["GROQ_API_KEY"] = def main(): @@ -62,7 +62,7 @@ def main(): st.sidebar.title('LLM Model') model = st.sidebar.selectbox( 'Model', - ["llama3-70b-8192"] + ["groq/llama-3.1-8b-instant"] ) # Initialize LLM @@ -102,13 +102,15 @@ def main(): crew = Crew( agents=list(agents.values()), tasks=tasks, - verbose=2 + verbose=True ) result = crew.kickoff() if result: # Only call st_ace if code has a valid value - code = result.strip("```") + code = str(result).strip("```") + if 'python' in code: + code = code[code.index('python')+1:] try: filt_idx = code.index("```") code = code[:filt_idx] @@ -136,13 +138,13 @@ def main(): crew = Crew( agents=list(agents.values()), tasks=tasks, - verbose=2 + verbose=True ) result = crew.kickoff() if result: # Only call st_ace if code has a valid value - code = result.strip("```") + code = str(result).strip("```") try: filter_idx = code.index("```") code = code[:filter_idx] @@ -168,13 +170,13 @@ def main(): crew = Crew( agents=list(agents.values()), tasks=tasks, - verbose=2 + verbose=True ) result = crew.kickoff() if result: # Only call st_ace if code has a valid value - code = result.strip("```") + code = str(result).strip("```") try: filter_idx = code.index("```") code = code[:filter_idx] diff --git a/ai_agent_tutorials/ai_coding_agent/autotabml_agents.py b/ai_agent_tutorials/ai_coding_agent/autotabml_agents.py index 64bcaba..371a430 100644 --- a/ai_agent_tutorials/ai_coding_agent/autotabml_agents.py +++ b/ai_agent_tutorials/ai_coding_agent/autotabml_agents.py @@ -81,7 +81,7 @@ def initialize_agents(llm,file_name,Temp_dir): ), "Compiler_Agent":Agent( role = "Code_compiler", - goal = "Extract only the python code.", + goal = "Extract only the python code. Remove any other things like backticks ``` and any thing like ```python```", backstory = "You are the compiler which extract only the python code.", verbose = True, allow_delegation = False,