Skip to main content

This package is an updated WYN-Agent package.

Project description

🌟 WYN-Agent-X

WYN-Agent-X is a dynamic and extendable chatbot that integrates with OpenAI and Twilio, allowing you to seamlessly handle user intents and trigger APIs (like sending SMS) based on natural language input. Plus, it’s super friendly and conversational! 🤖💬

Features:

  • AI-Powered Conversations: Uses OpenAI’s GPT models for general chit-chat. Just type away!
  • Trigger-Based API Calls: Automatically detects when users want to perform specific tasks (like sending a message), and triggers the corresponding API call.
  • Easy to Extend: Add more APIs by simply updating the metadata.json file. No need to dig into the core logic! 🌱

🚀 Installation

You can easily install the package via pip:

pip install wyn-agent-x

📂 Directory Structure

wyn-agent-x/
│
├── requirements.txt     # List of dependencies to install
├── wyn_agent_x/
│   ├── __init__.py      # Initializes the package   ├── main.py          # Main entry point for the chatbot   ├── helper.py        # Helper functions and processing logic   ├── list_of_apis.py  # All API functions registered here   ├── metadata.json    # Dynamic metadata for API calls and trigger words
│── pyproject.toml       # Optional config if packaging the project
└── README.md            # You're reading this!

System Diagram

The system is designed with an intent processor interpreting the prompt's purpose from the user. After intent processor determines the necessary API required for execution, it attemps to fill up the required input parameters in the input payload. For the unfilled parameters, the resolver bounces the questions back to the user to seek more information before execution. This process interates until all required parameters are filled.

For system giagram, please see here

🎮 Sample Usage

Want to try it out? Just import the AgentX class, provide your API keys, and start chatting with your agent!

from google.colab import userdata

# Fetch API credentials
OPENAI_API_KEY = userdata.get('OPENAI_API_KEY')
TWILIO_ACCOUNT_SID = userdata.get("YOUR_TWILIO_ACCOUNT_SID")
TWILIO_AUTH_TOKEN = userdata.get("YOUR_TWILIO_AUTH_TOKEN")
SERPAPI_API_KEY = userdata.get("SERPAPI_API_KEY")

# Import the agent
from wyn_agent_x.main import AgentX

# Initialize and start the chat!
agent = AgentX(
    api_key=OPENAI_API_KEY,
    account_sid=TWILIO_ACCOUNT_SID,
    auth_token=TWILIO_AUTH_TOKEN,
    serpapi_key=SERPAPI_API_KEY,
    protocol='You are a helpful assistant.')
agent.start_chat()

Once started, you'll see this friendly message:

👋 Welcome! Press 'EXIT' to quit the chat at any time.

Feel free to chat with the bot, ask it to send messages, or perform any task you've configured in the metadata. When you're done, simply type EXIT to end the session with a friendly goodbye! 👋

For yfinance demo, please see here

You can also access this notebook.


📖 How it Works

  1. Intent Detection: The agent listens for specific trigger words (like "send a message" or "set a demo") from user input and matches them against the triggers defined in metadata.json.

  2. API Calls: When an intent is detected (e.g., sending an SMS), it calls the corresponding API (like Twilio's SMS API) and logs the event in the event_stream.

  3. Dynamic Functions: Adding a new API or intent is as simple as updating the metadata.json file and registering the new API in list_of_apis.py. No need to modify core logic! 🚀


🛠️ Extend and Customize

You can easily extend WYN-Agent-X by adding new API calls or intents:

  1. Update metadata.json with new API information and trigger words:

    {
        "send_email": {
            "trigger_word": ["send email", "notify via email"],
            "sample_payload": {"email": "string", "subject": "string"},
            "prerequisite": null
        }
    }
    
  2. Register your new API in list_of_apis.py with a simple decorator:

    @register_function("send_sms")
     def send_sms(payload: Dict[str, str], secrets: Dict[str, str], event_stream: list) -> Dict[str, Any]:
        # Code to send email goes here!
        pass
    

📜 License

MIT License - Enjoy, use, and extend this project freely! 🥳


👤 Author

Yiqiao Yin

📧 Email: eagle0504@gmail.com

Feel free to reach out if you have any questions, suggestions, or just want to say hi! 😊

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

wyn_agent_x-0.3.8.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

wyn_agent_x-0.3.8-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file wyn_agent_x-0.3.8.tar.gz.

File metadata

  • Download URL: wyn_agent_x-0.3.8.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.13 Windows/10

File hashes

Hashes for wyn_agent_x-0.3.8.tar.gz
Algorithm Hash digest
SHA256 2e1982afb859e009f85b1dddac8b93c44c219aa9d66abad07ae5c0643c1e9640
MD5 f5a97497e7ae0380fc54003a3446fce5
BLAKE2b-256 88f6934a17350e82cb87ce0d10f64c5fd925be7f7dc7b3f2efa336033ad060fb

See more details on using hashes here.

File details

Details for the file wyn_agent_x-0.3.8-py3-none-any.whl.

File metadata

  • Download URL: wyn_agent_x-0.3.8-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.13 Windows/10

File hashes

Hashes for wyn_agent_x-0.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 ade9a6652757a1936bbf40d524c356fd16979ab55978d4cd52dce2da8e5da394
MD5 be16a4c6e8af29e0c98682db3b024a70
BLAKE2b-256 898059129df9099ea3f7046179914d52d237d8b12220a64d006f15254ca71de8

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