Skip to content

NavigatorBBS/sysop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– sysop - GitHub Copilot SDK Jupyter Assistant

Lint Python 3.10+ License: MIT

sysop is a Jupyter notebook assistant powered by GitHub's Copilot SDK. It provides an AI chatbot interface that integrates seamlessly with JupyterLab, enabling natural language interactions for code analysis, suggestions, and general assistanceβ€”all within your notebook environment.

✨ Features

  • πŸ€– GitHub Copilot Integration - Powered by GitHub's official Copilot SDK
  • πŸ““ Jupyter Native - Load as an IPython extension with %load_ext sysop
  • πŸ’¬ Auto-Rendering Markdown - Responses display as formatted markdown automatically
  • πŸ”„ Conversation History - Maintains context across multiple interactions
  • πŸ› οΈ Extensible Tools - Register custom tools using @define_tool decorator
  • ⚑ Async-First - Built on asyncio for responsive notebook experience

πŸ“¦ Installation

From PyPI (when published)

pip install sysop

From Source

git clone https://github.com/NavigatorBBS/sysop.git
cd sysop
pip install -e ".[dev]"

πŸš€ Quick Start

1. Set up your GitHub Copilot token

Create a .env file or set an environment variable:

GITHUB_COPILOT_PAT=your-github-copilot-pat-here

Get your token from: https://github.com/settings/tokens (requires copilot scope)

2. Use the CLI

You can test the agent from your terminal:

sysop -c "How can I optimize this pandas DataFrame?"
sysop --chat "Analyze this code for efficiency"

3. Load the extension in a Jupyter notebook

from dotenv import load_dotenv
load_dotenv()

%load_ext sysop

This automatically:

  • Initializes the NotebookChatAgent with your GitHub Copilot credentials
  • Injects the agent variable into your notebook namespace
  • Makes display() and Markdown() utilities available

4. Chat with the agent

# Simple usage - response auto-displays as markdown
response = await agent.chat("How can I optimize this pandas DataFrame?")
response

πŸ“š Usage Examples

CLI Usage

# Ask questions
sysop -c "What's the best way to handle missing data in pandas?"

# For longer questions with special characters, use quotes
sysop --chat "How do I optimize DataFrame groupby operations?"

Jupyter Extension Usage

# Ask questions
response = await agent.chat("What's the best way to handle missing data in pandas?")
response  # Auto-displays as formatted markdown

# For plain text without markdown formatting
plain_text = await agent.chat("Your question", as_markdown=False)

Code Analysis

# Analyze code snippets
code = '''
df = pd.read_csv('data.csv')
df = df[df['value'] > 0]
result = df.groupby('category').sum()
'''

response = await agent.analyze_code(code, context="data aggregation pipeline")
response

Conversation Management

# Get conversation history
messages = await agent.get_messages()
print(f"Conversation has {len(messages)} messages")

# Clear history to start fresh
await agent.clear_history()

# Cleanup when done (releases resources)
await agent.cleanup()

Custom Tools (Advanced)

Create custom tools that the agent can use:

from pydantic import BaseModel, Field
from copilot import define_tool

class AnalyzeCodeParams(BaseModel):
    code: str = Field(description="Python code to analyze")
    context: str = Field(default="", description="Optional context")

@define_tool(description="Analyze Python code for quality and best practices")
async def analyze_code_tool(params: AnalyzeCodeParams) -> str:
    # Your analysis logic here
    return f"Analyzing {len(params.code)} characters of code..."

# Register tools before first use
agent = NotebookChatAgent(model="gpt-4o")
agent.tools = [analyze_code_tool]

response = await agent.chat("Can you analyze my code?")

πŸ”§ Configuration

sysop uses environment variables for configuration:

Variable Required Description
GITHUB_COPILOT_PAT Yes Your GitHub Copilot Personal Access Token

Programmatic Initialization

You can also initialize the agent programmatically:

from sysop import NotebookChatAgent

agent = NotebookChatAgent(
    github_token="your-token",
    model="gpt-4o",
    system_prompt="Custom system prompt..."
)

πŸ“– API Reference

NotebookChatAgent

The main chatbot agent class.

Methods:

  • async chat(user_message: str, as_markdown: bool = True) - Send a message and get a response
  • async analyze_code(code: str, context: Optional[str] = None) - Analyze Python code
  • async suggest_notebook_improvements(notebook_summary: str) - Get notebook improvement suggestions
  • async get_messages() - Get conversation history
  • async clear_history() - Clear conversation and start fresh
  • async cleanup() - Clean up resources (call when done)
  • add_plugin(plugin_instance, plugin_name) - Register a plugin (before first chat)

MarkdownResponse

A string subclass that auto-renders as Markdown in Jupyter notebooks.

IPython Extension

  • load_ipython_extension(ipython) - Called by %load_ext sysop
  • unload_ipython_extension(ipython) - Called by %unload_ext sysop

πŸ§ͺ Development

Setup Development Environment

git clone https://github.com/NavigatorBBS/sysop.git
cd sysop
pip install -e ".[dev]"

Run Tests

pytest tests/ -v

Linting

# Format code
black src/ tests/ examples/
isort src/ tests/ examples/

# Check style
flake8 src/ tests/ examples/ --max-line-length=100

🀝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ”— Links

⚠️ Requirements

  • Python 3.10 or higher
  • GitHub Copilot subscription and access token
  • JupyterLab 4.0+ or IPython 8.0+

πŸ› Known Issues

  • Tools/plugins must be registered before the first chat() call
  • Session creation is lazy (initialized on first use)
  • Requires valid GitHub Copilot PAT with appropriate scopes

πŸ“ Changelog

v0.1.0 (Initial Release)

  • Core NotebookChatAgent with GitHub Copilot SDK integration
  • IPython extension for seamless Jupyter integration
  • Auto-rendering markdown responses
  • Conversation history management
  • Custom tool support via @define_tool
  • Async-first API design

Made with ❀️ by Christopher Landry

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors