Skip to main content

SDK for building langchain agents using resouces from Alita

Project description

Alita SDK

Alita SDK, built on top of Langchain, enables the creation of intelligent agents within the Alita Platform using project-specific prompts and data sources. This SDK is designed for developers looking to integrate advanced AI capabilities into their projects with ease.

Prerequisites

Before you begin, ensure you have the following requirements met:

  • Python 3.10
  • An active deployment of Project Alita
  • Access to personal project

Installation

First, you need to install the Langchain library. Alita SDK depends on Langchain for its core functionalities. You can install Langchain using pip:

pip install langchain

Next, clone the Alita SDK repository (assuming it's available on GitHub or another source):

git clone https://github.com/ProjectAlita/alita-sdk.git
cd alita-sdk

Install the SDK along with its dependencies:

pip install -r requirements.txt

Environment Setup

Before running your Alita agents, set up your environment variables. Create a .env file in the root directory of your project and include your Project Alita credentials:

AUTH_TOKEN=<your_api_token>
PROJECT_ID=<your_project_id> 
INTEGRATION_UID=<your_integration_uid>

Ensure you load these variables in your application:

from dotenv import load_dotenv 
load_dotenv('.env')

Basic Usage

The Alita SDK allows you to create and execute agents with ease. Here's a simple example to get you started:

import logging 
from src.alita_sdk.llms.alita import AlitaChatModel 
from langchain_core.messages import HumanMessage  
# Set up 
logging logging.basicConfig(level=logging.INFO) 
logger = logging.getLogger(__name__)  

# Load environment variables 
from os import environ 
load_dotenv('.env')  

# Configuration settings for AlitaChatModel 
settings = {
    "deployment": "https://eye.projectalita.ai",
    "model": "gpt-4-1106-preview",
    "api_key": environ.get("AUTH_TOKEN"),
    "project_id": environ.get("PROJECT_ID"),
    "integration_uid": environ.get("INTEGRATION_UID"),
    "max_tokens": 2048,
    "stream": True 
}  
# Instantiate AlitaChatModel 
llm = AlitaChatModel(**settings)  

# Define tools for agent operations 
from demo.demo_react_agent.tools import getRepoTreeTool, getRawFileTool, storeSpecFile  t
ools = [getRepoTreeTool(), getRawFileTool, storeSpecFile]  

# Construct the agent with mixed capabilities 

from src.alita_sdk.agents import create_mixed_agent 
from langchain.agents import AgentExecutor 

prompt = llm.client.prompt(prompt_id=<prompt_id>, prompt_version_id=<prompt_version_id>) 
agent = create_mixed_agent(llm, tools, prompt)  

# Execute the agent 
agent_executor = AgentExecutor.from_agent_and_tools(
    agent=agent, tools=tools, verbose=True, handle_parsing_errors=True, max_execution_time=None, return_intermediate_steps=True)  

input_data = {"input": """Use repository spring-petclinic/spring-framework-petclinic with branch main. 
It is a Java Spring application, please create a swagger spec. 
Deployment URL is https://petclinic.example.com"""}  

agent_executor.invoke(input_data, include_run_info=True)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alita_sdk-0.1.55.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

alita_sdk-0.1.55-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

Details for the file alita_sdk-0.1.55.tar.gz.

File metadata

  • Download URL: alita_sdk-0.1.55.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for alita_sdk-0.1.55.tar.gz
Algorithm Hash digest
SHA256 93777491da5fe9d7c5bd798b85602807da981db72e30e40d126cbd8936dea655
MD5 4a778ad782c5aad9ccb8ef4cb0ef19dd
BLAKE2b-256 cc933e06b2056de47b8644aadc2f8ea553171ced21193394b1b91a57d0062fb5

See more details on using hashes here.

File details

Details for the file alita_sdk-0.1.55-py3-none-any.whl.

File metadata

  • Download URL: alita_sdk-0.1.55-py3-none-any.whl
  • Upload date:
  • Size: 36.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for alita_sdk-0.1.55-py3-none-any.whl
Algorithm Hash digest
SHA256 1f82fe14ab683af259243cfdddd9bcecacef2ad61c2174f88bd39231bc5c5dad
MD5 a0b3d0a031089e39c3c6ddbd44f06f34
BLAKE2b-256 667acbb2dd770967e211900b61bab0ec683d19e77b90b3126a75269ead016ee4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page