SDK: text prompt (#4214)
This commit is contained in:
committed by
GitHub
parent
0f495f458e
commit
b7d08fe906
@@ -11,6 +11,7 @@ from skyvern.client import (
|
||||
RunSdkActionRequestAction_AiUploadFile,
|
||||
RunSdkActionRequestAction_Extract,
|
||||
RunSdkActionRequestAction_LocateElement,
|
||||
RunSdkActionRequestAction_Prompt,
|
||||
)
|
||||
from skyvern.config import settings
|
||||
from skyvern.core.script_generations.skyvern_page_ai import SkyvernPageAi
|
||||
@@ -225,3 +226,33 @@ class SdkSkyvernPageAi(SkyvernPageAi):
|
||||
return response.result
|
||||
|
||||
return None
|
||||
|
||||
async def ai_prompt(
|
||||
self,
|
||||
prompt: str,
|
||||
schema: dict[str, Any] | None = None,
|
||||
model: dict[str, Any] | None = None,
|
||||
) -> dict[str, Any] | list | str | None:
|
||||
"""Send a prompt to the LLM and get a response based on the provided schema via API call."""
|
||||
|
||||
LOG.info(
|
||||
"AI prompt",
|
||||
prompt=prompt,
|
||||
model=model,
|
||||
workflow_run_id=self._browser.workflow_run_id,
|
||||
)
|
||||
|
||||
response = await self._browser.skyvern.run_sdk_action(
|
||||
url=self._page.url,
|
||||
action=RunSdkActionRequestAction_Prompt(
|
||||
prompt=prompt,
|
||||
schema=schema,
|
||||
model=model,
|
||||
),
|
||||
browser_session_id=self._browser.browser_session_id,
|
||||
browser_address=self._browser.browser_address,
|
||||
workflow_run_id=self._browser.workflow_run_id,
|
||||
)
|
||||
self._browser.workflow_run_id = response.workflow_run_id
|
||||
|
||||
return response.result if response.result is not None else None
|
||||
|
||||
Reference in New Issue
Block a user