Skip to content

Commit 07e81c5

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/ui/frontend/dompurify-3.4.10
2 parents e8b9b1a + 8147b47 commit 07e81c5

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

contrib/docs/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
def invoke_chain_with_fallback(topic: str) -> str:
2-
try:
3-
return invoke_chain(topic) # noqa: F821
4-
except Exception:
5-
return invoke_anthropic_chain(topic) # noqa: F821
6-
7-
if __name__ == '__main__':
8-
print(invoke_chain_with_fallback("ice cream"))
1+
def invoke_chain_with_fallback(topic: str) -> str:
2+
"""Invoke a chain with a fallback to Anthropic chain.
3+
4+
Attempts to invoke a chain using `invoke_chain` and falls back to
5+
`invoke_anthropic_chain` if any exception is raised.
6+
7+
Args:
8+
topic: The topic to pass to the chain invocation.
9+
10+
Returns:
11+
The result from the successful chain invocation.
12+
"""
13+
try:
14+
return invoke_chain(topic) # noqa: F821
15+
except Exception:
16+
return invoke_anthropic_chain(topic) # noqa: F821
17+
18+
if __name__ == '__main__':
19+
print(invoke_chain_with_fallback("ice cream"))

0 commit comments

Comments
 (0)