Code Agent: Revolutionizing Coding with AI

Codebase: Github.com/ComposioHQ/composio-agentic-code-executor

Introducing Latest Code Agent Tool of Composio

In the rapidly evolving AI and software development landscape, leveraging Large Language Models (LLMs) has become essential for innovative solutions. Composio has led the way in LLM-focused integrations, offering developers strong tools to optimise their workflows. We are thrilled to present our newest product, a powerful code interpreter tool that expands the functionality of well-known LLM agent frameworks.

Understanding the importance of seamless integration and automation, we have developed dedicated plugins for five leading Code Agent frameworks: CrewAIAutogenGriptapeJulep, and Lyzr. These frameworks have already proven their worth in various applications, but the addition of our code interpreter tool takes their functionality to the next level.

The coding Agent feature is a game-changer, enabling these frameworks to understand, generate, and optimise code more effectively. By integrating AI Code Generator tool, developers can automate complex coding tasks, reduce errors, and significantly improve productivity. Composio’s AI code assistant makes AI coding more efficient and also empowers developers to focus on innovation rather than repetitive tasks.

In this blog, we will demonstrate how our code executor tool seamlessly integrates with each of these frameworks’ AI code generator agents, showcasing its capabilities and the transformative impact it can have on your development process. Join us as we explore the future of AI-powered coding and how Composio is leading the charge with our innovative solutions.

Build an AI Code assistant using CrewAI Agent

CrewAI stands out as a powerful coding agent, designed to streamline the development process by leveraging advanced AI capabilities. As an open-source AI code assistant, CrewAI integrates seamlessly with our code interpreter tool to enhance productivity and reduce manual coding tasks.

Key Features of CrewAI Code Generator

  • Autonomous Agents: CrewAI allows for the creation of autonomous custom AI agents that can assume specific roles and work collaboratively to achieve shared goals, much like members of a crew.
  • Customizable Tools and Skills: Agents in CrewAI can be equipped with a variety of tools and skills to aid in their tasks, allowing for the creation of custom tools that extend the capabilities of agents.
  • Process-Driven Task Execution: The framework supports structured task execution processes, allowing for sequential and, in future, more complex arrangements like consensual and hierarchical processing.
  • Integration with Composio: Our plugin enhances CrewAI’s capabilities, offering a seamless user experience for AI code generation.

Code Example

from crewai import Agent, Task
from langchain_openai import ChatOpenAI
from composio_crewai import ComposioToolset, Action, App

llm = ChatOpenAI(
    openai_api_key="sk-proj-GjfJ2CKt779qcCGfnQvtT3BlbkFJEgYuPo56yl3Elv6J3EiW"
)
composioToolset = ComposioToolset(actions=[Action.CODEINTERPRETER_EXECUTE_CODE])

crewai_agent = Agent(
    role="Code interpreter Agent",
    goal="""You can write code and execute it""",
    backstory="""You are an intelligent programmer named CodeInterpreter. You are an expert at coding. Your goal is to help me finish a code change.""",
    verbose=True,
    tools=composioToolset,
    llm=llm,
)

task = Task(
    description="Print 5 largest prime number under 10000",
    agent=crewai_agent,
    expected_output="Output of the codeinterpreter action",
)

print(task.execute())

Incorporating CrewAI with our code interpreter tool exemplifies the future of AI-powered coding agents. It simplifies complex coding tasks, allowing developers to focus on innovation and efficiency.

Build Coding Agent using Autogen

Autogen is another remarkable framework that excels as an AI coding agent framework. It is designed to provide developers with an intuitive and powerful coding environment, backed by robust AI capabilities.

Key Features of Autogen AI Code assistant

  • Versatility: AutoGen supports the generation of content in multiple formats, making it suitable for diverse content creation needs, from long-form articles to short social media captions.
  • Customization Options: Users can customize content templates, style preferences, and tone of voice to align with their brand identity and target audience, ensuring consistent messaging across all channels.
  • Time Efficiency: AutoGen automates the content creation process, significantly reducing the time and effort required to produce high-quality content.
  • Seamless Composio Integration: Our dedicated plugin for Autogen enhances its functionalities, making it an indispensable tool for developers.

Code Example

import os

import dotenv
from autogen import AssistantAgent, UserProxyAgent
from composio_autogen import Action, ComposioToolset


