srush commited on
Commit
30de231
·
1 Parent(s): 12cd2b3

Upload with huggingface_hub

Browse files
Files changed (3) hide show
  1. app.py +22 -0
  2. requirements.txt +4 -0
  3. 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}}