Skip to content

Commit d63d066

Browse files
committed
Add genai generate text interface
1 parent 442a166 commit d63d066

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

videodb/_constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class ApiPath:
7777
alert = "alert"
7878
generate_url = "generate_url"
7979
generate = "generate"
80+
text = "text"
8081
web = "web"
8182
translate = "translate"
8283
dub = "dub"

videodb/collection.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,30 @@ def generate_video(
358358
if video_data:
359359
return Video(self._connection, **video_data)
360360

361+
def generate_text(
362+
self,
363+
prompt: str,
364+
model_name: Literal["basic", "pro", "ultra"] = "basic",
365+
response_type: Literal["text", "json"] = "text",
366+
) -> Union[str, dict]:
367+
"""Generate text from a prompt using genai offering.
368+
369+
:param str prompt: Prompt for the text generation
370+
:param str model_name: Model name to use ("basic", "pro" or "ultra")
371+
:param str response_type: Desired response type ("text" or "json")
372+
:return: Generated text response
373+
:rtype: Union[str, dict]
374+
"""
375+
376+
return self._connection.post(
377+
path=f"{ApiPath.collection}/{self.id}/{ApiPath.generate}/{ApiPath.text}",
378+
data={
379+
"prompt": prompt,
380+
"model_name": model_name,
381+
"response_type": response_type,
382+
},
383+
)
384+
361385
def dub_video(
362386
self, video_id: str, language_code: str, callback_url: Optional[str] = None
363387
) -> Video:

0 commit comments

Comments
 (0)