quivr/frontend/lib/api/prompt/prompt.ts
Mamadou DICKO b3fb8fc3bc
feat: add public prompts picker (#841)
* fix: update prompt_id logic in payload

* feat: add getPublicPrompts to sdk

* feat: add public prompt picker
2023-08-03 17:00:05 +02:00

41 lines
1.0 KiB
TypeScript

import { AxiosInstance } from "axios";
import { Prompt } from "@/lib/types/Prompt";
export type CreatePromptProps = {
title: string;
content: string;
};
export const createPrompt = async (
prompt: CreatePromptProps,
axiosInstance: AxiosInstance
): Promise<Prompt> => {
return (await axiosInstance.post<Prompt>("/prompts", prompt)).data;
};
export const getPrompt = async (
promptId: string,
axiosInstance: AxiosInstance
): Promise<Prompt | undefined> => {
return (await axiosInstance.get<Prompt>(`/prompts/${promptId}`)).data;
};
export type PromptUpdatableProperties = {
title: string;
content: string;
};
export const updatePrompt = async (
promptId: string,
prompt: PromptUpdatableProperties,
axiosInstance: AxiosInstance
): Promise<Prompt> => {
return (await axiosInstance.put<Prompt>(`/prompts/${promptId}`, prompt)).data;
};
export const getPublicPrompts = async (
axiosInstance: AxiosInstance
): Promise<Prompt[]> => {
return (await axiosInstance.get<Prompt[]>("/prompts")).data;
};