import openviking as ov # Initialize OpenViking client with data directory client = ov.SyncOpenViking(path="./data") try: # Initialize the client client.initialize() # Add resource (supports URL, file, or directory) add_result = client.add_resource( path="/Users/bytedance/Downloads/exp/experience_data_mini.json", resource_type="json", # 明确指定类型 tags=["large_data", "agent_context", "structured"], ) root_uri = add_result["root_uri"] # Explore the resource tree structure ls_result = client.ls(root_uri) print(f"Directory structure:\n{ls_result}\n") # Use glob to find markdown files glob_result = client.glob(pattern="**/*.md", uri=root_uri) if glob_result["matches"]: 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) print(f"Abstract:\n{abstract}\n\nOverview:\n{overview}\n") # Perform semantic search results = client.find("what is openviking", target_uri=root_uri) print("Search results:") for r in results.resources: print(f" {r.uri} (score: {r.score:.4f})") # Close the client client.close() except Exception as e: print(f"Error: {e}")