- OpenAI Compatible Chat Node with complete input compatibility - Support for multiple OpenAI-compatible API endpoints - Multi-turn conversation support with context persistence - Image and file support for vision models and document analysis - Advanced options configuration - Comprehensive test suite - Robust error handling and edge case management - Complete documentation and examples
4.6 KiB
4.6 KiB
Nino-utils Implementation Summary
Overview
Successfully created a new ComfyUI custom node collection called "Nino-utils" with an OpenAI Compatible Chat node that works with any OpenAI-compatible API endpoint.
What Was Created
1. Core Files
__init__.py- Package initialization with proper exportsnodes.py- Main implementation of the OpenAI Compatible Chat nodepyproject.toml- Project configuration and dependenciesrequirements.txt- Python dependencies list
2. Documentation
README.md- Comprehensive documentation with usage examplesexample_configurations.md- Detailed configuration examples for different servicesIMPLEMENTATION_SUMMARY.md- This summary document
3. Testing & Examples
test_node.py- Comprehensive test suite (all tests pass ✅)example_workflow.json- Example ComfyUI workflowinstall.py- Automated installation script
Key Features
OpenAI Compatible Chat Node
- Complete Input Compatibility: All inputs from the original ChatGPT node are supported
- Flexible API Support: Works with Lemonade, Ollama, OpenAI API, LM Studio, and any OpenAI-compatible endpoint
- Same Interface: Maintains the same input/output interface as the original ChatGPT node
- Multi-turn Conversations: Context persistence for ongoing conversations
- Image Support: Vision model support with image inputs
- File Support: Document analysis with file inputs
- Advanced Options: Fine-tuned control with advanced configuration
- Configurable Parameters: Temperature, top_p, max_tokens, system messages
- Error Handling: Robust error handling for API failures
Input Parameters
Required:
prompt- Text input for the modelapi_url- OpenAI-compatible endpoint URLmodel- Model name (e.g., gpt-4o-mini, llama3.2)api_key- Authentication key (empty for local servers)persist_context- Enable multi-turn conversations
Optional:
images- Image inputs for vision modelsfiles- File inputs for document analysis (OPENAI_INPUT_FILES type)advanced_options- Advanced configuration (OPENAI_CHAT_CONFIG type)max_tokens- Response length limittemperature- Creativity control (0.0-2.0)top_p- Diversity control (0.0-1.0)system_message- Assistant behavior setting
Tested Configurations
✅ Lemonade Server: http://127.0.0.1:35841/v1/chat/completions
✅ Ollama: http://localhost:11434/v1/chat/completions
✅ OpenAI API: https://api.openai.com/v1/chat/completions
✅ LM Studio: http://localhost:1234/v1/chat/completions
Installation
The node collection is ready to use. Simply:
- The collection is already in
/home/nino/ComfyUI/custom_nodes/nino-utils/ - Restart ComfyUI
- Look for "OpenAI Compatible Chat" in the "Nino-utils" category
- Run
uv run python install.pyif you need to install dependencies
Usage in Workflows
The node can be used as a drop-in replacement for the original ChatGPT node:
- API URL: Set your endpoint (e.g.,
http://127.0.0.1:35841/v1/chat/completions) - Model: Specify model name (e.g.,
gpt-4o-mini) - API Key: Leave empty for local servers, add key for cloud services
- Prompt: Enter your text
- Connect: Link to other nodes as needed
Technical Implementation
- Async Support: Uses aiohttp for non-blocking HTTP requests
- Image Processing: Converts ComfyUI tensors to base64 for API transmission
- History Management: Maintains conversation context across calls
- Error Handling: Comprehensive error handling with meaningful messages
- ComfyUI Integration: Follows ComfyUI node patterns and conventions
- FUNCTION Attribute: Properly set to "api_call" for ComfyUI execution system
Next Steps
The collection is ready for use and can be extended with additional utility nodes as needed. The foundation is solid and follows ComfyUI best practices.
Files Created
/home/nino/ComfyUI/custom_nodes/nino-utils/
├── __init__.py # Package initialization
├── nodes.py # Main node implementation
├── pyproject.toml # Project configuration
├── requirements.txt # Dependencies
├── README.md # Documentation
├── example_configurations.md # Configuration examples
├── example_workflow.json # Example workflow
├── install.py # Installation script
├── test_node.py # Test suite
└── IMPLEMENTATION_SUMMARY.md # This summary
All tests pass and the node is ready for production use! 🎉