# Loading the variables from .env file
dotenv.load_dotenv()

llm_config = {
    "config_list": [{"model": "gpt-4", "api_key": os.environ["OPENAI_API_KEY"]}]
}

chatbot = AssistantAgent(
    "CodeInterpreter",
    system_message="Reply TERMINATE when the task is done or when user's content is empty",
    description="You are an intelligent programmer named CodeInterpreter. You are an expert at coding. Your goal is to write a code and execute it.",
    llm_config=llm_config,
)

# create a UserProxyAgent instance named "user_proxy"
user_proxy = UserProxyAgent(
    "user_proxy",
    is_termination_msg=lambda x: x.get("content", "")
    and "TERMINATE" in x.get("content", ""),
    human_input_mode="NEVER",  # Don't take input from User
    code_execution_config={"use_docker": False},
)


# Initialise the Composio Tool Set
composio_tools = ComposioToolset()

# Register the preferred Applications, with right executor.
composio_tools.register_actions(actions=Action.CODEINTERPRETER_EXECUTE_CODE, caller=chatbot, executor=user_proxy)


task = "Print 5 largest prime number under 10000"

response = user_proxy.initiate_chat(chatbot, message=task)

print(response.chat_history)

By integrating Autogen with our code interpreter tool, we provide a comprehensive solution that optimizes the coding process. Autogen’s advanced features combined with our tool ensure a seamless and efficient coding experience.

Build Agent Code LLM using Griptape

Griptape is newer framework, renowned for its flexibility and powerful AI-driven coding capabilities. It serves as an excellent coding agent, providing developers with a versatile toolset for various coding tasks.

Key Features of AI Code generator using Griptape

  • Versatile Code Generation: Griptape supports a wide range of coding languages and frameworks, making it a versatile tool for developers.
  • AI-Powered Code Optimization: The framework’s AI capabilities ensure that the generated code is optimized for performance and efficiency.
  • Enhanced by Composio: Our plugin integration with Griptape amplifies its coding capabilities, providing developers with a seamless coding experience.

Code Example

from griptape.structures import Agent
from griptape.utils import Chat

from composio_griptape import App, Action, Tag, ComposioToolset
import dotenv


dotenv.load_dotenv()

composio_toolset = ComposioToolset()
composio_tools = composio_toolset.get_actions(actions=Action.CODEINTERPRETER_EXECUTE_CODE)

agent = Agent(
    tools=composio_tools
)

task = "Print 5 largest prime number under 10000"
print(agent.run(task).output_task.output.value)

Griptape, when integrated with our code interpreter tool, becomes a powerhouse of coding efficiency and versatility. It empowers developers to tackle complex coding challenges with ease and precision.

Build AI Code Agent using Julep

Julep is a robust framework that offers comprehensive support for AI-powered coding. As a coding agent, it is designed to enhance the coding process with its intelligent features and seamless integration with other tools.

Key Features of Julep Framework

  • Intelligent Code Generation: Julep’s AI-driven code generation capabilities make it a powerful tool for any development project.
  • Real-time Code Assistance: The framework provides real-time suggestions and corrections, improving code accuracy and reducing errors.
  • Integration with Composio: Our plugin for Julep further enhances its capabilities, making it an indispensable tool for developers.

Code Example demonstrating Julep with Composio’s Code Agent

import os
import textwrap
from julep import Client
from dotenv import load_dotenv
import json
from composio_julep import Action, ComposioToolset


load_dotenv()
toolset = ComposioToolset()
composio_tools = toolset.get_actions(actions=[Action.CODEINTERPRETER_EXECUTE_CODE])

# Find api key at platform.julep.ai
os.environ["JULEP_API_KEY"]
# base_url = os.environ["JULEP_API_URL"]
# openai_api_key = os.environ["OPENAI_API_KEY"]

client = Client(api_key=api_key)


name = "Sawradip"
about = "Sawradip is a software developer with a passion for solving complex problems and a keen interest in AI. You have the ability to write code and execute it."
default_settings = {
    "temperature": 0.7,
    "top_p": 1,
    "min_p": 0.01,
    "presence_penalty": 0,
    "frequency_penalty": 0,
    "length_penalty": 1.0,
    "max_tokens": 4500,
}

