James Kelly
commited on
Commit
·
e9134fc
1
Parent(s):
782113f
added topK param
Browse files
app.py
CHANGED
@@ -12,16 +12,18 @@ pipe_config = PipeConfig(
|
|
12 |
CTM = CTMatch(pipe_config)
|
13 |
|
14 |
|
15 |
-
def ctmatch_web_api(topic_query: str) -> str:
|
16 |
-
return '\n\n'.join([f"{nid}: {txt}" for nid, txt in CTM.match_pipeline(topic_query, top_k=
|
17 |
|
18 |
|
19 |
if __name__ == "__main__":
|
20 |
|
|
|
21 |
with gr.Blocks(css=".gradio-container {background-color: #00CED1}") as demo:
|
22 |
name = gr.Textbox(lines=5, label="patient description", placeholder="Patient is a 45-year-old man with a history of anaplastic astrocytoma...")
|
|
|
23 |
output = gr.Textbox(lines=10, label="matching trials")
|
24 |
greet_btn = gr.Button("match")
|
25 |
-
greet_btn.click(fn=ctmatch_web_api, inputs=name, outputs=output, api_name="match")
|
26 |
|
27 |
demo.queue().launch(debug=True)
|
|
|
12 |
CTM = CTMatch(pipe_config)
|
13 |
|
14 |
|
15 |
+
def ctmatch_web_api(topic_query: str, topK: int = 5) -> str:
|
16 |
+
return '\n\n'.join([f"{nid}: {txt}" for nid, txt in CTM.match_pipeline(topic=topic_query, top_k=int(topK))])
|
17 |
|
18 |
|
19 |
if __name__ == "__main__":
|
20 |
|
21 |
+
|
22 |
with gr.Blocks(css=".gradio-container {background-color: #00CED1}") as demo:
|
23 |
name = gr.Textbox(lines=5, label="patient description", placeholder="Patient is a 45-year-old man with a history of anaplastic astrocytoma...")
|
24 |
+
topK = gr.Number(label='topK', info='number of documents to return, <= 50', value=5)
|
25 |
output = gr.Textbox(lines=10, label="matching trials")
|
26 |
greet_btn = gr.Button("match")
|
27 |
+
greet_btn.click(fn=ctmatch_web_api, inputs=[name, topK], outputs=output, api_name="match")
|
28 |
|
29 |
demo.queue().launch(debug=True)
|