imbajin commented on code in PR #78:
URL:
https://github.com/apache/incubator-hugegraph-ai/pull/78#discussion_r1746502062
##########
hugegraph-llm/src/hugegraph_llm/demo/rag_web_demo.py:
##########
@@ -602,7 +604,88 @@ def toggle_slider(enable):
outputs=[raw_out, vector_only_out, graph_only_out,
graph_vector_out],
)
- gr.Markdown("""## 3. Others (🚧) """)
+ gr.Markdown("""## 3. Multi Question Test (❔)""")
+ tests_df_headers = [
+ "Question",
+ "Expected Answer",
+ "Basic LLM Answer",
+ "Vector-only Answer",
+ "Graph-only Answer",
+ "Graph-Vector Answer",
+ ]
+
+ def read_excel(file):
+ df = pd.read_excel(BytesIO(file)) if file else pd.DataFrame()
+ df.to_excel(os.path.join(resource_path, "demo",
".questions.xlsx"), index=False)
+ if df.empty:
+ df = pd.DataFrame([[""] * len(tests_df_headers)],
columns=tests_df_headers)
+ else:
+ df.columns = tests_df_headers
+ return df
+
+ def several_rag_answer(
+ is_raw_answer: bool,
+ is_vector_only_answer: bool,
+ is_graph_only_answer: bool,
+ is_graph_vector_answer: bool,
+ graph_ratio: float,
+ rerank_method: Literal["bleu", "reranker"],
+ near_neighbor_first: bool,
+ custom_related_information: str,
+ answer_prompt: str,
+ progress=gr.Progress(track_tqdm=True),
+ ):
+ df = pd.read_excel(os.path.join(resource_path, "demo",
".questions.xlsx"), dtype=str)
+ total_rows = len(df)
+ for index, row in df.iterrows():
+ question = row.iloc[0]
+ basic_llm_answer, vector_only_answer, graph_only_answer,
graph_vector_answer = rag_answer(
+ question,
+ is_raw_answer,
+ is_vector_only_answer,
+ is_graph_only_answer,
+ is_graph_vector_answer,
+ graph_ratio,
+ rerank_method,
+ near_neighbor_first,
+ custom_related_information,
+ answer_prompt,
+ )
+ df.at[index, "Basic LLM Answer"] = basic_llm_answer
+ df.at[index, "Vector-only Answer"] = vector_only_answer
+ df.at[index, "Graph-only Answer"] = graph_only_answer
+ df.at[index, "Graph-Vector Answer"] = graph_vector_answer
+ progress((index + 1, total_rows))
+ answers_path = os.path.join(resource_path, "demo",
".questions_answers.xlsx")
+ df.to_excel(answers_path, index=False)
+ return df, answers_path
+
+ with gr.Row():
+ with gr.Column():
+ questions_file = gr.File(file_types=[".xlsx"],
label="Questions File", type="binary")
+ with gr.Column():
+ test_template_file = os.path.join(resource_path, "demo",
"questions_template.xlsx")
+ gr.File(value=test_template_file, label="Download Template
File")
+ answers_btn = gr.Button("Answer Questions", variant="primary")
Review Comment:
Should CSV format be supported?
##########
hugegraph-llm/.gitignore:
##########
Review Comment:
<img width="609" alt="image"
src="https://github.com/user-attachments/assets/ce2e619b-cad9-445b-89f6-0731968b96d6">
could enable the add `end-of-line` option in IDE maybe
##########
hugegraph-llm/src/hugegraph_llm/demo/rag_web_demo.py:
##########
@@ -602,7 +604,88 @@ def toggle_slider(enable):
outputs=[raw_out, vector_only_out, graph_only_out,
graph_vector_out],
)
- gr.Markdown("""## 3. Others (🚧) """)
+ gr.Markdown("""## 3. Multi Question Test (❔)""")
Review Comment:
```suggestion
gr.Markdown("""## 3. User Function """)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]