mirror of
https://github.com/Skyvern-AI/skyvern.git
synced 2025-09-17 02:39:40 +00:00
update documentation part3 - add code examples (#2369)
This commit is contained in:
parent
89fd604022
commit
d2419d82d7
4 changed files with 922 additions and 353 deletions
File diff suppressed because it is too large
Load diff
|
@ -23,6 +23,7 @@ from skyvern.forge.sdk.core.security import generate_skyvern_signature
|
||||||
from skyvern.forge.sdk.db.enums import OrganizationAuthTokenType
|
from skyvern.forge.sdk.db.enums import OrganizationAuthTokenType
|
||||||
from skyvern.forge.sdk.executor.factory import AsyncExecutorFactory
|
from skyvern.forge.sdk.executor.factory import AsyncExecutorFactory
|
||||||
from skyvern.forge.sdk.models import Step
|
from skyvern.forge.sdk.models import Step
|
||||||
|
from skyvern.forge.sdk.routes.code_samples import GET_RUN_CODE_SAMPLE, RUN_TASK_CODE_SAMPLE, RUN_WORKFLOW_CODE_SAMPLE
|
||||||
from skyvern.forge.sdk.routes.routers import base_router, legacy_base_router, legacy_v2_router
|
from skyvern.forge.sdk.routes.routers import base_router, legacy_base_router, legacy_v2_router
|
||||||
from skyvern.forge.sdk.schemas.ai_suggestions import AISuggestionBase, AISuggestionRequest
|
from skyvern.forge.sdk.schemas.ai_suggestions import AISuggestionBase, AISuggestionRequest
|
||||||
from skyvern.forge.sdk.schemas.organizations import (
|
from skyvern.forge.sdk.schemas.organizations import (
|
||||||
|
@ -417,6 +418,7 @@ async def get_runs(
|
||||||
openapi_extra={
|
openapi_extra={
|
||||||
"x-fern-sdk-group-name": "agent",
|
"x-fern-sdk-group-name": "agent",
|
||||||
"x-fern-sdk-method-name": "get_run",
|
"x-fern-sdk-method-name": "get_run",
|
||||||
|
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": GET_RUN_CODE_SAMPLE}]}],
|
||||||
},
|
},
|
||||||
responses={
|
responses={
|
||||||
200: {"description": "Successfully got run"},
|
200: {"description": "Successfully got run"},
|
||||||
|
@ -1423,6 +1425,16 @@ async def _flatten_workflow_run_timeline(organization_id: str, workflow_run_id:
|
||||||
openapi_extra={
|
openapi_extra={
|
||||||
"x-fern-sdk-group-name": "agent",
|
"x-fern-sdk-group-name": "agent",
|
||||||
"x-fern-sdk-method-name": "run_task",
|
"x-fern-sdk-method-name": "run_task",
|
||||||
|
"x-fern-examples": [
|
||||||
|
{
|
||||||
|
"code-samples": [
|
||||||
|
{
|
||||||
|
"sdk": "python",
|
||||||
|
"code": RUN_TASK_CODE_SAMPLE,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
},
|
},
|
||||||
description="Run a task",
|
description="Run a task",
|
||||||
summary="Run a task",
|
summary="Run a task",
|
||||||
|
@ -1582,6 +1594,16 @@ async def run_task(
|
||||||
openapi_extra={
|
openapi_extra={
|
||||||
"x-fern-sdk-group-name": "agent",
|
"x-fern-sdk-group-name": "agent",
|
||||||
"x-fern-sdk-method-name": "run_workflow",
|
"x-fern-sdk-method-name": "run_workflow",
|
||||||
|
"x-fern-examples": [
|
||||||
|
{
|
||||||
|
"code-samples": [
|
||||||
|
{
|
||||||
|
"sdk": "python",
|
||||||
|
"code": RUN_WORKFLOW_CODE_SAMPLE,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
},
|
},
|
||||||
description="Run a workflow",
|
description="Run a workflow",
|
||||||
summary="Run a workflow",
|
summary="Run a workflow",
|
||||||
|
|
18
skyvern/forge/sdk/routes/code_samples.py
Normal file
18
skyvern/forge/sdk/routes/code_samples.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
RUN_TASK_CODE_SAMPLE = """from skyvern import Skyvern
|
||||||
|
|
||||||
|
client = Skyvern(api_key="your_api_key")
|
||||||
|
await client.run_task(prompt="What's the top post on hackernews?")
|
||||||
|
"""
|
||||||
|
|
||||||
|
GET_RUN_CODE_SAMPLE = """from skyvern import Skyvern
|
||||||
|
|
||||||
|
client = Skyvern(api_key="your_api_key")
|
||||||
|
run = await client.get_run(run_id="tsk_123")
|
||||||
|
print(run)
|
||||||
|
"""
|
||||||
|
|
||||||
|
RUN_WORKFLOW_CODE_SAMPLE = """from skyvern import Skyvern
|
||||||
|
|
||||||
|
client = Skyvern(api_key="your_api_key")
|
||||||
|
await client.agent.run_workflow(workflow_id="wpid_123", parameters={"parameter1": "value1", "parameter2": "value2"})
|
||||||
|
"""
|
|
@ -92,7 +92,7 @@ class CredentialItem(BaseModel):
|
||||||
class CreateCredentialRequest(BaseModel):
|
class CreateCredentialRequest(BaseModel):
|
||||||
"""Request model for creating a new credential."""
|
"""Request model for creating a new credential."""
|
||||||
|
|
||||||
name: str = Field(..., description="Name of the credential", examples=["My Credential"])
|
name: str = Field(..., description="Name of the credential", examples=["Amazon Login"])
|
||||||
credential_type: CredentialType = Field(..., description="Type of credential to create")
|
credential_type: CredentialType = Field(..., description="Type of credential to create")
|
||||||
credential: NonEmptyPasswordCredential | NonEmptyCreditCardCredential = Field(
|
credential: NonEmptyPasswordCredential | NonEmptyCreditCardCredential = Field(
|
||||||
...,
|
...,
|
||||||
|
@ -109,7 +109,7 @@ class CredentialResponse(BaseModel):
|
||||||
..., description="The credential data"
|
..., description="The credential data"
|
||||||
)
|
)
|
||||||
credential_type: CredentialType = Field(..., description="Type of the credential")
|
credential_type: CredentialType = Field(..., description="Type of the credential")
|
||||||
name: str = Field(..., description="Name of the credential", examples=["My Credential"])
|
name: str = Field(..., description="Name of the credential", examples=["Amazon Login"])
|
||||||
|
|
||||||
|
|
||||||
class Credential(BaseModel):
|
class Credential(BaseModel):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue