Skip to main content

OpenAI chatkit backend support for Google ADK

Project description

OpenAI chatkit support for Google ADK

This repository provides the backend support for openai/chatkit-js (https://github.com/openai/chatkit-js) for Google ADK based agentic applications.

It uses and extends openai/chatkit-python (https://github.com/openai/chatkit-python) by providing

  • ADKStore that wraps BaseSessionService
  • A function (stream_agent_response) that translate ADK events into chatkit events
  • Provides support to render widgets
    • See examples/backend/src/backend/agents/facts/_tools.py::get_weather
  • Provides support for making calls to client tools.
    • Client tools typically run in browser
    • See examples/backend/src/backend/agents/facts/_tools.py::switch_theme

TODO:

  • Support for attachments / artifacts

Install

uv add adk-chatkit

Running examples

Make sure you open this repository in vscode devcontainer and all dependencies will be setup for you

# At the root of the repository
# fill in your configuration / settings
cp .env.example .env

There is one backend and one frontend that hosts 4 agents (chatkit servers) and their corresponding user interface.

# Run the backend
uv run poe run-example-backend
# Run the frontend
uv run poe run-example-frontend

Usage

See examples for full usage

class FactsChatKitServer(ADKChatKitServer):
    def __init__(
        self,
        store: ADKStore,
        runner_manager: RunnerManager,
        settings: Settings,
    ) -> None:
        super().__init__(store)
        agent = _make_facts_agent(settings)
        self._runner = runner_manager.add_runner(settings.FACTS_APP_NAME, agent)

    async def _adk_respond(
        self,
        thread: ThreadMetadata,
        item: UserMessageItem | None,
        context: ADKContext,
    ) -> AsyncIterator[ThreadStreamEvent]:
        if item is None:
            return

        if _is_tool_completion_item(item):
            return

        message_text = _user_message_text(item)
        if not message_text:
            return

        content = genai_types.Content(
            role="user",
            parts=[genai_types.Part.from_text(text=message_text)],
        )

        agent_context = ADKAgentContext(
            app_name=context.app_name,
            user_id=context.user_id,
            thread=thread,
        )

        event_stream = self._runner.run_async(
            user_id=context.user_id,
            session_id=thread.id,
            new_message=content,
            run_config=ChatkitRunConfig(streaming_mode=StreamingMode.SSE, context=agent_context),
        )

        async for event in stream_agent_response(agent_context, event_stream):
            yield event

Examples applications

There are 4 example applications (3 are ported from https://github.com/openai/openai-chatkit-advanced-samples)

Facts & Guide

  • Shows Fact Recording
  • Displays Weather using Widget
  • Theme Switching

http://localhost:5173/guide

Weather widget preview

Customer Support

  • Airline Reservation Management
  • Change Seat
  • Add bags

http://localhost:5171/customer-support

Customer Support preview

Knowledge Assistant

  • Answers questions based on files and vector store
  • Shows files and citations

http://localhost:5171/knowledge

Knowledge preview

Widget Gallery

  • Shows various widgets and how to process actions

Knowledge preview

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

adk_chatkit-0.0.8.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

adk_chatkit-0.0.8-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file adk_chatkit-0.0.8.tar.gz.

File metadata

  • Download URL: adk_chatkit-0.0.8.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for adk_chatkit-0.0.8.tar.gz
Algorithm Hash digest
SHA256 8f18726f7ae63ad8a70217e79fddf678952dd8e13df7e12c9240a6f29408d9cd
MD5 235c5b4e91d77f2dadf4c5809640f86a
BLAKE2b-256 18b253c1ae2397bf3ccd0d5495fe8051c569f59d3febdc307bf3a031317cac25

See more details on using hashes here.

Provenance

The following attestation bundles were made for adk_chatkit-0.0.8.tar.gz:

Publisher: publish.yaml on ksachdeva/adk-chatkit

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

File details

Details for the file adk_chatkit-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: adk_chatkit-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for adk_chatkit-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 5352a9640236d2db2b6a060f51991a0bc42f82a766c71b0736db20b138665868
MD5 b03fc671c3c03be2f2fc6a721ba7a5ca
BLAKE2b-256 c6af7fe52fb336369d8f6095ce8151d49e012aab4e1f8d637058d068f18a3e30

See more details on using hashes here.

Provenance

The following attestation bundles were made for adk_chatkit-0.0.8-py3-none-any.whl:

Publisher: publish.yaml on ksachdeva/adk-chatkit

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