from judini.codegpt.agent import Agent
# Define an asynchronous function to demonstrate a chat interaction with a CodeGPT agent
async def chat_example(prompt):
# Retrieve the CodeGPT API key from environment variables
CODEGPT_API_KEY = os.getenv("CODEGPT_API_KEY")
# Retrieve the CodeGPT agent ID from environment variables (or you can provide it directly)
# You can also specify the agent ID directly
CODEGPT_AGENT_ID = os.getenv("CODEGPT_AGENT_ID")
# Create an instance of the CodeGPT agent using the API key and agent ID
agent_instance = Agent(api_key=CODEGPT_API_KEY, agent_id=CODEGPT_AGENT_ID)
# Use an asynchronous loop to interact with the agent and get responses
async for response in agent_instance.chat_completion(prompt, stream=True):
print(response) # Print the responses obtained from the agent
import { CodeGPTPlus } from 'judini'
async function main () {
// Replace with your own API Key
const codegpt = new CodeGPTPlus('CODEGPT_API_KEY')
// Define the message
const msg = [{ role: 'user', content: 'What is the capital of Australia?' }]
// Send the message and process the response
const res = await codegpt.chatCompletion({
messages: msg,
agentId: 'CODEGPT_AGENT_ID'
}, (chunk) => {
console.log(chunk) // show the streaming response
})
}
# Import necessary libraries
from dotenv import load_dotenv
from langchain.chat_models import ChatOpenAI
from langchain.schema import HumanMessage
import os
# Load environment variables from .env file
load_dotenv()
# Retrieve API key and agent ID from environment variables
codegpt_api_key= os.getenv("CODEGPT_API_KEY")
code_gpt_agent_id= os.getenv("CODEGPT_AGENT_ID")
# Set API base URL
codegpt_api_base = "https://api.codegpt.co/v1"
# Create a ChatOpenAI object with the retrieved API key, API base URL, and agent ID
llm = ChatOpenAI(openai_api_key=codegpt_api_key,
openai_api_base=codegpt_api_base,
model=code_gpt_agent_id)
# Create a list of messages to send to the ChatOpenAI object
messages = [HumanMessage(content="¿What is Judini?")]
# Send the messages to the ChatOpenAI object and retrieve the response
response = llm(messages)
# Print the response
print(response)
curl --request POST \
--url https://api.codegpt.co/v1/completion \
--header 'accept: application/json' \
--header 'content-type: application/json'
Introduction
Discover the future of coding with the CodeGPT API! This tool is your gateway to integrating the custom agents you’ve meticulously crafted in the CodeGPT Playground into any application. Designed with the innovative developers in mind, those who are already harnessing the power of CodeGPT within VSCode, our API opens a world of endless possibilities.
With our REST API and its interactive endpoints, you can easily communicate with your agents, making them an integral part of your application. Plus, with our robust SDKs in Python and JavaScript, you can effortlessly implement the API, regardless of your preferred programming language.
Take your apps to the next level, create a unique and engaging user experience, and stand out in the ever-evolving tech landscape. Embrace the future of coding with the CodeGPT API today!
Playground
The CodeGPT Playground is an interactive platform where you can create and interact with AI Agents.
It allows you to input prompts and see the responses generated by the AI in real-time.
It's an excellent tool for understanding how the AI Agents function, and for testing different prompts and parameters in a user-friendly environment.
VSCode Extension
The CodeGPT VSCode Extension is a tool that brings the power of AI Agents into the Visual Studio Code environment.
It allows developers to interact with these AI Agents directly within their coding workspace.
These AI Agents can assist with tasks such as code completion, debugging, and learning new languages or frameworks, effectively enhancing the programming experience.
API
API is a service that allows developers to interact programmatically with the AI Agents created in the Playground.
It provides endpoints for generating responses from these AI Agents based on user input, enabling the integration of these AI-driven conversational capabilities into applications, services, or processes.
It's a powerful tool for leveraging the intelligence of AI Agents in various contexts.