lexrchainer-client


Namelexrchainer-client JSON
Version 0.1.4 PyPI version JSON
download
home_pageNone
SummaryPython client library for interacting with the LexrChainer API
upload_time2025-07-08 11:49:22
maintainerNone
docs_urlNone
authorLexrChainer Team
requires_python>=3.8
licenseNone
keywords agent ai api conversation llm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # LexrChainer Client

A Python client library for interacting with the LexrChainer API.

## Installation

```bash
pip install lexrchainer-client
```

## Configuration

Configure the client using environment variables:

```bash
# API Key authentication
LEXRCHAINER_API_KEY=your_api_key

# Or JWT token authentication
LEXRCHAINER_JWT_TOKEN=your_jwt_token

# API URL (default: http://localhost:8000)
LEXRCHAINER_API_URL=http://your-api-url
```

## Usage

### 1. Agent Builder Interface

#### Creating a Single Agent

```python
from lexrchainer.client import AgentBuilder

# Create an agent with basic configuration
agent = (AgentBuilder("Simple Assistant")
    .with_model("gpt-4")
    .with_system_prompt("You are a helpful assistant")
    .with_description("A simple assistant for basic tasks")
    .create_agent())

# Send a message to the agent
response = agent.send_message("Hello, how are you?")
```

#### Advanced Agent Configuration

```python
agent = (AgentBuilder("Advanced Assistant")
    .with_model("gpt-4", temperature=0.7, max_tokens=1000)  # Model with parameters
    .with_system_prompt("You are a helpful assistant")
    .with_description("An advanced assistant with multiple tools")
    .with_tool("search")  # Add a tool
    .with_tool("calculator", credentials={"api_key": "your_key"})  # Add a tool with credentials
    .with_static_meta({"version": "1.0", "category": "general"})  # Add static metadata
    .create_agent())
```

#### Custom Steps Configuration

```python
agent = (AgentBuilder("Step-Based Assistant")
    .with_model("gpt-4")
    .add_step(
        name="Research Step",
        prompt="Research the given topic thoroughly.",
        type="HIDDEN_TURN_USER",
        flow="TO_USER",
        flow_type="AT_ONCE",
        tool_use=True
    )
    .add_step(
        name="Summary Step",
        prompt="Summarize the research findings.",
        flow_state="CONTINUE",
        response_treatment="APPEND"
    )
    .create_agent())
```

#### Managing Existing Agents

```python
# Load an existing agent
agent = AgentBuilder("Existing Assistant").load_agent(agent_id="agent_123", conversation_id="conv_456")

# Update an existing agent
updated_agent = (AgentBuilder("Updated Assistant")
    .with_model("gpt-4")
    .with_system_prompt("New system prompt")
    .update_agent(agent_id="agent_123"))

# Get agent conversations
conversations = agent.get_agent_conversations(medium="WHATSAPP")

# Get all available agents
agents = agent.get_agents()
```

#### Creating Multiple Agents

```python
from lexrchainer.client import MultiAgentBuilder

# Create multiple agents
multi_agent = MultiAgentBuilder()

# Configure first agent
assistant = multi_agent.add_agent("Assistant")
assistant.with_model("gpt-4").with_system_prompt("You are a helpful assistant")

# Configure second agent
expert = multi_agent.add_agent("Expert")
expert.with_model("gpt-4").with_system_prompt("You are an expert in your field")

# Create all agents and start conversation
agents = multi_agent.create_agents()

# Send a message to all agents
responses = agents.send_message("Hello everyone!")
```

### 2. Conversation API

```python
from lexrchainer.client import ClientInterface

client = ClientInterface()

# Create a conversation
conversation = client.create_conversation({
    "medium": "WHATSAPP",
    "members": [...],
    "turn_type": "SEQUENTIAL",
    "iteration_end_criteria": "ALL_TURNS_DONE"
})

# Send a message
response = client.send_message(
    conversation_id="conv_123",
    messages=[...],
    streaming=True
)

# Add/remove members
client.add_conversation_member("conv_123", "user_456", "ACTIVE_PARTICIPATION")
client.remove_conversation_member("conv_123", "user_456")

# Get conversation messages
messages = client.get_conversation_messages("conv_123")

# Send message to specific agent
response = client.send_message_to_agent("agent_name", {
    "messages": [...],
    "streaming": True
})

# Send message to public agent
response = client.send_public_agent_message("public_agent", {
    "messages": [...],
    "streaming": True
})
```

### 3. User API

