Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(examples): wait before quickstart preview (#2167)

Yuan Shenhenga27c18eee9f6
diff --git a/docs/en/getting-started/02-quickstart.md b/docs/en/getting-started/02-quickstart.md
index 02d9d0653..5d59adafa 100644
--- a/docs/en/getting-started/02-quickstart.md
+++ b/docs/en/getting-started/02-quickstart.md
@@ -150,8 +150,11 @@ try:
# Add resource (supports URL, file, or directory)
# Local directory scans respect .gitignore by default.
+ # Wait until semantic processing completes before inspecting the resource.
+ print("Wait for semantic processing...")
add_result = client.add_resource(
- path="https://raw.githubusercontent.com/volcengine/OpenViking/refs/heads/main/README.md"
+ path="https://raw.githubusercontent.com/volcengine/OpenViking/refs/heads/main/README.md",
+ wait=True,
)
root_uri = add_result['root_uri']
@@ -165,10 +168,6 @@ try:
content = client.read(glob_result['matches'][0])
print(f"Content preview: {content[:200]}...\n")
- # Wait for semantic processing to complete
- print("Wait for semantic processing...")
- client.wait_processed()
-
# Get abstract and overview of the resource
abstract = client.abstract(root_uri)
overview = client.overview(root_uri)
@@ -196,12 +195,13 @@ python example.py
### Expected Output
```
+Wait for semantic processing...
+
Directory structure:
...
Content preview: ...
-Wait for semantic processing...
Abstract:
...
diff --git a/docs/zh/getting-started/02-quickstart.md b/docs/zh/getting-started/02-quickstart.md
index 5b57914d0..9bc778991 100644
--- a/docs/zh/getting-started/02-quickstart.md
+++ b/docs/zh/getting-started/02-quickstart.md
@@ -150,8 +150,11 @@ try:
# Add resource (supports URL, file, or directory)
# Local directory scans respect .gitignore by default.
+ # Wait until semantic processing completes before inspecting the resource.
+ print("Wait for semantic processing...")
add_result = client.add_resource(
- path="https://raw.githubusercontent.com/volcengine/OpenViking/refs/heads/main/README.md"
+ path="https://raw.githubusercontent.com/volcengine/OpenViking/refs/heads/main/README.md",
+ wait=True,
)
root_uri = add_result['root_uri']
@@ -165,10 +168,6 @@ try:
content = client.read(glob_result['matches'][0])
print(f"Content preview: {content[:200]}...\n")
- # Wait for semantic processing to complete
- print("Wait for semantic processing...")
- client.wait_processed()
-
# Get abstract and overview of the resource
abstract = client.abstract(root_uri)
overview = client.overview(root_uri)
@@ -196,12 +195,13 @@ python example.py
### 预期输出
```
+Wait for semantic processing...
+
Directory structure:
...
Content preview: ...
-Wait for semantic processing...
Abstract:
...
diff --git a/examples/quick_start.py b/examples/quick_start.py
index cc455980a..4fcb8da40 100644
--- a/examples/quick_start.py
+++ b/examples/quick_start.py
@@ -6,9 +6,11 @@ client = ov.OpenViking(path="./data")
try:
client.initialize()
- # Add resource (URL, file, or directory)
+ # Add resource (URL, file, or directory) and wait until it is ready to inspect
+ print("Wait for semantic processing...")
res = client.add_resource(
- path="https://raw.githubusercontent.com/volcengine/OpenViking/refs/heads/main/README.md"
+ path="https://raw.githubusercontent.com/volcengine/OpenViking/refs/heads/main/README.md",
+ wait=True,
)
root_uri = res["root_uri"]
res = client.ls(root_uri) # Explore resource tree
@@ -19,9 +21,6 @@ try:
content = client.read(res["matches"][0])
print(f"Content preview: {content[:200]}...\n")
- print(" Wait for semantic processing...")
- client.wait_processed()
-
abstract = client.abstract(root_uri) # Get abstract
overview = client.overview(root_uri) # Get overview
print(f"Abstract:\n{abstract}\n\nOverview:\n{overview}\n")
diff --git a/tests/integration/test_quick_start_lite.py b/tests/integration/test_quick_start_lite.py
index 4fd9b769d..b0cb07e97 100644
--- a/tests/integration/test_quick_start_lite.py
+++ b/tests/integration/test_quick_start_lite.py
@@ -4,6 +4,8 @@ import shutil
import sys
import tempfile
import unittest
+from contextlib import redirect_stdout
+from io import StringIO
from unittest.mock import MagicMock, patch
# Ensure the project root is in sys.path
@@ -237,12 +239,19 @@ class TestQuickStartLite(unittest.TestCase):
try:
os.chdir(os.path.dirname(script_path))
global_ns = {"__name__": "__main__", "__file__": script_path}
- exec(code, global_ns)
+ output = StringIO()
+ with redirect_stdout(output):
+ exec(code, global_ns)
except Exception as e:
self.fail(f"Quick start script execution failed: {e}")
finally:
os.chdir(original_cwd)
+ output_text = output.getvalue()
+ self.assertIn("Directory structure:", output_text)
+ self.assertNotIn("Directory structure:\n[]", output_text)
+ self.assertIn("Content preview:", output_text)
+
if __name__ == "__main__":
unittest.main()