Skip to content

Commit

Permalink
add random fail node to web_classification_random_fail
Browse files Browse the repository at this point in the history
  • Loading branch information
Min Shi committed Apr 11, 2024
1 parent f6bf913 commit 4ee3595
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import bs4
import requests
import random
from promptflow import tool


@tool
def fetch_text_content_from_url(url: str):
if random.random() < 0.5:
raise ValueError("Random failure")
# Send a request to the URL
try:
headers = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ nodes:
type: code
path: fetch_text_content_from_url.py
inputs:
url: ${inputs.url}
url: ${random_failure.output}
- name: summarize_text_content
type: llm
source:
Expand Down Expand Up @@ -66,3 +66,10 @@ nodes:
path: convert_to_dict.py
inputs:
input_str: ${classify_with_llm.output}
- name: random_failure
type: python
source:
type: code
path: random_failure.py
inputs:
url: ${inputs.url}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import random
from promptflow import tool


# The inputs section will change based on the arguments of the tool function, after you save the code
# Adding type to arguments and return value will help the system show the types properly
# Please update the function name/signature per need
@tool
def random_failure(url: str) -> str:
if random.random() < 0.5:
raise ValueError("Random failure")
return url

0 comments on commit 4ee3595

Please sign in to comment.