File tree Expand file tree Collapse file tree 1 file changed +0
-37
lines changed Expand file tree Collapse file tree 1 file changed +0
-37
lines changed Original file line number Diff line number Diff line change 41
41
__all__ = ["use" , "get_path_url" ]
42
42
43
43
44
- def _in_repl () -> bool :
45
- return bool (
46
- sys .flags .interactive # python -i
47
- or hasattr (sys , "ps1" ) # prompt strings exist
48
- or (
49
- sys .stdin .isatty () # tty
50
- and sys .stdout .isatty ()
51
- )
52
- or ("get_ipython" in globals ())
53
- )
54
-
55
-
56
- def _in_module_scope () -> bool :
57
- """
58
- Returns True when called from top level module scope.
59
- """
60
- if os .getenv ("REPLICATE_ALWAYS_ALLOW_USE" ):
61
- return True
62
-
63
- # If we're running in a REPL.
64
- if _in_repl ():
65
- return True
66
-
67
- if frame := inspect .currentframe ():
68
- print (frame )
69
- if caller := frame .f_back :
70
- print (caller .f_code .co_name )
71
- return caller .f_code .co_name == "<module>"
72
-
73
- return False
74
-
75
-
76
44
def _has_concatenate_iterator_output_type (openapi_schema : dict ) -> bool :
77
45
"""
78
46
Returns true if the model output type is ConcatenateIterator or
@@ -767,17 +735,12 @@ def use(
767
735
"""
768
736
Use a Replicate model as a function.
769
737
770
- This function can only be called at the top level of a module.
771
-
772
738
Example:
773
739
774
740
flux_dev = replicate.use("black-forest-labs/flux-dev")
775
741
output = flux_dev(prompt="make me a sandwich")
776
742
777
743
"""
778
- if not _in_module_scope ():
779
- raise RuntimeError ("You may only call replicate.use() at the top level." )
780
-
781
744
try :
782
745
ref = ref .name # type: ignore
783
746
except AttributeError :
You can’t perform that action at this time.
0 commit comments