Skip to content

Commit 87ab39b

Browse files
committed
update(docstring): update docstring (evaluation and cloud)
1 parent a0d6cf1 commit 87ab39b

File tree

5 files changed

+103
-75
lines changed

5 files changed

+103
-75
lines changed

veadk/cloud/cloud_agent_engine.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ class CloudAgentEngine(BaseModel):
4848
Credentials must be set via environment variables for default behavior.
4949
This class performs interactive confirmations for destructive operations like removal.
5050
51-
Example:
52-
>>> from veadk.cloud.cloud_agent_engine import CloudAgentEngine
53-
>>> engine = CloudAgentEngine()
54-
>>> app = engine.deploy("test-app", "/path/to/local/project")
55-
>>> print(app.vefaas_endpoint)
51+
Examples:
52+
```python
53+
from veadk.cloud.cloud_agent_engine import CloudAgentEngine
54+
engine = CloudAgentEngine()
55+
app = engine.deploy("test-app", "/path/to/local/project")
56+
print(app.vefaas_endpoint)
57+
```
5658
"""
5759

5860
volcengine_access_key: str = getenv("VOLCENGINE_ACCESS_KEY")
@@ -221,9 +223,11 @@ def deploy(
221223
Converts path to absolute; sets telemetry opt-out and ADK Web env vars.
222224
Generates default gateway names if not specified.
223225
224-
Example:
225-
>>> app = engine.deploy("my-agent", "./agent-project", local_test=True)
226-
>>> print(f"Deployed at: {app.vefaas_endpoint}")
226+
Examples:
227+
```python
228+
app = engine.deploy("my-agent", "./agent-project", local_test=True)
229+
print(f"Deployed at: {app.vefaas_endpoint}")
230+
```
227231
"""
228232
# prevent deepeval writing operations
229233
veadk_environments["DEEPEVAL_TELEMETRY_OPT_OUT"] = "YES"
@@ -285,9 +289,10 @@ def remove(self, app_name: str):
285289
Interactive prompt required; cancels on non-'y' input.
286290
Deletion is processed asynchronously by VeFaaS.
287291
288-
Example:
289-
>>> engine.remove("my-agent")
290-
Confirm delete cloud app my-agent? (y/N): y
292+
Examples:
293+
```python
294+
engine.remove("my-agent")
295+
```
291296
"""
292297
confirm = input(f"Confirm delete cloud app {app_name}? (y/N): ")
293298
if confirm.lower() != "y":
@@ -324,9 +329,10 @@ def update_function_code(
324329
Preserves gateway and other resources; only function code is updated.
325330
Path is resolved to absolute before processing.
326331
327-
Example:
328-
>>> updated_app = engine.update_function_code("my-agent", "./updated-project")
329-
>>> assert updated_app.vefaas_endpoint == old_endpoint
332+
Examples:
333+
```python
334+
updated_app = engine.update_function_code("my-agent", "./updated-project")
335+
```
330336
"""
331337
# convert `path` to absolute path
332338
path = str(Path(path).resolve())

