Spaces:
Running
Running
abdoh-alkhateeb
commited on
Commit
•
bb3140d
1
Parent(s):
565d5c0
Add cost tracking in Gradio interface
Browse files
app.py
CHANGED
@@ -14,12 +14,14 @@ thinking_ladder_agent = ThinkingLadderAgent()
|
|
14 |
synthesis_agent = SynthesisAgent()
|
15 |
|
16 |
|
17 |
-
def main(query: str) -> str:
|
18 |
-
main_title, themes,
|
19 |
-
sources,
|
20 |
-
classified_sources,
|
21 |
-
synthesis,
|
22 |
-
return synthesis
|
23 |
|
|
|
|
|
24 |
|
25 |
-
|
|
|
|
14 |
synthesis_agent = SynthesisAgent()
|
15 |
|
16 |
|
17 |
+
def main(query: str) -> tuple[str, float]:
|
18 |
+
main_title, themes, metrics_a = outline_agent.run(query)
|
19 |
+
sources, metrics_b = research_agent.run(themes)
|
20 |
+
classified_sources, metrics_c = thinking_ladder_agent.run(themes, sources)
|
21 |
+
synthesis, metrics_d = synthesis_agent.run(main_title, themes, classified_sources)
|
|
|
22 |
|
23 |
+
cost = sum(list(map(lambda metrics: metrics["cost"], [metrics_a, metrics_b, metrics_c, metrics_d])))
|
24 |
+
return synthesis, cost
|
25 |
|
26 |
+
|
27 |
+
gr.Interface(fn=main, inputs=gr.Textbox(label="Query:"), outputs=[gr.Textbox(label="Generated Synthesis:"), gr.Number(label="Cost ($):")]).launch()
|