agent = client.agents.create(
    name=name,
    about=about,
    default_settings=default_settings,
    model="gpt-4-turbo",
    tools=composio_tools,
)


user = client.users.create(
    name="Jessica",
    about="Tech recruiter specializing in identifying talented developers.",
)

situation_prompt = """Jessica, a tech recruiter, is conducting an interview with Sawradip, a promising software developer. They discuss various technical topics, with a focus on problem-solving and algorithm design.
"""

session = client.sessions.create(
    user_id=user.id, agent_id=agent.id, situation=situation_prompt
)

user_msg = "Can you give me the five largest prime numbers under 10,000, writing a python funtion and executing it. Be sure to return the value."

# user_msg = "What do you like about tech?"

response = client.sessions.chat(
    session_id=session.id,
    messages=[
        {
            "role": "user",
            "content": user_msg,
            "name": "Jessica",
        },
    ],
    recall=True,
    remember=True,
    max_tokens=4500,
)

if response.finish_reason == "stop":
    print("Response Stopped due as processing completed")
    print(response)
else:
    while response.finish_reason == "tool_calls":
        execution_output = toolset.handle_tool_calls(
            response
        )  # execute tool call to get response
        response = client.sessions.chat(  # submit the tool call
            session_id=session.id,
            messages=[{"role": "assistant", "content": json.dumps(execution_output)}],
            recall=True,
            remember=True,
            max_tokens=4500,
        )
        print(response)

print(response)

Conclusion

Integrating Julep with Composio’s code agent interpreter tool provides developers with a comprehensive solution for efficient and accurate coding. Julep’s advanced features, combined with our tool, streamline the development process significantly.

Build Code Agent using Lyzr Framework

Lyzr is a cutting-edge framework that excels as an AI code assistant. It is designed to provide developers with powerful tools for efficient coding, supported by advanced AI capabilities.

Key Features of Lyzr AI code assistant

  • Advanced Code Generation: Lyzr’s AI-driven code generation ensures high-quality and efficient code production.
  • Error Detection and Correction: The framework identifies and corrects code errors in real-time, enhancing overall code quality.
  • Seamless Integration with Composio: Our plugin for Lyzr boosts its functionalities, offering a superior coding experience for developers.

Code Example

import os

import dotenv
from lyzr_automata import Agent, Task
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from lyzr_automata.tasks.task_literals import InputType, OutputType


dotenv.load_dotenv()
from composio_lyzr import Action, ComposioToolset  # noqa: E402


open_ai_text_completion_model = OpenAIModel(
    api_key=os.environ["OPENAI_API_KEY"],
    parameters={
        "model": "gpt-4-turbo-preview",
        "temperature": 0.2,
        "max_tokens": 1500,
    },
)


lyzr_agent = Agent(
    role="CodeInterpreter",
    prompt_persona="You are an intelligent programmer named CodeInterpreter. You are an expert at coding. Your goal is to help me finish a code change.",
)

composio_toolset = ComposioToolset()
composio_tool = composio_toolset.get_lyzr_tool(Action.CODEINTERPRETER_EXECUTE_CODE)

task = Task(
    name="Code Execution",
    agent=lyzr_agent,
    tool=composio_tool,
    output_type=OutputType.TEXT,
    input_type=InputType.TEXT,
    model=open_ai_text_completion_model,
    instructions="Print 5 largest prime number under 10000",
    log_output=True,
    enhance_prompt=False,
)

lyzr_output = LinearSyncPipeline(
    name="Composio Lyzr",
    # completion message after pipeline completes
    completion_message="Task completed",
    tasks=[
        # tasks are instance of Task class
        task,
    ],
).run()

print(lyzr_output)

Lyzr, combined with our code interpreter tool, provides a comprehensive solution for AI-powered coding. It simplifies complex coding tasks and enhances productivity, making it a valuable tool for developers.

Conclusion

In today’s fast-paced world of AI and software development, our integration of code interpreter tools with platforms like CrewAI, Autogen, Griptape, Julep, and Lyzr is reshaping the way we approach coding. These platforms, enhanced by our plugins, automate complex coding tasks and elevate productivity and code quality. With reliable coding agents, developers are free to innovate and solve problems creatively, entrusting routine tasks to AI.

