Skip to main content

Python API to use WorkHub API for conversational AI.

Project description

Workhub API Client

The Workhub API Client is a Python package designed to simplify interactions with the Workhub API. It supports user authentication, company information retrieval, conversation management, message handling, and direct integration with GPT-4 for processing messages.

Features

  • User authentication
  • Fetch company information
  • Manage conversations
  • Send messages with optional GPT-4 processing
  • Stream bot responses directly after sending a message

Installation

To install the Workhub API Client, use pip:

pip install workhub-client

Quick Start

Initialize the Client

First, create an instance of the WorkhubClient:

from workhub_client import WorkhubClient

client = WorkhubClient()

Authenticate

Log in using your Workhub credentials:

client.login('your_email@example.com', 'your_password')

Fetch Company Information

Retrieve and automatically set your active company UUID:

company_info = client.get_company_info()
print(company_info)

Send a Message

Send a message to a specific conversation. You can specify GPT-4 processing by setting document_type='GPT4'.

conversation_uuid = 'your_conversation_uuid_here'
response = client.send_user_message(
    conversation_uuid,
    "What's the weather like today?",
    document_type='GPT4'
)
print(response)

Stream Bot Responses

Send a user message and directly stream the bot's response:

client.stream_bot_message(
    conversation_uuid="your_conversation_uuid",
    content="when was uark founded?",
    document_type="GPT4"
)

This method sends a message and immediately starts listening for and printing the streamed response from the bot.

Workhub API Client Example

This section provides a simple Python program example that uses the Workhub API Client to authenticate, fetch company information, send a message with GPT-4 processing, and stream the bot's response.

Example Program

from workhub_client import WorkHubClient

def main():
    # Initialize the Workhub API client
    client = WorkHubClient()

    # Login with your Workhub credentials
    print("Logging in...")
    client.login('your_email@example.com', 'your_password')

    # Fetch and display company information
    print("Fetching company information...")
    company_info = client.get_company_info()
    print(f"Company Info: {company_info}")

    # Specify the UUID of the conversation you want to interact with
    conversation_uuid = 'your_conversation_uuid_here'

    # Send a message using GPT-4 processing and display the response
    print("Sending a message with GPT-4 processing...")
    message_response = client.send_user_message(
        conversation_uuid,
        "What's the weather like today?",
        document_type='GPT4'
    )
    print(f"Message Response: {message_response}")

    # Stream bot's response directly after sending a message
    print("Streaming bot's response...")
    client.stream_bot_message(
        conversation_uuid=conversation_uuid,
        content="when was uark founded?",
        document_type="GPT4"
    )

if __name__ == "__main__":
    main()

Running the Example

  1. Replace 'your_email@example.com', 'your_password', and 'your_conversation_uuid_here' with your actual Workhub credentials and the UUID of the conversation you want to send a message to.
  2. Save the program to a file, for example, workhub_example.py.
  3. Run the program using Python:
python workhub_example.py

This example demonstrates the core functionalities of the Workhub API Client, making it easy for users to understand how to use the package in their applications. Remember, when sharing or using your credentials and sensitive information, always ensure they are secured and not hardcoded in production scripts.

Contributing

Contributions to the Workhub API Client are welcome. Please feel free to submit pull requests or report issues to improve the project.

License

This project is released under the MIT License.

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

workhub_client-1.0.7.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

workhub_client-1.0.7-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file workhub_client-1.0.7.tar.gz.

File metadata

  • Download URL: workhub_client-1.0.7.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for workhub_client-1.0.7.tar.gz
Algorithm Hash digest
SHA256 1193729a0eb933669000f4f97c9ae9ef836709c6298b125fe12b39bb850cf1ab
MD5 53a26006fdc33d1f87784d8243fbf25b
BLAKE2b-256 3f7271be45120e6931721a62192c6deaea072809a2bc6d4f42a4c56894cae279

See more details on using hashes here.

File details

Details for the file workhub_client-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: workhub_client-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for workhub_client-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b5836873f12fefdce18620ac44474e29201913881d601a53b80d060fe0a97d91
MD5 82a0853144ef9213b29a3b77c802c777
BLAKE2b-256 5794a6c367d6676b4e123e07c8f188a5001d110f6f85f6a5d0b9d260ad8be747

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