@charisma-ai/react
Charisma.ai chat component for React
Last updated 3 months ago by benhjames .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install @charisma-ai/react 
SYNC missed versions from official npm registry.

Charisma for React

Charisma.ai chat component for React.

yarn add @charisma-ai/react

Usage

import { Charisma, Conversation } from "@charisma-ai/react";
import { Charisma as CharismaSDK } from "@charisma-ai/sdk";

const MyChat = () => {
  // If you need to get a playthrough token or conversation id, you may consider
  // doing this as a `useEffect` hook, otherwise skip this:

  const [playthroughToken, setPlaythroughToken] = useState<string>();
  const [conversationId, setConversationId] = useState<string>();
  useEffect(() => {
    async function run() {
      const newToken = await CharismaSDK.createPlaythroughToken({
        storyId,
        version,
        userToken,
      });
      setPlaythroughToken(newToken);

      const newConversationId = await CharismaSDK.createConversation(newToken);
      setConversationId(newConversationId);
    }
    run();
  }, [storyId, version, userToken]);

  return (
    <Charisma playthroughToken={playthroughToken}>
      <Conversation conversationId={conversationId}>
        {({ messages, inputValue, start, reply, type }) => (
          <>
            <button onClick={() => start()}>Start</button>
            {messages.map(({ message: { text } }) => (
              <div>{text}</div>
            ))}
            <input
              onChange={({ currentTarget: { value } }) => type(value)}
              value={inputValue}
              onKeyPress={({ key }) => {
                if (key === "Enter") {
                  reply({ text: inputValue });
                }
              }}
            />
          </>
        )}
      </Conversation>
    </Charisma>
  );
}

For a full list of prop types, see the TypeScript definition file.

### Breaking Changes

The v1 release of @charisma-ai/react has a bunch of breaking changes.

Most notably, multiple conversations can now exist in a single playthrough, hence the addition of the Conversation component which references a particular conversationId.

Conversations work similarly to how the Charisma component used to work, except it does not use speech-to-text (microphone) or text-to-speech (speaker) out the box. These need to be configured using the relevant low-level APIs in charisma-ai/sdk: Microphone and Speaker.

Current Tags

  • 2.0.0-alpha.6                                ...           alpha (8 days ago)
  • 1.10.0                                ...           latest (3 months ago)
  • 0.5.0-next.6                                ...           next (2 years ago)

84 Versions

  • 2.0.0-alpha.6                                ...           8 days ago
  • 2.0.0-alpha.5                                ...           10 days ago
  • 2.0.0-alpha.4                                ...           a month ago
  • 2.0.0-alpha.3                                ...           a month ago
  • 2.0.0-alpha.2                                ...           a month ago
  • 2.0.0-alpha.1                                ...           a month ago
  • 1.10.0                                ...           3 months ago
  • 1.10.0-alpha.2                                ...           3 months ago
  • 1.10.0-alpha.1                                ...           3 months ago
  • 1.9.0                                ...           4 months ago
  • 1.8.0                                ...           6 months ago
  • 1.8.0-alpha.1                                ...           6 months ago
  • 1.7.2                                ...           6 months ago
  • 1.7.1                                ...           7 months ago
  • 1.7.0                                ...           7 months ago
  • 1.6.0                                ...           8 months ago
  • 1.6.0-alpha.1                                ...           9 months ago
  • 1.5.0                                ...           9 months ago
  • 1.5.0-alpha.3                                ...           9 months ago
  • 1.5.0-alpha.2                                ...           9 months ago
  • 1.5.0-alpha.1                                ...           9 months ago
  • 1.4.1                                ...           10 months ago
  • 1.4.0                                ...           10 months ago
  • 1.3.2                                ...           a year ago
  • 1.3.1                                ...           a year ago
  • 1.3.0                                ...           a year ago
  • 1.3.0-alpha.1                                ...           a year ago
  • 1.2.1                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.2.0-alpha.4                                ...           a year ago
  • 1.2.0-alpha.3                                ...           a year ago
  • 1.2.0-alpha.2                                ...           a year ago
  • 1.2.0-alpha.1                                ...           a year ago
  • 1.1.1                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 1.0.0-alpha.16                                ...           a year ago
  • 1.0.0-alpha.15                                ...           a year ago
  • 1.0.0-alpha.14                                ...           a year ago
  • 1.0.0-alpha.13                                ...           a year ago
  • 1.0.0-alpha.12                                ...           a year ago
  • 1.0.0-alpha.11                                ...           a year ago
  • 1.0.0-alpha.10                                ...           a year ago
  • 1.0.0-alpha.9                                ...           a year ago
  • 1.0.0-alpha.8                                ...           a year ago
  • 1.0.0-alpha.7                                ...           a year ago
  • 1.0.0-alpha.6                                ...           a year ago
  • 1.0.0-alpha.5                                ...           a year ago
  • 1.0.0-alpha.4                                ...           a year ago
  • 1.0.0-alpha.3                                ...           a year ago
  • 1.0.0-alpha.2                                ...           a year ago
  • 1.0.0-alpha.1                                ...           a year ago
  • 0.9.2                                ...           a year ago
  • 0.9.1                                ...           a year ago
  • 0.9.0                                ...           a year ago
  • 0.8.0                                ...           a year ago
  • 0.7.1                                ...           a year ago
  • 0.7.0                                ...           a year ago
  • 0.6.1                                ...           a year ago
  • 0.6.0                                ...           a year ago
  • 0.5.1                                ...           a year ago
  • 0.5.0                                ...           a year ago
  • 0.5.0-next.6                                ...           2 years ago
  • 0.5.0-next.5                                ...           2 years ago
  • 0.5.0-next.4                                ...           2 years ago
  • 0.5.0-next.3                                ...           2 years ago
  • 0.5.0-next.2                                ...           2 years ago
  • 0.5.0-next.1                                ...           2 years ago
  • 0.5.0-next.0                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
  • 0.3.1                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.2.3                                ...           2 years ago
  • 0.2.2                                ...           2 years ago
  • 0.2.1                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.2                                ...           2 years ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 38
Last Day 0
Last Week 38
Last Month 40
Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |