Skip to main content

Add your description here

Project description

Framewise Meet Client

A Python client library for building interactive applications with the Framewise API.

Installation

Install the package using pip:

pip install -r requirements.txt

Getting Started

Basic Usage

from src.app import App
from src.models.messages import TranscriptMessage

# Create an app instance with your API key
app = App(api_key="your_api_key_here")

# Join a specific meeting
app.join_meeting(meeting_id="your_meeting_id")

# Define an event handler for transcripts
@app.on_transcript()
def handle_transcript(message: TranscriptMessage):
    transcript = message.content.text
    is_final = message.content.is_final
    print(f"Received: {transcript}")

# Define an event handler for final transcripts using invoke
@app.invoke
def process_command(message: TranscriptMessage):
    command = message.content.text
    print(f"Processing command: {command}")
    
    # Send a response
    app.send_generated_text(f"I received: {command}")

# Run the app
if __name__ == "__main__":
    app.run()

Features

Authentication

The client supports API key authentication:

app = App(api_key="your_api_key_here")

Message Types

The client supports several message types:

  1. Transcripts: Real-time speech transcriptions
  2. Join/Exit Events: Notifications when users join or leave
  3. MCQ Questions: Multiple-choice questions
  4. Custom UI Elements: Flexible UI components

Event Handlers

Register handlers for different event types:

# Using typed method
@app.on_transcript()
def handle_transcript(message: TranscriptMessage):
    print(f"Transcript: {message.content.text}")

# Using general method
@app.on("mcq_selection")
def handle_mcq_selection(message: MCQSelectionMessage):
    print(f"Selected: {message.content.selectedOption}")

# Using invoke for final transcripts
@app.invoke
def process_final(message: TranscriptMessage):
    print(f"Final transcript: {message.content.text}")

Sending Responses

Send various types of responses:

# Send text
app.send_text("Hello there!")

# Send generated text (with streaming support)
app.send_generated_text("Processing your request...", is_generation_end=False)
app.send_generated_text("Here's the answer!", is_generation_end=True)

# Send an MCQ question
app.send_mcq(
    question="How would you like to proceed?",
    options=["Continue", "Start over", "Exit"],
    correct_index=0
)

# Send a custom UI element
app.send_custom_ui_element("card", {
    "title": "Important Information",
    "content": "This is a custom card element",
    "buttons": ["OK", "Cancel"]
})

Multiple-Choice Questions (MCQs)

The Framewise client provides robust support for creating and handling multiple-choice questions:

Sending MCQs

There are two ways to send MCQs to the user:

1. Traditional MCQs

# Send a standard MCQ
app.send_mcq(
    question="What's your favorite color?",
    options=["Red", "Blue", "Green", "Yellow"],
    correct_index=0  # Optional - marks the first option as "correct"
)

2. Enhanced MCQs via Custom UI

# Send an MCQ with a unique ID for tracking responses
import uuid
question_id = str(uuid.uuid4())

app.send_mcq_question(
    question_id=question_id,
    question="How would you rate this service?",
    options=["Excellent", "Good", "Fair", "Poor"]
)

Handling MCQ Responses

When a user selects an option from an MCQ, you'll receive an mcq_selection event:

@app.on_mcq_selection
def handle_mcq_selection(message: MCQSelectionMessage):
    # Get the selected option text
    selected_option = message.content.selectedOption
    
    # Get the selected option index (0-based)
    selected_index = message.content.selectedIndex
    
    # Get the question ID (if provided in the original MCQ)
    question_id = message.content.questionId
    
    print(f"User selected '{selected_option}' (index: {selected_index}) for question {question_id}")
    
    # Respond based on the selection
    if selected_option == "Excellent":
        app.send_text("Thank you for your positive feedback!")
    else:
        app.send_text(f"You selected: {selected_option}. We appreciate your feedback.")

MCQ Message Format

When receiving an MCQ selection, the message structure is:

{
    "type": "mcq_selection",
    "content": {
        "selectedOption": "Option text that was selected",
        "selectedIndex": 2,  # Zero-based index of the selected option
        "questionId": "unique-id-if-provided"  # Only present if you used send_mcq_question
    }
}

This structure is automatically parsed into the MCQSelectionMessage object when using the @app.on_mcq_selection decorator.

Custom UI Elements

The Framewise client supports custom UI elements with direct subtype handling:

Handling UI Element Types

Each custom UI element has a specific type that you can handle directly:

# Handle "mcq_question" UI elements directly
@app.on_ui_type("mcq_question")
def handle_mcq_question(message: CustomUIElementMessage):
    data = message.content.data
    selected_option = data.get("selectedOption")
    question_id = data.get("id")
    print(f"MCQ response: {selected_option} for question {question_id}")
    app.send_generated_text(f"You chose: {selected_option}")

# Handle "info_card" UI elements
@app.on_ui_type("info_card") 
def handle_info_card(message: CustomUIElementMessage):
    data = message.content.data
    action = data.get("action")
    print(f"Info card action: {action}")
    app.send_generated_text(f"Action taken: {action}")

Generic Handler vs Specific Handlers

You can use both specific handlers for known UI types and a generic fallback:

# Specific handler
@app.on_ui_type("poll")
def handle_poll(message: CustomUIElementMessage):
    # Handle poll responses
    pass

# Generic handler for any other UI types
@app.on_custom_ui_response()
def handle_any_ui(message: CustomUIElementMessage):
    ui_type = message.content.type
    if ui_type not in ["mcq_question", "info_card", "poll"]:
        # Handle unknown UI types
        pass

Advanced Features

Meeting Creation

Create meetings programmatically:

app = App(api_key="your_api_key_here")

# Create a meeting
meeting_data = app.create_meeting(
    meeting_id="new_meeting_123",
    start_time_utc="2023-06-01T15:00:00Z",
    end_time_utc="2023-06-01T16:00:00Z"
)

# Join the created meeting
app.join_meeting(meeting_id=meeting_data["meeting_id"])

Logging

Configure logging level when running the app:

app.run(log_level="DEBUG")  # Other options: INFO, WARNING, ERROR, CRITICAL

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

framewise_meet_client-0.1.1.tar.gz (710.8 kB view details)

Uploaded Source

Built Distribution

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

framewise_meet_client-0.1.1-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file framewise_meet_client-0.1.1.tar.gz.

File metadata

  • Download URL: framewise_meet_client-0.1.1.tar.gz
  • Upload date:
  • Size: 710.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for framewise_meet_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8a5c488686743c36e7d99246b692ade0ebee859202cfef08f3de2570f8001e85
MD5 0581802bbfe7ab3cb1afe0691ca9d1f2
BLAKE2b-256 2c72fd1e4e778d9c6d70ee81d82b4d9a090c847c50a106236fed9598398aa9b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for framewise_meet_client-0.1.1.tar.gz:

Publisher: python-publish.yml on Framewise-AI/framewise_meet_client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file framewise_meet_client-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for framewise_meet_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ec54a213c57a4419101275ad1bd78f46f4f782c9e332d4cd73f364a2ee400dd
MD5 31428f445419cfbeb13ad0a6bd9d9fbc
BLAKE2b-256 d8491f9aefc7a9b10e43d40690bc679ba8741792d1ba2445329b7d7d038774c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for framewise_meet_client-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on Framewise-AI/framewise_meet_client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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