@chatbotkit/next
Advanced tools
@@ -16,3 +16,3 @@ "use strict"; | ||
| else { | ||
| throw new Error('Invald source'); | ||
| throw new Error('Invalid source'); | ||
| } | ||
@@ -19,0 +19,0 @@ try { |
+1
-1
@@ -13,3 +13,3 @@ export function stream(source) { | ||
| else { | ||
| throw new Error('Invald source'); | ||
| throw new Error('Invalid source'); | ||
| } | ||
@@ -16,0 +16,0 @@ try { |
+5
-3
| { | ||
| "name": "@chatbotkit/next", | ||
| "version": "1.1.10", | ||
| "version": "1.8.0", | ||
| "description": "Utility library for ChatbotKit for Next.js", | ||
| "license": "ISC", | ||
| "engines": { | ||
| "node": ">=18.16.0" | ||
| "node": ">=18.17.0" | ||
| }, | ||
@@ -82,3 +82,5 @@ "repository": { | ||
| "types": "./dist/cjs/index.d.ts", | ||
| "dependencies": {}, | ||
| "dependencies": { | ||
| "tslib": "^2.6.2" | ||
| }, | ||
| "scripts": { | ||
@@ -85,0 +87,0 @@ "build": "run-s build:*", |
+11
-9
@@ -27,7 +27,5 @@ [](https://twitter.com/chatbotkit) | ||
| // file: ./pages/api/conversation/complete.js | ||
| // Import ChatBotKit and Edge streaming utilities | ||
| import { stream } from '@chatbotkit/next/edge' | ||
| import { ChatBotKit } from '@chatbotkit/sdk' | ||
| import { stream } from '@chatbotkit/next/edge' | ||
| // Initialize ChatBotKit with API secret | ||
| const cbk = new ChatBotKit({ | ||
@@ -37,3 +35,2 @@ secret: process.env.CHATBOTKIT_API_SECRET, | ||
| // Define an API handler for streaming messages | ||
| export default async function handler(req) { | ||
@@ -45,3 +42,2 @@ const { messages } = await req.json() | ||
| // Configure Edge runtime | ||
| export const config = { | ||
@@ -56,11 +52,18 @@ runtime: 'edge', | ||
| // file: ./pages/index.js | ||
| // Utilize components and hooks from ChatBotKit's React package | ||
| import { AutoTextarea, useConversationManager } from '@chatbotkit/react' | ||
| export default function Index() { | ||
| const { thinking, text, setText, messages, submit } = useConversationManager({ | ||
| const { | ||
| thinking, | ||
| text, | ||
| setText, | ||
| messages, | ||
| submit, | ||
| } = useConversationManager({ | ||
| endpoint: '/api/conversation/complete', | ||
| }) | ||
| // Handle text submission on Enter key press | ||
| function handleOnKeyDown(event) { | ||
@@ -74,3 +77,2 @@ if (event.keyCode === 13) { | ||
| // Render chat interface | ||
| return ( | ||
@@ -77,0 +79,0 @@ <div style={{ fontFamily: 'monospace', padding: '10px' }}> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
112
1.82%67994
-21.45%1
Infinity%66
-1.49%+ Added
+ Added