@gram-ai/elements 1.0.9 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,14 +18,16 @@ pnpm add @gram-ai/elements
18
18
 
19
19
  ## Setting up your backend
20
20
 
21
- At the moment, we provide a set of handlers via the `@gram-ai/elements/server` package that you can use to automatically setup your backend for usage with Gram Elements. The example below demonstrates the setup for Hono:
21
+ At the moment, we provide a set of handlers via the `@gram-ai/elements/server` package that you can use to automatically setup your backend for usage with Gram Elements. The example below demonstrates the setup for Express:
22
22
 
23
23
  ```typescript
24
- import { Hono } from 'hono'
25
24
  import { createElementsServerHandlers } from '@gram-ai/elements/server'
25
+ import express from 'express'
26
26
 
27
- const app = new Hono()
28
27
  const handlers = createElementsServerHandlers()
28
+ const app = express()
29
+
30
+ app.use(express.json())
29
31
 
30
32
  app.post('/chat/completions', handlers.chat)
31
33
  ```
@@ -50,6 +52,8 @@ import '@gram-ai/elements/elements.css'
50
52
  const config: ElementsConfig = {
51
53
  projectSlug: 'xxx',
52
54
  mcp: 'https://app.getgram.ai/mcp/{your_slug}',
55
+ // Points to your backend endpoint
56
+ chatEndpoint: '/chat/completions',
53
57
  variant: 'widget',
54
58
  welcome: {
55
59
  title: 'Hello!',
package/dist/elements.js CHANGED
@@ -7310,7 +7310,7 @@ const Ko = zs(
7310
7310
  }) => {
7311
7311
  const o = Zh({
7312
7312
  transport: new Fr({
7313
- api: Bh,
7313
+ api: r.chatEndpoint ?? Bh,
7314
7314
  prepareSendMessagesRequest: ({ id: i, messages: e }) => ({
7315
7315
  body: {
7316
7316
  messages: e,
@@ -20,9 +20,20 @@ export interface ElementsConfig {
20
20
  /**
21
21
  * The Gram Server URL to use for the Elements library.
22
22
  * Can be retrieved from https://app.getgram.ai/{team}/{project}/mcp/{mcp_slug}
23
+ *
23
24
  * Note: This config option will likely change in the future
24
25
  */
25
26
  mcp: ServerUrl;
27
+ /**
28
+ * The path of your backend's chat endpoint.
29
+ * @default '/chat/completions'
30
+ *
31
+ * @example
32
+ * const config: ElementsConfig = {
33
+ * chatEndpoint: '/my-custom-chat-endpoint',
34
+ * }
35
+ */
36
+ chatEndpoint?: string;
26
37
  /**
27
38
  * Custom environment variable overrides for the Elements library.
28
39
  * Will be used to override the environment variables for the MCP server.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@gram-ai/elements",
3
3
  "description": "Gram Elements is a library of UI primitives for building chat-like experiences for MCP Servers.",
4
4
  "type": "module",
5
- "version": "1.0.9",
5
+ "version": "1.1.0",
6
6
  "main": "dist/index.js",
7
7
  "exports": {
8
8
  ".": {