Spaces:
Running
Running
A loop node, not working yet.
Browse files- server/llm_ops.py +7 -0
- server/ops.py +19 -0
server/llm_ops.py
CHANGED
@@ -63,3 +63,10 @@ def view(input):
|
|
63 |
}}
|
64 |
}
|
65 |
return v
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
}}
|
64 |
}
|
65 |
return v
|
66 |
+
|
67 |
+
@ops.input_position(input="right")
|
68 |
+
@ops.output_position(output="left")
|
69 |
+
@ops.op("Loop")
|
70 |
+
def loop(input, *, max_iterations: int = 10):
|
71 |
+
'''Data can flow back here until it becomes empty or reaches the limit.'''
|
72 |
+
return input
|
server/ops.py
CHANGED
@@ -176,6 +176,25 @@ def op(name, *, view='basic', sub_nodes=None):
|
|
176 |
op.sub_nodes = sub_nodes
|
177 |
op.type = 'sub_flow'
|
178 |
ALL_OPS[name] = op
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
return func
|
180 |
return decorator
|
181 |
|
|
|
176 |
op.sub_nodes = sub_nodes
|
177 |
op.type = 'sub_flow'
|
178 |
ALL_OPS[name] = op
|
179 |
+
func.__op__ = op
|
180 |
+
return func
|
181 |
+
return decorator
|
182 |
+
|
183 |
+
def input_position(**kwargs):
|
184 |
+
'''Decorator for specifying unusual positions for the inputs.'''
|
185 |
+
def decorator(func):
|
186 |
+
op = func.__op__
|
187 |
+
for k, v in kwargs.items():
|
188 |
+
op.inputs[k].position = v
|
189 |
+
return func
|
190 |
+
return decorator
|
191 |
+
|
192 |
+
def output_position(**kwargs):
|
193 |
+
'''Decorator for specifying unusual positions for the outputs.'''
|
194 |
+
def decorator(func):
|
195 |
+
op = func.__op__
|
196 |
+
for k, v in kwargs.items():
|
197 |
+
op.outputs[k].position = v
|
198 |
return func
|
199 |
return decorator
|
200 |
|