quivr/frontend/lib/api/user/user.ts
Mamadou DICKO 7532b558c7
feat: add user level open ai key management (#805)
* feat: add user user identity table

* feat: add user openai api key input

* feat: add encryption missing message

* chore: log more details about 422 errors

* docs(API): update api creation path

* feat: use user openai key if defined
2023-08-01 09:24:57 +02:00

26 lines
662 B
TypeScript

import { AxiosInstance } from "axios";
import { UUID } from "crypto";
export type UserIdentityUpdatableProperties = {
openai_api_key?: string | null;
};
export type UserIdentity = {
openai_api_key?: string | null;
user_id: UUID;
};
export const updateUserIdentity = async (
userUpdatableProperties: UserIdentityUpdatableProperties,
axiosInstance: AxiosInstance
): Promise<UserIdentity> =>
axiosInstance.put(`/user/identity`, userUpdatableProperties);
export const getUserIdentity = async (
axiosInstance: AxiosInstance
): Promise<UserIdentity> => {
const { data } = await axiosInstance.get<UserIdentity>(`/user/identity`);
return data;
};