Skip to content

Commit 867f77d

Browse files
committed
add telemetry tracing into tools.py
Signed-off-by: Tsai, Louie <[email protected]>
1 parent 0c8eaf1 commit 867f77d

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

AgentQnA/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Agents for Question Answering
22

3+
## Table of contents
4+
5+
1. [Overview](#overview)
6+
2. [Deploy with Docker](#deploy-with-docker)
7+
3. [Launch the UI](#launch-the-ui)
8+
4. [Validate Services](#validate-services)
9+
5. [Register Tools](#how-to-register-other-tools-with-the-ai-agent)
10+
311
## Overview
412

513
This example showcases a hierarchical multi-agent system for question-answering applications. The architecture diagram below shows a supervisor agent that interfaces with the user and dispatches tasks to two worker agents to gather information and come up with answers. The worker RAG agent uses the retrieval tool to retrieve relevant documents from a knowledge base - a vector database. The worker SQL agent retrieves relevant data from a SQL database. Although not included in this example by default, other tools such as a web search tool or a knowledge graph query tool can be used by the supervisor agent to gather information from additional sources.

AgentQnA/tests/step4_launch_and_validate_agent_gaudi.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function start_tgi(){
2828
echo "Starting tgi-gaudi server"
2929
cd $WORKDIR/GenAIExamples/AgentQnA/docker_compose/intel/hpu/gaudi
3030
source set_env.sh
31-
docker compose -f $WORKDIR/GenAIExamples/DocIndexRetriever/docker_compose/intel/cpu/xeon/compose.yaml -f compose.yaml tgi_gaudi.yaml up -d
31+
docker compose -f $WORKDIR/GenAIExamples/DocIndexRetriever/docker_compose/intel/cpu/xeon/compose.yaml -f compose.yaml tgi_gaudi.yaml -f compose.telemetry.yaml up -d
3232

3333
}
3434

@@ -40,7 +40,7 @@ function start_all_services() {
4040
echo "**************model is $model**************"
4141
cd $WORKDIR/GenAIExamples/AgentQnA/docker_compose/intel/hpu/gaudi
4242
source set_env.sh
43-
docker compose -f $WORKDIR/GenAIExamples/DocIndexRetriever/docker_compose/intel/cpu/xeon/compose.yaml -f compose.yaml up -d
43+
docker compose -f $WORKDIR/GenAIExamples/DocIndexRetriever/docker_compose/intel/cpu/xeon/compose.yaml -f compose.yaml -f compose.telemetry.yaml up -d
4444
sleep 5s
4545
echo "Waiting vllm gaudi ready"
4646
n=0

AgentQnA/tools/tools.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import os
55

66
import requests
7+
from comps.cores.telemetry.opea_telemetry import opea_telemetry, tracer
78
from tools.pycragapi import CRAG
89

910

11+
@opea_telemetry
1012
def search_web_base(query: str) -> str:
1113
import os
1214

@@ -25,6 +27,7 @@ def search_web_base(query: str) -> str:
2527
return response
2628

2729

30+
@opea_telemetry
2831
def search_knowledge_base(query: str) -> str:
2932
"""Search a knowledge base about music and singers for a given query.
3033
@@ -40,6 +43,7 @@ def search_knowledge_base(query: str) -> str:
4043
return response.json()["text"]
4144

4245

46+
@opea_telemetry
4347
def search_sql_database(query: str) -> str:
4448
"""Search a SQL database on artists and their music with a natural language query.
4549
@@ -55,32 +59,37 @@ def search_sql_database(query: str) -> str:
5559
return response.json()["text"]
5660

5761

62+
@opea_telemetry
5863
def get_grammy_best_artist_by_year(year: int) -> dict:
5964
"""Get the Grammy Best New Artist for a specific year."""
6065
api = CRAG()
6166
year = int(year)
6267
return api.music_grammy_get_best_artist_by_year(year)
6368

6469

70+
@opea_telemetry
6571
def get_members(band_name: str) -> dict:
6672
"""Get the member list of a band."""
6773
api = CRAG()
6874
return api.music_get_members(band_name)
6975

7076

77+
@opea_telemetry
7178
def get_artist_birth_place(artist_name: str) -> dict:
7279
"""Get the birthplace of an artist."""
7380
api = CRAG()
7481
return api.music_get_artist_birth_place(artist_name)
7582

7683

84+
@opea_telemetry
7785
def get_billboard_rank_date(rank: int, date: str = None) -> dict:
7886
"""Get Billboard ranking for a specific rank and date."""
7987
api = CRAG()
8088
rank = int(rank)
8189
return api.music_get_billboard_rank_date(rank, date)
8290

8391

92+
@opea_telemetry
8493
def get_song_release_date(song_name: str) -> dict:
8594
"""Get the release date of a song."""
8695
api = CRAG()

AgentQnA/ui/svelte/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
AGENT_URL = '/v1/chat/completions'
1+
AGENT_URL = 'http://100.83.147.105:9090/v1/chat/completions'

0 commit comments

Comments
 (0)