SkywardAI / voyager

The project is OpenAI-like API service of SkywardAI ecosystem
Apache License 2.0
1 stars 6 forks source link

[Feature]: Add token management #28

Closed cbh778899 closed 1 month ago

cbh778899 commented 1 month ago

Contact Details(optional)

No response

What feature are you requesting?

We want to implement token management like OpenAI, more specifically, to make the generated API key to use, like having tokens in total and drop by usage for each time, when passing the API key. It should be basic database CURD, as we've got LanceDB implemented.

We temporarily won't need this function so it's just a proposal, and at this stage we don't want the tokens to be limited, an individual js module should work.

Murkeee commented 1 month ago

I presume this would use the Full-Text-Search feature of LanceDB? If so i believe it is not implemented in JS yet.

cbh778899 commented 1 month ago

I presume this would use the Full-Text-Search feature of LanceDB? If so i believe it is not implemented in JS yet.

Yes, this doesn't include vector, what we want is a new table, check whether the api-key exists and update the token usage. Please refer to here, the section on the bottom for your reference.

To simplify this, for search section you can do something like

import { getTable } from "/database/index.js";
// your code here
await (await getTable("api-key-table-name”)).query().where(
    // Your where clause here
).limit(1).toArray()