```python
from lexrchainer.client import ClientInterface

client = ClientInterface()

# Create a user
user = client.create_user({
    "username": "john_doe",
    "email": "john@example.com",
    "phone": "+1234567890",
    "user_type": "HUMAN"
})

# Get user details
user = client.get_user("user_123")

# Update user
updated_user = client.update_user("user_123", {
    "email": "new_email@example.com"
})

# Delete user
client.delete_user("user_123")

# List users
users = client.list_users(skip=0, limit=100)

# Get current user
current_user = client.get_current_user()
```

### 4. Organization API

```python
from lexrchainer.client import ClientInterface

client = ClientInterface()

# Create organization
org = client.create_organization({
    "name": "My Organization"
})

# Update organization
updated_org = client.update_organization("org_123", {
    "name": "Updated Organization Name"
})
```

### 5. Workspace API

```python
from lexrchainer.client import ClientInterface

client = ClientInterface()

# Create workspace
workspace = client.create_workspace({
    "name": "My Workspace",
    "description": "A workspace for collaboration",
    "is_private": True
})

# Get workspace
workspace = client.get_workspace("workspace_123")

# Update workspace
updated_workspace = client.update_workspace("workspace_123", {
    "name": "Updated Workspace Name"
})

# Delete workspace
client.delete_workspace("workspace_123")

# List workspaces
workspaces = client.list_workspaces(skip=0, limit=100)

# Manage workspace members
members = client.list_workspace_members("workspace_123")
client.add_workspace_member("workspace_123", {
    "user_id": "user_456",
    "role": "member"
})
client.remove_workspace_member("workspace_123", "user_456")
```

### 6. Chain API

```python
from lexrchainer.client import ClientInterface

client = ClientInterface()

# Create chain
chain = client.create_chain({
    "name": "My Chain",
    "description": "A custom chain",
    "json_content": {...}
})

# Get chain
chain = client.get_chain("chain_123")

# Update chain
updated_chain = client.update_chain("chain_123", {
    "description": "Updated description"
})

# Delete chain
client.delete_chain("chain_123")

# List chains
chains = client.list_chains(skip=0, limit=100)

# Trigger chain execution
result = client.trigger_chain("chain_123", {
    "message": "Hello",
    "meta_data": {...}
})

# Schedule chain execution
schedule = client.schedule_chain("chain_123", {
    "cron": "0 0 * * *",
    "message": "Scheduled message"
})
```

## Features

- Simple and intuitive API
- Support for single and multi-agent conversations
- Advanced tool integration with credential support
- Custom step configuration with flow control
- Static metadata support
- Agent management (create, update, load)
- Streaming responses
- Authentication via API key or JWT token
- Error handling and validation
- Complete coverage of all API endpoints
- Type hints and documentation

## License

