Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: js api sdk #216

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

feat: js api sdk #216

wants to merge 4 commits into from

Conversation

634750802
Copy link
Collaborator

@634750802 634750802 commented Aug 9, 2024

Usage

npm i @tidb-ai/[email protected]

API Calls

import { listApiKeys } from "@tidb-ai/sdk";
listApiKeys().then(console.log)

Chat

import { ChatController } from '@tidb-ai/sdk';

const controller = new ChatController();

controller.post({
  content: 'What is tidb?'
})

controller.on('message-loaded', message => {
  if (message.role === 'assistant') {
    console.log('assistant message start', message.id)
    message.on('stream-finished', message => {
      console.log(message.content);
      console.log(message.sources);
    })
  }
});

Required environments

TIDBAI_BASE_URL=https://tidb.ai
TIDBAI_API_KEY=ta-xxxxx

TODO:

  • authenticate with API Key
  • publish scripts

Copy link

vercel bot commented Aug 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
grab.demo.tidb.ai ⬜️ Ignored (Inspect) Visit Preview Aug 12, 2024 4:09am
internal.tidb.ai ⬜️ Ignored (Inspect) Visit Preview Aug 12, 2024 4:09am
tidb.ai ⬜️ Ignored (Inspect) Visit Preview Aug 12, 2024 4:09am

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