Skip to content

feat(ai-components): AI translations via the chat SDK, AI sample on the agents router - #3921

Open
isekovanic wants to merge 1 commit into
feat/ai-message-partsfrom
feat/ai-agent-groundwork
Open

isekovanic wants to merge 1 commit into
feat/ai-message-partsfrom
feat/ai-agent-groundwork

Conversation

@isekovanic

Copy link
Copy Markdown
Contributor

Ticket: https://linear.app/stream/issue/RN-485

Stacked on #3920.

🎯 Goal

Groundwork for the agent conversation views: strings that follow the chat's language, and an AI sample that talks to a real agent backend, so the next PRs have reasoning and tool-call steps to show.

🛠 Implementation details

Translations

  • useAITranslation() reads the chat SDK's TranslationContext. Inside <Chat> it returns the chat's t. Without one, it falls back to English with {{ name }} placeholders filled.
  • It's a thin adapter rather than useTranslationContext() because ours throws outside a provider, which would crash AI-only apps.
  • defaultTranslatorFunction moved from Streami18n.ts to utils/i18n/utils.ts, so TranslationContext.tsx no longer imports Streami18n (i18next and every locale). Streami18n still re-exports it, and the public API is unchanged.
  • TranslationContext.tsx, isTestEnvironment.ts and utils/i18n/utils.ts are on the AI entry's allowlist. The AI entry gains plain dayjs and nothing else.
  • TranslationProvider is re-exported from /ai-components for apps without <Chat>.

ExpoChatGPTSample

  • It talks to a Vision-Agents router through @stream-io/calypso and no longer uses the old Heroku demo backend.
  • Each conversation is a router session and its agent channel. Questions go through session.responses.create, with photos sent as data URIs. Stop goes through session.interrupt().
  • The drawer lists the user's agent channels. A conversation that was never asked anything is deleted when you leave it.
  • The reply's ai_* steps are hidden through the UnsupportedAttachment slot until their views land.
  • Config is read from .env.local, and .env.example documents it. The README covers running the router.
  • Hermes has no crypto.randomUUID, so the sample polyfills it with stream-chat-js's generateUUIDv4.
  • <Channel> and <MessageList> are stand-ins until AIConversation exists. After that the sample reads the low-level client directly, the same way React's Juno sample does.

🎨 UI Changes

No SDK UI. The sample now shows real agent replies.

🧪 Testing

  • Unit tests for the translation adapter. They cover English without <Chat>, a real Streami18n instance (a French string with a placeholder) and the override provider.
  • On an Android emulator against a local router:
    • asking a question, the thinking indicator, the stop button showing and the streamed answer;
    • router-titled conversations, and resuming one;
    • an unused session being deleted;
    • no "Unsupported Attachment" cards for the steps.
  • Not tested: iOS, pressing stop mid-reply, photos, voice mode.
  • yarn lint, yarn typecheck, yarn build and yarn test:unit pass.

☑️ Checklist

@Stream-SDK-Bot

Copy link
Copy Markdown
Contributor

SDK Size

title develop branch diff status
js_bundle_size 2037 KB 2038 KB +213 B 🟢
ai_components_size 163 KB 169 KB +5968 B 🔴

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants