1use crate::client::HingeClient;
2use crate::errors::HingeError;
3use crate::models::{
4 AnswerEvaluateRequest, CreatePromptPollRequest, CreatePromptPollResponse,
5 CreateVideoPromptRequest, CreateVideoPromptResponse, Prompt, PromptsResponse,
6};
7use crate::prompts_manager::HingePromptsManager;
8use crate::storage::Storage;
9
10pub struct PromptsApi<'a, S: Storage + Clone> {
11 pub(super) client: &'a mut HingeClient<S>,
12}
13
14impl<S: Storage + Clone> PromptsApi<'_, S> {
15 pub async fn list(&mut self) -> Result<PromptsResponse, HingeError> {
16 self.client.fetch_prompts().await
17 }
18
19 pub async fn manager(&mut self) -> Result<HingePromptsManager, HingeError> {
20 self.client.fetch_prompts_manager().await
21 }
22
23 pub async fn text(&mut self, prompt_id: &str) -> Result<String, HingeError> {
24 self.client.get_prompt_text(prompt_id).await
25 }
26
27 pub async fn search(&mut self, query: &str) -> Result<Vec<Prompt>, HingeError> {
28 self.client.search_prompts(query).await
29 }
30
31 pub async fn by_category(&mut self, category_slug: &str) -> Result<Vec<Prompt>, HingeError> {
32 self.client.get_prompts_by_category(category_slug).await
33 }
34
35 pub async fn payload(&mut self) -> serde_json::Value {
36 self.client.prompt_payload().await
37 }
38
39 pub async fn evaluate_answer(
40 &self,
41 payload: AnswerEvaluateRequest,
42 ) -> Result<serde_json::Value, HingeError> {
43 self.client.evaluate_answer(payload).await
44 }
45
46 pub async fn create_prompt_poll(
47 &self,
48 payload: CreatePromptPollRequest,
49 ) -> Result<CreatePromptPollResponse, HingeError> {
50 self.client.create_prompt_poll(payload).await
51 }
52
53 pub async fn create_video_prompt(
54 &self,
55 payload: CreateVideoPromptRequest,
56 ) -> Result<CreateVideoPromptResponse, HingeError> {
57 self.client.create_video_prompt(payload).await
58 }
59}