veadk/cloud/cloud_app.py

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ class CloudApp:
4646
At least one of name, endpoint, or ID must be provided during init.
4747
Agent card mode fetches card from the endpoint's public path.
4848
49-
Example:
50-
>>> from veadk.cloud.cloud_app import CloudApp
51-
>>> app = CloudApp(vefaas_endpoint="https://my-agent.volcengine.com")
52-
>>> response = await app.message_send("Query", "session-1", "user-123")
53-
>>> print(response.message_id)
49+
Examples:
50+
```python
51+
from veadk.cloud.cloud_app import CloudApp
52+
app = CloudApp(vefaas_endpoint="https://my-agent.volcengine.com")
53+
response = await app.message_send("Query", "session-1", "user-123")
54+
print(response.message_id)
55+
```
5456
"""
5557

5658
def __init__(
@@ -80,8 +82,10 @@ def __init__(
8082
Logs info if agent card mode enabled.
8183
Endpoint is fetched via _get_vefaas_endpoint if not set.
8284
83-
Example:
84-
>>> app = CloudApp(vefaas_application_id="app-123", use_agent_card=True)
85+
Examples:
86+
```python
87+
app = CloudApp(vefaas_application_id="app-123", use_agent_card=True)
88+
```
8589
"""
8690
self.vefaas_endpoint = vefaas_endpoint
8791
self.vefaas_application_id = vefaas_application_id
@@ -140,8 +144,10 @@ def _get_vefaas_endpoint(
140144
Logs warning if JSON parsing fails; returns empty on error.
141145
Called during init if endpoint missing.
142146
143-
Example:
144-
>>> endpoint = app._get_vefaas_endpoint("custom-ak", "custom-sk")
147+
Examples:
148+
```python
149+
endpoint = app._get_vefaas_endpoint("custom-ak", "custom-sk")
150+
```
145151
"""
146152
from veadk.integrations.ve_faas.ve_faas import VeFaaS
147153

@@ -180,9 +186,11 @@ def _get_vefaas_application_id_by_name(self) -> str:
180186
Uses default environment credentials.
181187
Internal method for ID resolution.
182188
183-
Example:
184-
>>> app.vefaas_application_name = "my-app"
185-
>>> id = app._get_vefaas_application_id_by_name()
189+
Examples:
190+
```python
191+
app.vefaas_application_name = "my-app"
192+
id = app._get_vefaas_application_id_by_name()
193+
```
186194
"""
187195
if not self.vefaas_application_name:
188196
raise ValueError(
@@ -251,8 +259,10 @@ def update_self(
251259
Raises:
252260
ValueError: If access key or secret key missing.
253261
254-
Example:
255-
>>> app.update_self("ak", "sk")
262+
Examples:
263+
```python
264+
app.update_self("ak", "sk")
265+
```
256266
"""
257267
if not volcengine_ak or not volcengine_sk:
258268
raise ValueError("Volcengine access key and secret key must be set.")
@@ -283,10 +293,10 @@ def delete_self(
283293
Polls every 3 seconds until app no longer exists.
284294
Prints status messages.
285295
286-
Example:
287-
>>> app.delete_self()
288-
Confirm delete cloud app app-123? (y/N): y
289-
Delete application done.
296+
Examples:
297+
```python
298+
app.delete_self()
299+
```
290300
"""
291301
if not volcengine_ak or not volcengine_sk:
292302
raise ValueError("Volcengine access key and secret key must be set.")
@@ -343,9 +353,11 @@ async def message_send(
343353
Debug logs the full response.
344354
Ignores type checks for result as it may not be Task.
345355
346-
Example:
347-
>>> response = await app.message_send("What is AI?", "chat-1", "user-1", timeout=300)
348-
>>> print(response.content)
356+
Examples:
357+
```python
358+
response = await app.message_send("What is AI?", "chat-1", "user-1", timeout=300)
359+
print(response.content)
360+
```
349361
"""
350362
a2a_client = await self._get_a2a_client()
351363

@@ -400,9 +412,11 @@ def get_message_id(message: Message):
400412
Ensures compatibility with a2a-python versions before and after 0.3.0.
401413
Prefers 'message_id' if available, falls back to 'messageId'.
402414
403-
Example:
404-
>>> mid = get_message_id(response_message)
405-
>>> print(mid)
415+
Examples:
416+
```python
417+
mid = get_message_id(response_message)
418+
print(mid)
419+
```
406420
"""
407421
if getattr(message, "messageId", None):
408422
# Compatible with the messageId of the old a2a-python version (<0.3.0) in cloud app

veadk/evaluation/adk_evaluator/adk_evaluator.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ class ADKEvaluator(BaseEvaluator):
6666
Default thresholds: tool=1.0, response=0.8.
6767
Runs each test multiple times (default 2) for average scores.
6868
69-
Example:
70-
>>> agent = Agent(tools=[get_city_weather])
71-
>>> evaluator = ADKEvaluator(agent=agent)
72-
>>> results, failures = await evaluator.evaluate(
73-
... eval_set_file_path="test_folder"
74-
... )
69+
Examples:
70+
```python
71+
agent = Agent(tools=[get_city_weather])
72+
evaluator = ADKEvaluator(agent=agent)
73+
results, failures = await evaluator.evaluate(eval_set_file_path="test_folder")
74+
```
7575
"""
7676

7777
def __init__(
@@ -131,13 +131,14 @@ async def evaluate(
131131
FileNotFoundError: If test file not found.
132132
EvaluationError: If agent fails or scoring fails.
133133
134-
Example:
135-
>>> results, failures = await evaluator.evaluate(
136-
... eval_set_file_path="tests/",
137-
... tool_score_threshold=0.9,
138-
... num_runs=3
139-
... )
140-
>>> print(f"Results: {len(results)}, Failures: {len(failures)}")
134+
Examples:
135+
```python
136+
results, failures = await evaluator.evaluate(
137+
eval_set_file_path="tests/",
138+
tool_score_threshold=0.9,
139+
num_runs=3)
140+
print(f"Results: {len(results)}, Failures: {len(failures)}")
141+
```
141142
"""
142143

143144
# Resolve eval files: accept a directory (scan *.test.json) or a single file

veadk/evaluation/deepeval_evaluator/deepeval_evaluator.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ class DeepevalEvaluator(BaseEvaluator):
6666
Needs judge model credentials from environment if not given.
6767
Turns off cache to get fresh results each time.
6868
69-
Example:
70-
>>> agent = Agent(tools=[get_city_weather])
71-
>>> evaluator = DeepevalEvaluator(agent=agent)
72-
>>> metrics = [GEval(threshold=0.8)]
73-
>>> results = await evaluator.evaluate(metrics, eval_set_file_path="test.json")
69+
Examples:
70+
```python
71+
agent = Agent(tools=[get_city_weather])
72+
evaluator = DeepevalEvaluator(agent=agent)
73+
metrics = [GEval(threshold=0.8)]
74+
results = await evaluator.evaluate(metrics, eval_set_file_path="test.json")
75+
```
7476
"""
7577

7678
def __init__(
@@ -100,12 +102,13 @@ def __init__(
100102
ValueError: If model settings are wrong.
101103
EnvironmentError: If environment variables are missing.
102104
103-
Example:
104-
>>> evaluator = DeepevalEvaluator(
105-
... agent=my_agent,
106-
... judge_model_api_key="sk-...",
107-
... prometheus_config=prometheus_config
108-
... )
105+
Examples:
106+
```python
107+
evaluator = DeepevalEvaluator(
108+
agent=my_agent,
109+
judge_model_api_key="sk-...",
110+
prometheus_config=prometheus_config)
111+
```
109112
"""
110113
super().__init__(agent=agent, name=name)
111114

@@ -162,13 +165,14 @@ async def evaluate(
162165
FileNotFoundError: If test file not found.
163166
EvaluationError: If agent fails or metrics fail.
164167
165-
Example:
166-
>>> metrics = [GEval(threshold=0.8), ToolCorrectnessMetric(threshold=0.5)]
167-
>>> results = await evaluator.evaluate(
168-
... metrics=metrics,
169-
... eval_set_file_path="test_cases.json"
170-
... )
171-
>>> print(f"Test cases run: {len(results.test_results)}")
168+
Examples:
169+
```python
170+
metrics = [GEval(threshold=0.8), ToolCorrectnessMetric(threshold=0.5)]
171+
results = await evaluator.evaluate(
172+
metrics=metrics,
173+
eval_set_file_path="test_cases.json")
174+
print(f"Test cases run: {len(results.test_results)}")
175+
```
172176
"""
173177
# Get evaluation data by parsing eval set file
174178
self.build_eval_set(eval_set, eval_set_file_path)
@@ -268,9 +272,10 @@ def export_results(self, eval_id: str, test_results: EvaluationResult):
268272
Uses fixed thresholds for now: case_threshold=0.5, diff_threshold=0.2.
269273
These may change later.
270274
271-
Example:
272-
>>> evaluator.export_results("test_20240101", test_results)
273-
# Results sent to Prometheus
275+
Examples:
276+
```python
277+
evaluator.export_results("test_20240101", test_results)
278+
```
274279
"""
275280
# fixed attributions
276281
test_name = eval_id

veadk/evaluation/eval_set_file_loader.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ def load_eval_set_from_file(eval_set_file_path: str) -> EvalSet:
3333
Raises:
3434
Exception: If file loading or parsing fails, with details.
3535
36-
Example:
37-
>>> eval_set = load_eval_set_from_file("my_eval.json")
38-
>>> print(len(eval_set.eval_cases))
36+
Examples:
37+
```python
38+
eval_set = load_eval_set_from_file("my_eval.json")
39+
print(len(eval_set.eval_cases))
40+
```
3941
"""
4042
try:
4143
eval_set = adk_load_eval_set_from_file(eval_set_file_path, eval_set_file_path)

0 commit comments

Comments
 (0)