MIT License 
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "lexrchainer-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "agent, ai, api, conversation, llm",
    "author": "LexrChainer Team",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/0f/4d/fd2120878cd24030ea7ee68b179d09858d493dee799c2ecaf9714b47c60a/lexrchainer_client-0.1.4.tar.gz",
    "platform": null,
    "description": "# LexrChainer Client\n\nA Python client library for interacting with the LexrChainer API.\n\n## Installation\n\n```bash\npip install lexrchainer-client\n```\n\n## Configuration\n\nConfigure the client using environment variables:\n\n```bash\n# API Key authentication\nLEXRCHAINER_API_KEY=your_api_key\n\n# Or JWT token authentication\nLEXRCHAINER_JWT_TOKEN=your_jwt_token\n\n# API URL (default: http://localhost:8000)\nLEXRCHAINER_API_URL=http://your-api-url\n```\n\n## Usage\n\n### 1. Agent Builder Interface\n\n#### Creating a Single Agent\n\n```python\nfrom lexrchainer.client import AgentBuilder\n\n# Create an agent with basic configuration\nagent = (AgentBuilder(\"Simple Assistant\")\n    .with_model(\"gpt-4\")\n    .with_system_prompt(\"You are a helpful assistant\")\n    .with_description(\"A simple assistant for basic tasks\")\n    .create_agent())\n\n# Send a message to the agent\nresponse = agent.send_message(\"Hello, how are you?\")\n```\n\n#### Advanced Agent Configuration\n\n```python\nagent = (AgentBuilder(\"Advanced Assistant\")\n    .with_model(\"gpt-4\", temperature=0.7, max_tokens=1000)  # Model with parameters\n    .with_system_prompt(\"You are a helpful assistant\")\n    .with_description(\"An advanced assistant with multiple tools\")\n    .with_tool(\"search\")  # Add a tool\n    .with_tool(\"calculator\", credentials={\"api_key\": \"your_key\"})  # Add a tool with credentials\n    .with_static_meta({\"version\": \"1.0\", \"category\": \"general\"})  # Add static metadata\n    .create_agent())\n```\n\n#### Custom Steps Configuration\n\n```python\nagent = (AgentBuilder(\"Step-Based Assistant\")\n    .with_model(\"gpt-4\")\n    .add_step(\n        name=\"Research Step\",\n        prompt=\"Research the given topic thoroughly.\",\n        type=\"HIDDEN_TURN_USER\",\n        flow=\"TO_USER\",\n        flow_type=\"AT_ONCE\",\n        tool_use=True\n    )\n    .add_step(\n        name=\"Summary Step\",\n        prompt=\"Summarize the research findings.\",\n        flow_state=\"CONTINUE\",\n        response_treatment=\"APPEND\"\n    )\n    .create_agent())\n```\n\n#### Managing Existing Agents\n\n```python\n# Load an existing agent\nagent = AgentBuilder(\"Existing Assistant\").load_agent(agent_id=\"agent_123\", conversation_id=\"conv_456\")\n\n# Update an existing agent\nupdated_agent = (AgentBuilder(\"Updated Assistant\")\n    .with_model(\"gpt-4\")\n    .with_system_prompt(\"New system prompt\")\n    .update_agent(agent_id=\"agent_123\"))\n\n# Get agent conversations\nconversations = agent.get_agent_conversations(medium=\"WHATSAPP\")\n\n# Get all available agents\nagents = agent.get_agents()\n```\n\n#### Creating Multiple Agents\n\n```python\nfrom lexrchainer.client import MultiAgentBuilder\n\n# Create multiple agents\nmulti_agent = MultiAgentBuilder()\n\n# Configure first agent\nassistant = multi_agent.add_agent(\"Assistant\")\nassistant.with_model(\"gpt-4\").with_system_prompt(\"You are a helpful assistant\")\n\n# Configure second agent\nexpert = multi_agent.add_agent(\"Expert\")\nexpert.with_model(\"gpt-4\").with_system_prompt(\"You are an expert in your field\")\n\n# Create all agents and start conversation\nagents = multi_agent.create_agents()\n\n# Send a message to all agents\nresponses = agents.send_message(\"Hello everyone!\")\n```\n\n### 2. Conversation API\n\n```python\nfrom lexrchainer.client import ClientInterface\n\nclient = ClientInterface()\n\n# Create a conversation\nconversation = client.create_conversation({\n    \"medium\": \"WHATSAPP\",\n    \"members\": [...],\n    \"turn_type\": \"SEQUENTIAL\",\n    \"iteration_end_criteria\": \"ALL_TURNS_DONE\"\n})\n\n# Send a message\nresponse = client.send_message(\n    conversation_id=\"conv_123\",\n    messages=[...],\n    streaming=True\n)\n\n# Add/remove members\nclient.add_conversation_member(\"conv_123\", \"user_456\", \"ACTIVE_PARTICIPATION\")\nclient.remove_conversation_member(\"conv_123\", \"user_456\")\n\n# Get conversation messages\nmessages = client.get_conversation_messages(\"conv_123\")\n\n# Send message to specific agent\nresponse = client.send_message_to_agent(\"agent_name\", {\n    \"messages\": [...],\n    \"streaming\": True\n})\n\n# Send message to public agent\nresponse = client.send_public_agent_message(\"public_agent\", {\n    \"messages\": [...],\n    \"streaming\": True\n})\n```\n\n### 3. User API\n\n```python\nfrom lexrchainer.client import ClientInterface\n\nclient = ClientInterface()\n\n# Create a user\nuser = client.create_user({\n    \"username\": \"john_doe\",\n    \"email\": \"john@example.com\",\n    \"phone\": \"+1234567890\",\n    \"user_type\": \"HUMAN\"\n})\n\n# Get user details\nuser = client.get_user(\"user_123\")\n\n# Update user\nupdated_user = client.update_user(\"user_123\", {\n    \"email\": \"new_email@example.com\"\n})\n\n# Delete user\nclient.delete_user(\"user_123\")\n\n# List users\nusers = client.list_users(skip=0, limit=100)\n\n# Get current user\ncurrent_user = client.get_current_user()\n```\n\n### 4. Organization API\n\n```python\nfrom lexrchainer.client import ClientInterface\n\nclient = ClientInterface()\n\n# Create organization\norg = client.create_organization({\n    \"name\": \"My Organization\"\n})\n\n# Update organization\nupdated_org = client.update_organization(\"org_123\", {\n    \"name\": \"Updated Organization Name\"\n})\n```\n\n### 5. Workspace API\n\n```python\nfrom lexrchainer.client import ClientInterface\n\nclient = ClientInterface()\n\n# Create workspace\nworkspace = client.create_workspace({\n    \"name\": \"My Workspace\",\n    \"description\": \"A workspace for collaboration\",\n    \"is_private\": True\n})\n\n# Get workspace\nworkspace = client.get_workspace(\"workspace_123\")\n\n# Update workspace\nupdated_workspace = client.update_workspace(\"workspace_123\", {\n    \"name\": \"Updated Workspace Name\"\n})\n\n# Delete workspace\nclient.delete_workspace(\"workspace_123\")\n\n# List workspaces\nworkspaces = client.list_workspaces(skip=0, limit=100)\n\n# Manage workspace members\nmembers = client.list_workspace_members(\"workspace_123\")\nclient.add_workspace_member(\"workspace_123\", {\n    \"user_id\": \"user_456\",\n    \"role\": \"member\"\n})\nclient.remove_workspace_member(\"workspace_123\", \"user_456\")\n```\n\n### 6. Chain API\n\n```python\nfrom lexrchainer.client import ClientInterface\n\nclient = ClientInterface()\n\n# Create chain\nchain = client.create_chain({\n    \"name\": \"My Chain\",\n    \"description\": \"A custom chain\",\n    \"json_content\": {...}\n})\n\n# Get chain\nchain = client.get_chain(\"chain_123\")\n\n# Update chain\nupdated_chain = client.update_chain(\"chain_123\", {\n    \"description\": \"Updated description\"\n})\n\n# Delete chain\nclient.delete_chain(\"chain_123\")\n\n# List chains\nchains = client.list_chains(skip=0, limit=100)\n\n# Trigger chain execution\nresult = client.trigger_chain(\"chain_123\", {\n    \"message\": \"Hello\",\n    \"meta_data\": {...}\n})\n\n# Schedule chain execution\nschedule = client.schedule_chain(\"chain_123\", {\n    \"cron\": \"0 0 * * *\",\n    \"message\": \"Scheduled message\"\n})\n```\n\n## Features\n\n- Simple and intuitive API\n- Support for single and multi-agent conversations\n- Advanced tool integration with credential support\n- Custom step configuration with flow control\n- Static metadata support\n- Agent management (create, update, load)\n- Streaming responses\n- Authentication via API key or JWT token\n- Error handling and validation\n- Complete coverage of all API endpoints\n- Type hints and documentation\n\n## License\n\nMIT License ",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python client library for interacting with the LexrChainer API",
    "version": "0.1.4",
    "project_urls": {
        "Documentation": "https://lexrchainer.readthedocs.io/",
        "Homepage": "https://github.com/yourusername/lexrchainer",
        "Issues": "https://github.com/yourusername/lexrchainer/issues",
        "Repository": "https://github.com/yourusername/lexrchainer.git"
    },
    "split_keywords": [
        "agent",
        " ai",
        " api",
        " conversation",
        " llm"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b0a5bd884c68e00e5734dc3aa6cc1abe30de36beec46c3f6906be88f5bf7678b",
                "md5": "1e3e2ea3faf3cff546262ed96b675322",
                "sha256": "88add7896ff09dbfc800fa5a1d7b5d0142954dd0da784cae42ae3ff00d676c83"
            },
            "downloads": -1,
            "filename": "lexrchainer_client-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1e3e2ea3faf3cff546262ed96b675322",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 16740,
            "upload_time": "2025-07-08T11:49:19",
            "upload_time_iso_8601": "2025-07-08T11:49:19.902319Z",
            "url": "https://files.pythonhosted.org/packages/b0/a5/bd884c68e00e5734dc3aa6cc1abe30de36beec46c3f6906be88f5bf7678b/lexrchainer_client-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0f4dfd2120878cd24030ea7ee68b179d09858d493dee799c2ecaf9714b47c60a",
                "md5": "613da642b77ca47962757066ab7f9198",
                "sha256": "8fc586089c1753ad08fc7f480c503fd61a177a3ad8cbbfbed0a79c5cac5a9595"
            },
            "downloads": -1,
            "filename": "lexrchainer_client-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "613da642b77ca47962757066ab7f9198",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 23008,
            "upload_time": "2025-07-08T11:49:22",
            "upload_time_iso_8601": "2025-07-08T11:49:22.557062Z",
            "url": "https://files.pythonhosted.org/packages/0f/4d/fd2120878cd24030ea7ee68b179d09858d493dee799c2ecaf9714b47c60a/lexrchainer_client-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-08 11:49:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yourusername",
    "github_project": "lexrchainer",
    "github_not_found": true,
    "lcname": "lexrchainer-client"
}
        
Elapsed time: 0.42857s