Skip to content

Commit

Permalink
Add eval tab (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwxxzz authored Sep 13, 2024
1 parent 6566427 commit 521cf64
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/pai_rag/app/web/rag_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def evaluate_for_response_stage(self):
response = dotdict(json.loads(r.text))
if r.status_code != HTTPStatus.OK:
raise RagApiError(code=r.status_code, msg=response.message)
print("evaluate_for_response_stage response", response)
return response


rag_client = RagWebClient()
1 change: 0 additions & 1 deletion src/pai_rag/app/web/tabs/eval_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def eval_response_stage():
response_res = rag_client.evaluate_for_response_stage()
except RagApiError as api_error:
raise gr.Error(f"HTTP {api_error.code} Error: {api_error.msg}")

formatted_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
pd_results = {
"Metrics": ["Faithfulness", "Correctness", "Similarity", "LastModified"],
Expand Down
7 changes: 4 additions & 3 deletions src/pai_rag/app/web/webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pai_rag.app.web.tabs.chat_tab import create_chat_tab
from pai_rag.app.web.tabs.agent_tab import create_agent_tab
from pai_rag.app.web.tabs.data_analysis_tab import create_data_analysis_tab
from pai_rag.app.web.tabs.eval_tab import create_evaluation_tab
from pai_rag.app.web.element_manager import elem_manager
from pai_rag.app.web.ui_constants import (
DEFAULT_CSS_STYPE,
Expand Down Expand Up @@ -56,15 +57,15 @@ def make_homepage():
with gr.Tab("\N{fire} Chat"):
chat_elements = create_chat_tab()
elem_manager.add_elems(chat_elements)
# with gr.Tab("\N{rocket} Evaluation"):
# eval_elements = create_evaluation_tab()
# elem_manager.add_elems(eval_elements)
with gr.Tab("\N{rocket} Agent"):
agent_elements = create_agent_tab()
elem_manager.add_elems(agent_elements)
with gr.Tab("\N{bar chart} Data Analysis"):
analysis_elements = create_data_analysis_tab()
elem_manager.add_elems(analysis_elements)
with gr.Tab("\N{rocket} Evaluation"):
eval_elements = create_evaluation_tab()
elem_manager.add_elems(eval_elements)
homepage.load(
resume_ui, outputs=elem_manager.get_elem_list(), concurrency_limit=None
)
Expand Down
4 changes: 4 additions & 0 deletions src/pai_rag/config/settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ name = "qwen-turbo"
[rag.llm.function_calling_llm]
source = ""

[rag.llm.multi_modal]
enable = false
source = ""

[rag.llm_chat_engine]
type = "SimpleChatEngine"

Expand Down
15 changes: 6 additions & 9 deletions src/pai_rag/modules/evaluation/batch_eval_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from llama_index.core.base.response.schema import RESPONSE_TYPE, Response
from llama_index.core.evaluation.base import BaseEvaluator, EvaluationResult
from pai_rag.integrations.evaluation.retrieval.evaluator import MyRetrievalEvalResult
from fastapi.concurrency import run_in_threadpool


async def eval_response_worker(
Expand Down Expand Up @@ -277,14 +276,12 @@ async def aevaluate_queries(
response_jobs.append(response_worker(self.semaphore, query_engine, query))
responses = await self.asyncio_mod.gather(*response_jobs)

return await run_in_threadpool(
lambda: self.aevaluate_responses(
queries=queries,
node_ids=node_ids,
responses=responses,
references=reference_answers,
**eval_kwargs_lists,
)
return await self.aevaluate_responses(
queries=queries,
node_ids=node_ids,
responses=responses,
references=reference_answers,
**eval_kwargs_lists,
)

async def aevaluate_queries_for_retrieval(
Expand Down

0 comments on commit 521cf64

Please sign in to comment.