Skip to main content

AI Assistant and Copilot SDK for SaaS Applications

Project description

Meez - AI Assistant and Copilot SDK for SaaS Applications

PyPI-Server Build Status License PyPI Downloads

Meez

AI Assistant and Copilot SDK for SaaS Applications

Meez is a powerful Python library that provides AI-powered assistance capabilities for SaaS applications. It offers intention detection, contextual responses, and workflow automation using LangChain and LangGraph.

Features

  • Intention Detection: Automatically detect user intentions from natural language input

  • Contextual Responses: Generate intelligent responses based on provided context data

  • Workflow Automation: Create complex AI workflows using LangGraph

  • Multiple Data Sources: Support for text, JSON, and file-based data sources

  • OpenAI Integration: Built on top of OpenAI’s GPT models for reliable AI responses

  • Flexible Architecture: Modular design for easy integration and customization

Installation

Install Meez using pip:

pip install Meez

Quick Start

  1. Set up your OpenAI API key:

import os
os.environ["OPENAI_API_KEY"] = "your-openai-api-key-here"
  1. Basic intention detection:

from meez.core import Langchain, Intention

# Initialize LangChain
langchain = Langchain(openai_api_key="your-api-key")

# Define possible intentions
intentions = ["greeting", "weather", "help", "goodbye", "unknown"]

# Create intention detector
detector = Intention(langchain=langchain, intentions=intentions)

# Detect intention
user_input = "Hello there!"
intention = detector.detect(user_input)
print(f"Detected intention: {intention}")
  1. Contextual responses:

from meez.core import Langchain, Respond
from meez.data import TextReader

# Initialize components
langchain = Langchain(openai_api_key="your-api-key")
respond = Respond(langchain)

# Create data source
context_data = "Python is a high-level programming language..."
data_reader = TextReader(context_data)

# Get contextual response
question = "What is Python?"
response = respond.run(question=question, data=data_reader)
print(f"Response: {response}")

Usage Examples

Intention Detection

Detect user intentions from natural language:

import os
from meez.core import Langchain, Intention

# Setup
api_key = os.getenv("OPENAI_API_KEY")
langchain = Langchain(openai_api_key=api_key)

# Define intentions
intentions = [
    "greeting",
    "weather",
    "joke",
    "help",
    "goodbye",
    "book_appointment",
    "cancel_appointment",
    "unknown"
]

# Create detector
detector = Intention(langchain=langchain, intentions=intentions)

# Test inputs
test_texts = [
    "Hello there!",
    "What's the weather like?",
    "I need to book an appointment",
    "Can you help me cancel my appointment?"
]

for text in test_texts:
    intention = detector.detect(text)
    print(f"'{text}' → {intention}")

Contextual Responses

Generate responses based on context data:

from meez.core import Langchain, Respond
from meez.data import TextReader, JsonReader, FileReader

# Initialize
langchain = Langchain(openai_api_key=api_key)
respond = Respond(langchain)

# Using text data
text_data = "Artificial Intelligence is a branch of computer science..."
text_reader = TextReader(text_data)

response = respond.run(
    question="What is AI?",
    data=text_reader
)

# Using JSON data
json_data = {"company": {"name": "TechCorp", "employees": 250}}
json_reader = JsonReader(json_data)

response = respond.run(
    question="How many employees does the company have?",
    data=json_reader
)

# Using file data
file_reader = FileReader("documentation.txt")
response = respond.run(
    question="What are the main features?",
    data=file_reader
)

General Respond

Respond to general user questions using AI knowledge:

from meez.core import Langchain, GeneralRespond

# Initialize
langchain = Langchain(openai_api_key=api_key)
respond = GeneralRespond(langchain)

# Get response
question = "What is the capital of France?"
response = respond.run(question=question)
print(f"Response: {response}")

Workflow Automation with LangGraph

Create complex AI workflows:

from meez.core.langgraph import LangGraph, MainState
from meez.core import Langchain, Intention

# Define workflow nodes
def get_intent(state: MainState) -> MainState:
    # Detect user intention
    detector = Intention(langchain, ["get_phone", "get_email", "unknown"])
    intent = detector.detect(state["messages"][-1]["content"])
    state["messages"].append({"role": "assistant", "content": intent, "internal": True})
    return state

def decide(state: MainState) -> str:
    # Return the detected intent to determine next step
    return state["messages"][-1]["content"]

def get_phone(state: MainState) -> MainState:
    state["messages"].append({"role": "assistant", "content": "Phone: +1234567890"})
    return state

def get_email(state: MainState) -> MainState:
    state["messages"].append({"role": "assistant", "content": "Email: support@company.com"})
    return state

def unknown(state: MainState) -> MainState:
    state["messages"].append({"role": "assistant", "content": "I'm sorry, I don't know that."})
    return state

# Create and configure graph
graph = LangGraph()
graph.add_node("get_intent", get_intent)
graph.add_node("decide", decide)
graph.add_node("get_phone", get_phone)
graph.add_node("get_email", get_email)
graph.add_node("unknown", unknown)

graph.set_entry_point("get_intent")
graph.add_conditional_edge("get_intent", decide)
graph.add_finish_point("get_phone")
graph.add_finish_point("get_email")
graph.add_finish_point("unknown")

# Run workflow
initial_state = {"messages": [{"role": "user", "content": "What's your phone number?"}]}
result = graph.run(initial_state)

Examples

See the examples/ directory for complete working examples:

  • intention_detection.py - Basic intention detection

  • respond_to_user.py - Contextual responses with different data sources

  • complex_graph.py - Advanced workflow automation

  • sample_graph.py - Simple graph workflow

  • sample_assistant.py - Complete assistant implementation

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/clivern/meez.git
cd meez

# Install development dependencies
pip install -r requirements.test.txt
pip install -e .

Running Tests

# Run tests
make ci

Support

Changelog

See CHANGELOG.rst for a detailed history of changes.

Project details


Download files

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

Source Distribution

meez-0.3.4.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

meez-0.3.4-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file meez-0.3.4.tar.gz.

File metadata

  • Download URL: meez-0.3.4.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for meez-0.3.4.tar.gz
Algorithm Hash digest
SHA256 0e2d4e56235995ebe1fb22c945cb08811a6181ffb0ceac6f2c1d757aa12a5713
MD5 e5a9af26c4485071b56576ffa3816659
BLAKE2b-256 d0c207b99a00524494fb4ef7c95f1d02aa1943cb4a21ede7b87c162289422986

See more details on using hashes here.

File details

Details for the file meez-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: meez-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for meez-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1103d68b07c5c54ef9870a8450951d8d13914aac8929e2ba3eae0665dd73fc96
MD5 381b25b47be183054d1d0633dcfb2354
BLAKE2b-256 2aec38d66a78ab80fca405395018d06ac54851ad3b4093b8dcc05a4864089f91

See more details on using hashes here.

Supported by

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