Skip to content

Commit c86cc82

Browse files
committed
feat: add run url
1 parent 6ce5466 commit c86cc82

File tree

5 files changed

+28
-6
lines changed

5 files changed

+28
-6
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "workflowai"
3-
version = "0.6.0.dev11"
3+
version = "0.6.0.dev12"
44
description = ""
55
authors = ["Guillaume Aquilina <guillaume@workflowai.com>"]
66
readme = "README.md"

workflowai/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import os
21
from collections.abc import Callable, Iterable
32
from typing import Any, Optional
43

54
from typing_extensions import deprecated
65

6+
from workflowai import env
77
from workflowai.core.client._types import AgentDecorator
88
from workflowai.core.client.client import WorkflowAI as WorkflowAI
99
from workflowai.core.domain import model
@@ -23,8 +23,8 @@ def _build_client(
2323
default_version: Optional[VersionReference] = None,
2424
):
2525
return WorkflowAI(
26-
endpoint=endpoint or os.getenv("WORKFLOWAI_API_URL"),
27-
api_key=api_key or os.getenv("WORKFLOWAI_API_KEY", ""),
26+
endpoint=endpoint or env.WORKFLOWAI_API_URL,
27+
api_key=api_key or env.WORKFLOWAI_API_KEY,
2828
default_version=default_version,
2929
)
3030

@@ -33,7 +33,7 @@ def _build_client(
3333
shared_client: WorkflowAI = _build_client()
3434

3535
# The default model to use when running agents without a deployment
36-
DEFAULT_MODEL: "model.ModelOrStr" = os.getenv("WORKFLOWAI_DEFAULT_MODEL", "gemini-1.5-pro-latest")
36+
DEFAULT_MODEL: "model.ModelOrStr" = env.WORKFLOWAI_DEFAULT_MODEL
3737

3838

3939
def init(api_key: Optional[str] = None, url: Optional[str] = None, default_version: Optional[VersionReference] = None):

workflowai/core/domain/run.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from pydantic import BaseModel, Field # pyright: ignore [reportUnknownVariableType]
55
from typing_extensions import Unpack
66

7+
from workflowai import env
78
from workflowai.core import _common_types
89
from workflowai.core.client import _types
910
from workflowai.core.domain.errors import BaseError
@@ -120,6 +121,10 @@ def __str__(self) -> str:
120121
"""Return a string representation of the run."""
121122
return self.format_output()
122123

124+
@property
125+
def run_url(self):
126+
return f"{env.WORKFLOWAI_APP_URL}/agents/{self.agent_id}/runs/{self.id}"
127+
123128

124129
class _AgentBase(Protocol, Generic[AgentOutput]):
125130
async def reply(

workflowai/core/domain/run_test.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from unittest.mock import Mock
1+
from unittest.mock import Mock, patch
22

33
import pytest
44
from pydantic import BaseModel
@@ -114,3 +114,9 @@ def test_format_output_no_cost_latency() -> None:
114114
=================================================="""
115115

116116
assert run.format_output() == expected
117+
118+
119+
class TestRunURL:
120+
@patch("workflowai.env.WORKFLOWAI_APP_URL", "https://workflowai.hello")
121+
def test_run_url(self, run1: Run[_TestOutput]):
122+
assert run1.run_url == "https://workflowai.hello/agents/agent-1/runs/test-id"

workflowai/env.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""A file to describe all environment variables"""
2+
3+
import os
4+
5+
WORKFLOWAI_APP_URL = os.getenv("WORKFLOWAI_APP_URL", "workflowai.com")
6+
7+
WORKFLOWAI_DEFAULT_MODEL = os.getenv("WORKFLOWAI_DEFAULT_MODEL", "gemini-1.5-pro-latest")
8+
9+
WORKFLOWAI_API_URL = os.getenv("WORKFLOWAI_API_URL")
10+
11+
WORKFLOWAI_API_KEY = os.getenv("WORKFLOWAI_API_KEY", "")

0 commit comments

Comments
 (0)