At Composio, we are dedicated to enhancing the capabilities of our tools. This blog marks the beginning of a series of updates as we expand our support to more frameworks and launch new features to improve your coding experience. Whether you’re interested in an open-source AI code assistant or a free AI code generator, our upcoming posts will offer detailed insights and live demonstrations.

Join us to redefine the future of coding with AI. Follow our blog for more detailed analyses, live demos, and the latest updates on AI coding agents and frameworks. Let’s advance the boundaries of software development together.

Complete Flow Video

Frequently Asked Questions(FAQs)

Code Interpreter Integration with LLM Agent Frameworks

What are agents?

Agents, in the context of software and AI, are autonomous entities that perform tasks on behalf of users, usually with an LLM as their backbone. They can make decisions, perform actions, and interact with other systems based on the data they receive and their programmed objectives.

What are code agents?

Code agents are specialized types of agents focused on coding tasks. They leverage AI to understand, generate, and optimize code, assisting developers by automating repetitive tasks, suggesting improvements, and ensuring code quality.

What is Composio doing?

Composio is at the forefront of LLM-focused integrations, providing powerful tools to streamline development workflows. Recently, we introduced a robust code interpreter tool designed to enhance the capabilities of popular LLM agent frameworks, enabling seamless integration and automation for more efficient coding.

What is a code interpreter, and why is it important for LLM agent frameworks?

A code interpreter is a tool that can read, execute, and understand code. In the context of LLM agent frameworks, it allows the AI to generate, optimize, and correct code in real-time, significantly enhancing the development process by automating repetitive tasks, reducing errors, and improving productivity.

How does Composio’s code interpreter integrate with the mentioned frameworks?

Composio’s code interpreter integrates with frameworks like CrewAI, Autogen, Griptape, Julep, and Lyzr through dedicated plugins. These plugins allow seamless communication between the code interpreter and the frameworks, enabling them to leverage the interpreter’s capabilities for enhanced coding assistance.

Can you provide an example of how the code interpreter works with CrewAI?

Certainly! When integrated with CrewAI, our code interpreter can generate code snippets based on natural language prompts, suggest real-time corrections, and optimize existing code. For instance, a developer can input a high-level task description, and CrewAI, powered by our interpreter, will generate the corresponding code.

What are the key benefits of using an AI-powered coding agent like Autogen with Composio’s code interpreter?

Using Autogen with Composio’s code interpreter provides several benefits:

  • Dynamic code generation tailored to project-specific needs.
  • Real-time error detection and correction, enhancing code quality.
  • Automation of repetitive coding tasks, freeing developers to focus on complex problem-solving and innovation.

How does Griptape handle multiple programming languages with the code interpreter?

Griptape, known for its versatility, can handle multiple programming languages by leveraging the code interpreter’s capability to understand and generate code in various languages. This makes it a versatile tool for developers working on diverse projects requiring different programming languages.

What makes Julep a robust choice for AI-powered coding, especially with the integration of Composio’s code interpreter?

Julep is designed for comprehensive AI-powered coding support. With the integration of Composio’s code interpreter, Julep offers intelligent code generation, real-time assistance, and seamless error correction. These features make Julep a robust choice for developers seeking efficient and accurate coding solutions.

How does Lyzr enhance coding efficiency with Composio’s code interpreter?

Lyzr enhances coding efficiency by using the code interpreter to provide advanced code generation and optimization. The interpreter helps Lyzr identify and correct errors in real-time, ensuring high-quality code output and reducing the time developers spend on debugging and corrections.

Are there any specific requirements for integrating Composio’s code interpreter with these frameworks?

The integration of Composio’s code interpreter with these frameworks typically requires installing the corresponding plugin and configuring it according to the framework’s guidelines. Detailed installation and configuration instructions are provided with each plugin to ensure a smooth integration process.

What kind of support can developers expect when using these integrations?

Developers can expect comprehensive support, including detailed documentation, installation guides, and troubleshooting assistance. Additionally, our support team is available to help resolve any issues and provide guidance on maximizing the benefits of these integrations.

Will there be more frameworks supported by Composio’s code interpreter in the future?

Yes, Composio is committed to continuously expanding the capabilities of our code interpreter, ensuring it supports more frameworks and offers broader functionality to developers.