The official Python library for the Integry API
Project description
Integry Python API Library
The Python API library allows access to Integry REST API from Python programs.
Installation
# install from PyPI
pip install integry
Usage with Agent Frameworks
1. LangChain/LangGraph
import os
from integry import Integry
from langchain_core.messages import SystemMessage, HumanMessage
from langchain_openai import ChatOpenAI
from langchain_core.tools import StructuredTool
from langgraph.prebuilt import create_react_agent
user_id = "your user's ID"
# Initialize the client
integry = Integry(
app_key=os.environ.get("INTEGRY_APP_SECRET"),
app_secret=os.environ.get("INTEGRY_APP_KEY"),
)
slack_post_message = await integry.functions.get("slack-post-message", user_id)
llm = ChatOpenAI(
model="gpt-4o",
api_key=os.environ.get("OPENAI_API_KEY"),
)
tool = slack_post_message.as_langchain_tool(StructuredTool.from_function, user_id)
agent = create_react_agent(
tools=[tool],
model=llm,
)
await agent.ainvoke({
"messages": [
SystemMessage(content="You are a helpful assistant"),
HumanMessage(content="Say hello to my team on slack"),
]
})
2. CrewAI
import os
from integry import Integry
from langchain_openai import ChatOpenAI
user_id = "your user's ID"
# Initialize the client
integry = Integry(
app_key=os.environ.get("INTEGRY_APP_SECRET"),
app_secret=os.environ.get("INTEGRY_APP_KEY"),
)
slack_post_message = await integry.functions.get("slack-post-message", user_id)
tool = slack_post_message.as_langchain_tool(StructuredTool.from_function, user_id)
llm = ChatOpenAI(
model="gpt-4o",
api_key=SecretStr(os.environ.get("OPENAI_API_KEY")),
)
crewai_agent = Agent(
role="Integration Assistant",
goal="You are a helpful assistant",
backstory="You help users make actions on various apps",
verbose=True,
tools=[tool],
llm=llm,
)
task = Task(
description="Say hello to my team on slack",
agent=crewai_agent,
expected_output="Status of the operation"
)
crew = Crew(
agents = [crewai_agent],
tasks = [task]
)
result = crew.kickoff()
3. Letta
import os
from integry import Integry
user_id = "your user's ID"
# Initialize the client
integry = Integry(
app_key=os.environ.get("INTEGRY_APP_SECRET"),
app_secret=os.environ.get("INTEGRY_APP_KEY"),
)
slack_post_message = await integry.functions.get("slack-post-message", user_id)
client = create_client()
agent_state = client.create_agent(
name="Integration Assistant",
)
tool = slack_post_message.as_langchain_tool(StructuredTool.from_function, user_id)
client.add_tool(tool)
response = client.send_message(agent_id=agent_state.id, role="user", message="say hello to my team on Slack")
4. AutoGen (WIP)
import os
from integry import Integry
from autogen import AssistantAgent, UserProxyAgent
user_id = "your user's ID"
# Initialize the client
integry = Integry(
app_key=os.environ.get("INTEGRY_APP_SECRET"),
app_secret=os.environ.get("INTEGRY_APP_KEY"),
)
llm_config = {
"config_list": [
{
"model": "gpt-4o-mini",
"api_key": "<your-api-key>",
}
]
}
chatbot = AssistantAgent(
"chatbot",
system_message="Reply TERMINATE when the task is done or when user's content is empty",
llm_config=llm_config,
)
user_proxy = UserProxyAgent(
name="User",
is_termination_msg=lambda x: x.get("content", "")
and "TERMINATE" in x.get("content", ""),
human_input_mode="NEVER",
code_execution_config={"use_docker": False},
)
toolset.register_tools(apps=[App.GITHUB], caller=chatbot, executor=user_proxy)
response = user_proxy.initiate_chat(chatbot, message="say hello to my team on Slack")
Prediction
import os
from integry import Integry
user_id = "your user's ID"
# Initialize the client
integry = Integry(
app_secret=os.environ.get("INTEGRY_APP_KEY"),
app_key=os.environ.get("INTEGRY_APP_SECRET"),
)
# Get the most relevant function
predictions = await integry.functions.predict(
prompt="say hello to my team on Slack", user_id=user_id, predict_arguments=True
)
if predictions:
function = predictions[0]
# Call the function
await function(user_id, function.arguments)
Pagination
List methods are paginated and allow you to iterate over data without handling pagination manually.
from integry import Integry
user_id = "your user's ID"
integry = Integry(
app_secret=os.environ.get("INTEGRY_APP_KEY"),
app_key=os.environ.get("INTEGRY_APP_SECRET"),
)
async for function in integry.functions.list(user_id):
# do something with function
print(function.name)
If you want to control pagination, you can fetch individual pages by using the cursor returned by the previous page.
from integry import Integry
user_id = "your user's ID"
integry = Integry(
app_secret=os.environ.get("INTEGRY_APP_KEY"),
app_key=os.environ.get("INTEGRY_APP_SECRET"),
)
first_page = await integry.apps.list(user_id)
second_page = await integry.apps.list(user_id, cursor=first_page.cursor)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file integry-0.0.4.tar.gz.
File metadata
- Download URL: integry-0.0.4.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e5c40c809c6b8b669e00cfc04ef57c0acf2bb2b5b99f1c1c50beabcc04593fb
|
|
| MD5 |
97d85969e6a71ff1451ba859f4ecf6c4
|
|
| BLAKE2b-256 |
48ce121284ea5249afc9c44fc323de4fa9ce65e9fcc5e8787fd1cbdeb165c880
|
File details
Details for the file integry-0.0.4-py3-none-any.whl.
File metadata
- Download URL: integry-0.0.4-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72f5374d3281286fded2697c09e605b5d4ce479281fec6fb4757d207908a9453
|
|
| MD5 |
9e4d84b34c5adda02a6faff9b1e912e0
|
|
| BLAKE2b-256 |
fed7ef80cffdd2767603c54649385205708b65f7aa5ebe18cb123d5127ce6635
|