Spaces:
Runtime error
Runtime error
Upload with huggingface_hub
Browse files- app.py +57 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Prompt from ...
|
2 |
+
#
|
3 |
+
|
4 |
+
prompt = """
|
5 |
+
Question: Who lived longer, Muhammad Ali or Alan Turing?
|
6 |
+
Are follow up questions needed here: Yes.
|
7 |
+
Follow up: How old was Muhammad Ali when he died?
|
8 |
+
Intermediate answer: Muhammad Ali was 74 years old when he died.
|
9 |
+
Follow up: How old was Alan Turing when he died?
|
10 |
+
Intermediate answer: Alan Turing was 41 years old when he died.
|
11 |
+
So the final answer is: Muhammad Ali
|
12 |
+
|
13 |
+
Question: When was the founder of craigslist born?
|
14 |
+
Are follow up questions needed here: Yes.
|
15 |
+
Follow up: Who was the founder of craigslist?
|
16 |
+
Intermediate answer: Craigslist was founded by Craig Newmark.
|
17 |
+
Follow up: When was Craig Newmark born?
|
18 |
+
Intermediate answer: Craig Newmark was born on December 6, 1952.
|
19 |
+
So the final answer is: December 6, 1952
|
20 |
+
|
21 |
+
Question: Who was the maternal grandfather of George Washington?
|
22 |
+
Are follow up questions needed here: Yes.
|
23 |
+
Follow up: Who was the mother of George Washington?
|
24 |
+
Intermediate answer: The mother of George Washington was Mary Ball Washington.
|
25 |
+
Follow up: Who was the father of Mary Ball Washington?
|
26 |
+
Intermediate answer: The father of Mary Ball Washington was Joseph Ball.
|
27 |
+
So the final answer is: Joseph Ball
|
28 |
+
|
29 |
+
Question: Are both the directors of Jaws and Casino Royale from the same country?
|
30 |
+
Are follow up questions needed here: Yes.
|
31 |
+
Follow up: Who is the director of Jaws?
|
32 |
+
Intermediate answer: The director of Jaws is Steven Spielberg.
|
33 |
+
Follow up: Where is Steven Spielberg from?
|
34 |
+
Intermediate answer: The United States.
|
35 |
+
Follow up: Who is the director of Casino Royale?
|
36 |
+
Intermediate answer: The director of Casino Royale is Martin Campbell.
|
37 |
+
Follow up: Where is Martin Campbell from?
|
38 |
+
Intermediate answer: New Zealand.
|
39 |
+
So the final answer is: No
|
40 |
+
|
41 |
+
Question: {{input}}
|
42 |
+
Are followup questions needed here: {% if agent_scratchpad %}Yes{%else%}No{% endif %}.
|
43 |
+
"""
|
44 |
+
|
45 |
+
import jinja2
|
46 |
+
|
47 |
+
class SelfAsk:
|
48 |
+
def render(self, input: str, agent_scratchpad: bool):
|
49 |
+
return jinja.render(prompt, dict(input=input,
|
50 |
+
agent_scatchpad=agent_scratchpad))
|
51 |
+
|
52 |
+
def parse(self, response: str):
|
53 |
+
pass
|
54 |
+
|
55 |
+
|
56 |
+
def stop(self):
|
57 |
+
return []
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
git+https://github.com/srush/minichain
|
3 |
+
manifest-ml
|