WilliamGazeley
commited on
Commit
·
b1f79b2
1
Parent(s):
bbded71
Implement retry
Browse files- src/app.py +18 -9
- tests/qa_questions.json +15 -16
src/app.py
CHANGED
|
@@ -97,26 +97,35 @@ workflow.set_finish_point("output_node")
|
|
| 97 |
flow = workflow.compile()
|
| 98 |
|
| 99 |
progress_map = {
|
| 100 |
-
"question_rephrase": ":
|
| 101 |
-
"function_agent": ":
|
| 102 |
-
"output_node": ":bulb:
|
| 103 |
}
|
| 104 |
|
| 105 |
def main():
|
| 106 |
st.title("LLM-ADE 9B Demo")
|
| 107 |
|
| 108 |
input_text = st.text_area("Enter your text here:", value="", height=200)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
if st.button("Generate"):
|
| 111 |
if input_text:
|
| 112 |
with st.status("Generating response...") as status:
|
| 113 |
config.status = status
|
| 114 |
-
config.status.update(label=":
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
config.status.update(label=progress_map[key])
|
| 118 |
-
pprint(f"Finished running: {key}")
|
| 119 |
-
st.write(value["generation"])
|
| 120 |
config.status.update(label="Finished!", state="complete", expanded=True)
|
| 121 |
else:
|
| 122 |
st.warning("Please enter some text to generate a response.")
|
|
|
|
| 97 |
flow = workflow.compile()
|
| 98 |
|
| 99 |
progress_map = {
|
| 100 |
+
"question_rephrase": ":mag: Collecting data",
|
| 101 |
+
"function_agent": ":bulb: Preparing response",
|
| 102 |
+
"output_node": ":bulb: Done!",
|
| 103 |
}
|
| 104 |
|
| 105 |
def main():
|
| 106 |
st.title("LLM-ADE 9B Demo")
|
| 107 |
|
| 108 |
input_text = st.text_area("Enter your text here:", value="", height=200)
|
| 109 |
+
|
| 110 |
+
def get_response(input_text: str) -> str:
|
| 111 |
+
try:
|
| 112 |
+
for output in flow.stream({"question": input_text}):
|
| 113 |
+
for key, value in output.items():
|
| 114 |
+
config.status.update(label=progress_map[key])
|
| 115 |
+
pprint(f"Finished running: {key}")
|
| 116 |
+
return value["generation"]
|
| 117 |
+
except Exception as e:
|
| 118 |
+
logger.error(e)
|
| 119 |
+
logger.info("Retrying..")
|
| 120 |
+
get_response(input_text)
|
| 121 |
|
| 122 |
if st.button("Generate"):
|
| 123 |
if input_text:
|
| 124 |
with st.status("Generating response...") as status:
|
| 125 |
config.status = status
|
| 126 |
+
config.status.update(label=":question: Breaking down question")
|
| 127 |
+
response = get_response(input_text)
|
| 128 |
+
st.write(response)
|
|
|
|
|
|
|
|
|
|
| 129 |
config.status.update(label="Finished!", state="complete", expanded=True)
|
| 130 |
else:
|
| 131 |
st.warning("Please enter some text to generate a response.")
|
tests/qa_questions.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
[
|
| 2 |
{
|
| 3 |
-
"question": "
|
| 4 |
"expecteds":
|
| 5 |
{
|
| 6 |
"includes": ["microstrategy", "bitcoin"],
|
|
@@ -39,52 +39,51 @@
|
|
| 39 |
"question": "Should I buy BTC or ETH?",
|
| 40 |
"expecteds":
|
| 41 |
{
|
| 42 |
-
"includes": [],
|
| 43 |
"excludes": [],
|
| 44 |
"functions_used": ["get_analysis"]
|
| 45 |
}
|
| 46 |
},
|
| 47 |
{
|
| 48 |
-
"question": "
|
| 49 |
"expecteds":
|
| 50 |
{
|
| 51 |
"includes": ["BTC"],
|
| 52 |
"excludes": [],
|
| 53 |
-
"functions_used": ["get_current_stock_price"]
|
| 54 |
}
|
| 55 |
-
}
|
| 56 |
{
|
| 57 |
-
"question": "Why is Bitcoin
|
| 58 |
"expecteds":
|
| 59 |
{
|
| 60 |
"includes": ["BTC"],
|
| 61 |
"excludes": [],
|
| 62 |
-
"functions_used": ["
|
| 63 |
}
|
| 64 |
-
}
|
| 65 |
{
|
| 66 |
-
"question": "
|
| 67 |
"expecteds":
|
| 68 |
{
|
| 69 |
"includes": ["BTC"],
|
| 70 |
"excludes": [],
|
| 71 |
-
"functions_used": ["
|
| 72 |
}
|
| 73 |
-
},
|
| 74 |
{
|
| 75 |
-
"question": "What
|
| 76 |
"expecteds":
|
| 77 |
{
|
| 78 |
-
"includes": ["BTC"],
|
| 79 |
"excludes": [],
|
| 80 |
"functions_used": ["get_analysis"]
|
| 81 |
}
|
| 82 |
-
}
|
| 83 |
{
|
| 84 |
-
"question": "What
|
| 85 |
"expecteds":
|
| 86 |
{
|
| 87 |
-
"includes": ["
|
| 88 |
"excludes": [],
|
| 89 |
"functions_used": ["get_analysis"]
|
| 90 |
}
|
|
|
|
| 1 |
[
|
| 2 |
{
|
| 3 |
+
"question": "Should I buy bitcoin or MSTR?",
|
| 4 |
"expecteds":
|
| 5 |
{
|
| 6 |
"includes": ["microstrategy", "bitcoin"],
|
|
|
|
| 39 |
"question": "Should I buy BTC or ETH?",
|
| 40 |
"expecteds":
|
| 41 |
{
|
| 42 |
+
"includes": ["BTC", "ETH"],
|
| 43 |
"excludes": [],
|
| 44 |
"functions_used": ["get_analysis"]
|
| 45 |
}
|
| 46 |
},
|
| 47 |
{
|
| 48 |
+
"question": "Why is Bitcoin down today?",
|
| 49 |
"expecteds":
|
| 50 |
{
|
| 51 |
"includes": ["BTC"],
|
| 52 |
"excludes": [],
|
| 53 |
+
"functions_used": ["get_analysis", "get_current_stock_price"]
|
| 54 |
}
|
| 55 |
+
}
|
| 56 |
{
|
| 57 |
+
"question": "Why is Bitcoin up today?",
|
| 58 |
"expecteds":
|
| 59 |
{
|
| 60 |
"includes": ["BTC"],
|
| 61 |
"excludes": [],
|
| 62 |
+
"functions_used": ["get_analysis", "get_current_stock_price"]
|
| 63 |
}
|
| 64 |
+
}
|
| 65 |
{
|
| 66 |
+
"question": "What is the latest news on Bitcoin?",
|
| 67 |
"expecteds":
|
| 68 |
{
|
| 69 |
"includes": ["BTC"],
|
| 70 |
"excludes": [],
|
| 71 |
+
"functions_used": ["get_analysis"]
|
| 72 |
}
|
|
|
|
| 73 |
{
|
| 74 |
+
"question": "What does bitcoin halving mean?",
|
| 75 |
"expecteds":
|
| 76 |
{
|
| 77 |
+
"includes": ["BTC", "mining"],
|
| 78 |
"excludes": [],
|
| 79 |
"functions_used": ["get_analysis"]
|
| 80 |
}
|
| 81 |
+
}
|
| 82 |
{
|
| 83 |
+
"question": "What bitcoin ETF should I buy?",
|
| 84 |
"expecteds":
|
| 85 |
{
|
| 86 |
+
"includes": ["BTC", "ETF"],
|
| 87 |
"excludes": [],
|
| 88 |
"functions_used": ["get_analysis"]
|
| 89 |
}
|