This guide explains how to use the DataBridge interactive shell for quick experimentation and debugging.
Getting Started
The DataBridge shell provides an interactive Python environment with the SDK pre-configured. To start the shell:
# Without authentication (connects to localhost:8000):pythonshell.py# With authentication (using a generated URI):pythonshell.py"databridge://user:token@localhost:8000"
The shell will automatically:
Connect to http://localhost:8000 if no URI is provided
Convert databridge:// to http:// for localhost URIs
Handle authentication when a URI with credentials is provided
Basic Usage
Once the shell starts, you'll have access to a db object that provides all SDK functionality:
# Ingest text contentdoc = db.ingest_text( content="Machine learning is fascinating...", metadata={"title": "ML Introduction"})print(f"Document ID: {doc['external_id']}")# Ingest a filedoc = db.ingest_file( file="research_paper.pdf", filename="research_paper.pdf", metadata={"category": "research"})print(f"Document ID: {doc['external_id']}")# Search for contentchunks = db.retrieve_chunks( query="What are the key findings?", filters={"category": "research"}, k=4, min_score=0.7)for chunk in chunks:print(f"Score: {chunk['score']}")print(f"Content: {chunk['content']}")print("---")
Features
The shell environment includes:
Tab completion for methods and attributes
Command history (use arrow keys)
Access to all SDK functionality
Pretty-printed results
Built-in help system
Getting Help
To see available methods and documentation:
# List all available methodshelp(db)# Get help for a specific methodhelp(db.ingest_text)help(db.retrieve_chunks)
Shell Tips
Command History
Use up/down arrow keys to cycle through previous commands
Commands persist between sessions
Tab Completion
Press Tab to complete method names
Press Tab twice to see all available completions
Multiline Input
For long commands, you can write multiple lines
The shell will wait for complete Python statements
Exit
Use Ctrl+D or type exit() to exit the shell
Common Tasks
Document Management
# List recent documentsdocs = db.list_documents(limit=5)for doc in docs:print(f"ID: {doc['external_id']}")print(f"Title: {doc['metadata'].get('title')}")print("---")# Get document by IDdoc = db.get_document("doc_123")print(f"Content Type: {doc['content_type']}")print(f"Metadata: {doc['metadata']}")