Skip to content

Commit

Permalink
Merge branch 'peiwen/add_example_flow' of https://github.com/microsof…
Browse files Browse the repository at this point in the history
…t/promptflow into peiwen/add_example_flow
  • Loading branch information
PeiwenGaoMS committed Sep 18, 2023
2 parents eb8b261 + a78eecb commit 12d8b0d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/promptflow/promptflow/contracts/run_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@


class RunMode(str, Enum):
"""An enumeration of possible run modes."""

Test = "Test"
SingleNode = "SingleNode"
Batch = "Batch"

@classmethod
def parse(cls, value: str):
"""Parse string to RunMode."""
"""Parse a string to a RunMode enum value.
:param value: The string to parse.
:type value: str
:return: The corresponding RunMode enum value.
:rtype: ~promptflow.contracts.run_mode.RunMode
:raises ValueError: If the value is not a valid string.
"""
if not isinstance(value, str):
raise ValueError(f"Invalid value type to parse: {type(value)}")
if value == "SingleNode":
Expand Down
24 changes: 24 additions & 0 deletions src/promptflow/promptflow/contracts/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,37 @@


class TraceType(str, Enum):
"""An enumeration class to represent different types of traces."""

LLM = "LLM"
TOOL = "Tool"
LANGCHAIN = "LangChain"


@dataclass
class Trace:
"""A dataclass that represents a trace of a program execution.
:param name: The name of the trace.
:type name: str
:param type: The type of the trace.
:type type: ~promptflow.contracts.trace.TraceType
:param inputs: The inputs of the trace.
:type inputs: Dict[str, Any]
:param output: The output of the trace, or None if not available.
:type output: Optional[Any]
:param start_time: The timestamp of the start time, or None if not available.
:type start_time: Optional[float]
:param end_time: The timestamp of the end time, or None if not available.
:type end_time: Optional[float]
:param error: The error message of the trace, or None if no error occurred.
:type error: Optional[str]
:param children: The list of child traces, or None if no children.
:type children: Optional[List[Trace]]
:param node_name: The node name of the trace, used for flow level trace, or None if not applicable.
:type node_name: Optional[str]
"""

name: str
type: TraceType
inputs: Dict[str, Any]
Expand Down

0 comments on commit 12d8b0d

Please sign in to comment.