Skip to content

Commit 54e27f3

Browse files
authored
Merge pull request #213 from volcengine/fix/typos
fix(typo): fix typos in docs and init
2 parents 562dd91 + 36886b8 commit 54e27f3

File tree

6 files changed

+49
-9
lines changed

6 files changed

+49
-9
lines changed

docs/content/2.configurations/2.envs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ navigation:
1212
| 环境变量名称 | 释义 |
1313
| :- | :- |
1414
| `VOLCENGINE_ACCESS_KEY` | 火山引擎 Access Key |
15-
| `VOLCENGINE_SECRET_KEY` | 火山引擎 Access Key |
15+
| `VOLCENGINE_SECRET_KEY` | 火山引擎 Secret Key |
1616

1717
对应 `yaml` 文件格式:
1818

veadk/cli/cli_web.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def init_for_veadk(
154154
eval_set_results_manager: Any,
155155
agents_dir: str,
156156
extra_plugins: Optional[list[str]] = None,
157+
**kwargs: Any,
157158
):
158159
self.agent_loader = agent_loader
159160
self.artifact_service = artifact_service
@@ -166,6 +167,9 @@ def init_for_veadk(
166167
self.runner_dict = {}
167168
self.extra_plugins = extra_plugins or []
168169

170+
for key, value in kwargs.items():
171+
setattr(self, key, value)
172+
169173
# parse VeADK memories
170174
short_term_memory, long_term_memory = _get_memory(module_path=agents_dir)
171175
self.session_service = short_term_memory.session_service

veadk/memory/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __getattr__(name):
2525
from veadk.memory.short_term_memory import ShortTermMemory
2626

2727
return ShortTermMemory
28-
if name == "LongTeremMemory":
28+
if name == "LongTermMemory":
2929
from veadk.memory.long_term_memory import LongTermMemory
3030

3131
return LongTermMemory

veadk/memory/short_term_memory.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
BaseSessionService,
2020
DatabaseSessionService,
2121
InMemorySessionService,
22+
Session,
2223
)
2324
from pydantic import BaseModel, Field, PrivateAttr
2425

@@ -106,7 +107,7 @@ async def create_session(
106107
app_name: str,
107108
user_id: str,
108109
session_id: str,
109-
) -> None:
110+
) -> Session | None:
110111
if isinstance(self._session_service, DatabaseSessionService):
111112
list_sessions_response = await self._session_service.list_sessions(
112113
app_name=app_name, user_id=user_id
@@ -122,7 +123,12 @@ async def create_session(
122123
)
123124
is None
124125
):
125-
# create a new session for this running
126-
await self._session_service.create_session(
126+
return await self._session_service.create_session(
127127
app_name=app_name, user_id=user_id, session_id=session_id
128128
)
129+
else:
130+
logger.info(
131+
f"Session {session_id} already exists with app_name={app_name} user_id={user_id}."
132+
)
133+
134+
return None

veadk/tracing/telemetry/exporters/apmplus_exporter.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
from typing import Any
1818

1919
from google.adk.agents.invocation_context import InvocationContext
20+
from google.adk.events import Event
2021
from google.adk.models.llm_request import LlmRequest
2122
from google.adk.models.llm_response import LlmResponse
23+
from google.adk.tools import BaseTool
2224
from opentelemetry import metrics, trace
2325
from opentelemetry import metrics as metrics_api
2426
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter
@@ -195,7 +197,7 @@ def __init__(
195197
explicit_bucket_boundaries_advisory=_GEN_AI_SERVER_TIME_PER_OUTPUT_TOKEN_BUCKETS,
196198
)
197199

198-
def record(
200+
def record_call_llm(
199201
self,
200202
invocation_context: InvocationContext,
201203
event_id: str,
@@ -267,6 +269,14 @@ def record(
267269
# time_per_output_token, attributes=attributes
268270
# )
269271

272+
def record_tool_call(
273+
self,
274+
tool: BaseTool,
275+
args: dict[str, Any],
276+
function_response_event: Event,
277+
):
278+
logger.debug(f"Record tool call work in progress. Tool: {tool.name}")
279+
270280

271281
class APMPlusExporterConfig(BaseModel):
272282
endpoint: str = Field(

veadk/tracing/telemetry/telemetry.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333

3434
logger = get_logger(__name__)
3535

36+
meter_uploader = None
3637

37-
def _upload_metrics(
38+
39+
def _upload_call_llm_metrics(
3840
invocation_context: InvocationContext,
3941
event_id: str,
4042
llm_request: LlmRequest,
@@ -47,11 +49,27 @@ def _upload_metrics(
4749
for tracer in tracers:
4850
for exporter in getattr(tracer, "exporters", []):
4951
if getattr(exporter, "meter_uploader", None):
50-
exporter.meter_uploader.record(
52+
global meter_uploader
53+
meter_uploader = exporter.meter_uploader
54+
exporter.meter_uploader.record_call_llm(
5155
invocation_context, event_id, llm_request, llm_response
5256
)
5357

5458

59+
def _upload_tool_call_metrics(
60+
tool: BaseTool,
61+
args: dict[str, Any],
62+
function_response_event: Event,
63+
):
64+
global meter_uploader
65+
if meter_uploader:
66+
meter_uploader.record_tool_call(tool, args, function_response_event)
67+
else:
68+
logger.warning(
69+
"Meter uploader is not initialized yet. Skip recording tool call metrics."
70+
)
71+
72+
5573
def _set_agent_input_attribute(
5674
span: Span, invocation_context: InvocationContext
5775
) -> None:
@@ -203,6 +221,8 @@ def trace_tool_call(
203221
response: ExtractorResponse = attr_extractor(params)
204222
ExtractorResponse.update_span(span, attr_name, response)
205223

224+
_upload_tool_call_metrics(tool, args, function_response_event)
225+
206226

207227
def trace_call_llm(
208228
invocation_context: InvocationContext,
@@ -252,7 +272,7 @@ def trace_call_llm(
252272
response: ExtractorResponse = attr_extractor(params)
253273
ExtractorResponse.update_span(span, attr_name, response)
254274

255-
_upload_metrics(invocation_context, event_id, llm_request, llm_response)
275+
_upload_call_llm_metrics(invocation_context, event_id, llm_request, llm_response)
256276

257277

258278
# Do not modify this function

0 commit comments

Comments
 (0)