Skip to main content

Empower your UI by AI Agent

Project description

Next Gen UI Agent

The goal of this AI agent is to generate personalised and rich UI components based on the user prompt, chat history and backend data provided by other agent in your assistant.

Why use Next Gen UI?

  • Rich user experience - Extends simple text based LLM applications output by UI components like card, table, chart, video-player, image gallery etc.
  • Extensible architecture - Developer's choice to which AI framwork to choose and which UI component framework.
  • AI Frameworks integration - Seamless integration of various AI framworks.
  • Server (Agent) side UI rendering - Powerful agent centralized HTML (e.g. web component) rendition.
  • Client side UI rendering - Client side rendering for more control over the rendition.

Example of rich card component including image and structured data.

Card UI Component

Example

Following example shows how easy you can integrate your ReAct LangGraph agent with Next Gen UI Agent. For other frameworks see below.

from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
from next_gen_ui_langgraph.agent import NextGenUILangGraphAgent

# search_movie tool function
# def search_movie(title: str):
#  ...

llm = ChatOpenAI(**llm_settings)
movies_agent = create_react_agent(model=llm, tools=[search_movie])

# Next Gen UI Agent - Build it as Standard LangGraph agent
ngui_agent = NextGenUILangGraphAgent(model=llm).build_graph()
ngui_cfg = {"configurable": {"component_system": "json"}}

if __name__ == "__main__":
    # Run Movies Agent to get raw movie data and answer
    movies_response = movies_agent.invoke(
        {"messages": [{"role": "user", "content": "Play Toy Story movie trailer"}]}
    )
    print("

===Movies Text Answer===
", movies_response["messages"][-1].content)

    # Run NGUI Agent to get UI component as JSON for client-side rendering
    ngui_response = asyncio.run(
        # Run Next Gen UI Agent. Pass movies agent response directly.
        ngui_agent.ainvoke(movies_response, ngui_cfg),
    )

    print(f"

===Next Gen UI {component_system} Rendition===
", ngui_response["renditions"][0].content)

Note: Full python file is stored in libs/next_gen_ui_langgraph/readme_example.py.

Running this assistant with user's questions Play Toy Story movie trailer generates following output of movies agent:

===Movies Text Answer===
 Here's the answer to the original user question:

[Intro music plays]

Narrator (in a deep, dramatic voice): "In a world where toys come to life..."

[Scene: Andy's room, toys are scattered all over the floor. Woody, a pull-string cowboy toy, is centered on a shelf.]

Narrator: "One toy stands tall."

[Scene: Close-up of Woody's face]

and Next Gen UI json rendering:

===Next Gen UI json Rendition===
{
    'component': 'video-player',
    'id': 'call_zomga3r3',
    'title': 'Toy Story Trailer',
    'video': 'https://www.youtube.com/embed/v-PjgYDrg70',
    'video_img': 'https://img.youtube.com/vi/v-PjgYDrg70/maxresdefault.jpg'
}

AI Frameworks

For seamless integration with your AI application following frameworks are supported.

  1. LangGraph
  2. Llama-stack
  3. BeeAI Framework - WIP

Missing framework? Create an issue please.

AI/UI Protocols

Protocols provides standardization between client and agent and provides TypeScript / Python interoperability.

  1. ACP - WIP
  2. A2A - TBD

UI Frameworks

  1. React/PatternFly - WIP
  2. Hat Design System System - Server-side web component rendering
  3. Text - TBD

Contributing

Follow the CONTRIBUTING.md

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

next_gen_ui_agent-0.1.0-py3-none-any.whl (32.2 kB view details)

Uploaded Python 3

File details

Details for the file next_gen_ui_agent-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for next_gen_ui_agent-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b448f870c8b87b9dd2197acb32593a713efbf024fd18293a885ae0afdc2294de
MD5 157b548a876d75ea5d04c64493d578d1
BLAKE2b-256 26a3bc1d5ea91a7df35195fcd582a7c61d1e6a4752ebad80468a8d2c4da0ba72

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