Skip to content

alkispoly-db/skill-agent

Repository files navigation

Example of a skills-based agent

This app shows how to build an agent entirely based on skills and a system prompt. The agent is deployed as a databricks app and exposes an OpenAI-compatible chat/completions endpoint.

Project Structure

├── app.py                          # Main FastAPI application
├── app.yaml                        # Databricks deployment config
├── config.py                       # Configuration with Pydantic settings
├── requirements.txt                # Python dependencies
├── chat_cli.py                     # Interactive CLI client for testing
├── agent/
│   ├── __init__.py
│   ├── core.py                    # Agent creation and initialization
│   ├── provider.py                # Multi-provider support (Databricks, Anthropic, etc.)
│   ├── system_prompt.md           # Agent system prompt (editable)
│   └── skills/
│       └── cookie-flavor-generator/  # Example skill
├── models/
│   ├── __init__.py
│   └── openai_schema.py           # OpenAI-compatible models
└── routes/
    ├── __init__.py
    └── v1/
        ├── __init__.py
        ├── completions.py         # Chat completions endpoint
        └── healthcheck.py         # Health check endpoint

Local Development

Setup

  1. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  2. Install dependencies:

    pip install -r requirements.txt

Running Locally

Start the development server:

uvicorn app:app --reload --host 0.0.0.0 --port 5000

The API will be available at:

Testing the Endpoint

Using curl:

curl -X POST "http://localhost:5000/api/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {"role": "user", "content": "Hello, how are you?"}
    ]
  }'

Using Python:

import requests

response = requests.post(
    "http://localhost:5000/api/v1/chat/completions",
    json={
        "messages": [
            {"role": "user", "content": "Hello, how are you?"}
        ]
    }
)

print(response.json())

Using chat_cli.py (interactive client with conversation history):

python chat_cli.py --host localhost --port 5000

This provides an interactive chat interface where you can have multi-turn conversations with the agent.

API Documentation

POST /api/v1/chat/completions

Create a chat completion (OpenAI-compatible).

Request Body:

{
  "messages": [
    {
      "role": "user|assistant|system",
      "content": "string"
    }
  ]
}

Response:

{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "created": 1234567890,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Response text..."
      },
      "finish_reason": "stop"
    }
  ]
}

Error Response:

{
  "error": {
    "message": "Error description",
    "type": "invalid_request_error",
    "param": "messages",
    "code": "invalid_value"
  }
}

GET /api/v1/healthcheck

Check service health status.

Response:

{
  "status": "healthy",
  "timestamp": "2026-01-10T12:00:00.000000",
  "service": "openai-compatible-api"
}

Databricks Deployment

Quick Start

Prerequisites: Databricks CLI configured with a profile (assumes ~/.databrickscfg is already set up)

# 1. Create the app
databricks apps create skill-agent --description "Marketing Research Agent"

# 2. Upload source code
databricks workspace import-dir . /Workspace/Users/YOUR.EMAIL@company.com/apps/skill-agent --overwrite

# 3. Deploy
databricks apps deploy skill-agent --source-code-path /Workspace/Users/YOUR.EMAIL@company.com/apps/skill-agent

# 4. Test with chat_cli.py
python chat_cli.py --url $(databricks apps get skill-agent --output json | jq -r '.url') --databricks-profile DEFAULT

Detailed Instructions

For comprehensive deployment instructions, troubleshooting, and monitoring, see DATABRICKS_DEPLOYMENT.md.

References

License

This project is provided as-is for demonstration purposes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages