Spaces:
Runtime error
Runtime error
Upload with huggingface_hub
Browse files- app.py +22 -0
- requirements.txt +4 -0
- test.pmpt.tpl +1 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from minichain import prompt, Mock, show
|
2 |
+
import minichain
|
3 |
+
|
4 |
+
@prompt(Mock(["hello"]))
|
5 |
+
def prompt_function1(model, x):
|
6 |
+
return model(x)
|
7 |
+
|
8 |
+
@prompt(Mock(["b"]), template_file="test.pmpt.tpl")
|
9 |
+
def prompt_function2(model, x):
|
10 |
+
return model(dict(x=x))
|
11 |
+
|
12 |
+
def run(query):
|
13 |
+
x = prompt_function1(query)
|
14 |
+
return prompt_function2(prompt_function2(x))
|
15 |
+
|
16 |
+
|
17 |
+
demo = show(run,
|
18 |
+
examples=["a"],
|
19 |
+
subprompts=[prompt_function1, prompt_function2, prompt_function2])
|
20 |
+
|
21 |
+
if __name__ == "__main__":
|
22 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio==3.21.0
|
2 |
+
git+https://github.com/srush/minichain@gradio
|
3 |
+
manifest-ml
|
4 |
+
faiss-cpu
|
test.pmpt.tpl
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Hello there! {{x}}
|