Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

AutoBot

AutoBot is a Chrome-compatible browser extension backed by a local FastAPI service. It reads coding problems and multiple-choice questions from the active page, sends them to the appropriate AI engine, and presents the result in the extension popup or an in-page overlay.

The project uses two complementary AI paths:

  • TypeSafe Jev AI provides fast, structured intent classification and multiple-choice selection.
  • Ollama provides local model inference for code generation, explanations, free-form questions, and optional MCQ solving.

AutoBot is intended for development, learning, and experimentation. Always review generated answers and code before using them.

Branches

The project has two branches for choosing how inference is performed:

  • main is for local inference. It uses Ollama for generated responses and does not require a Gemini API key.
  • gemini-intg is for running generated responses through the Google Gemini API. Set a Gemini API key before using this branch.

Check out the branch that matches your setup:

git switch main          # Local inference with Ollama
git switch gemini-intg   # Gemini inference with an API key

Capabilities

Coding problems

On coding sites such as LeetCode, the extension can extract the problem title, description, selected language, and starter code. The backend sends that context to the configured Ollama model and returns structured results containing intuition, an algorithmic approach, time and space complexity, complete solution code, and edge-case explanations.

The popup can display the solution and copy generated code. The content script also contains editor-insertion logic for supported page editors.

Multiple-choice questions

The content script detects options from HTML radio buttons and checkboxes, labels, ARIA quiz roles, common quiz elements, and text formatted like A., B), C:, or D-. AutoBot sends the question and normalized options to Jev AI by default. When a result is returned, the extension can highlight or select the matching option if automatic ticking is enabled.

General questions and controls

Free-form text is sent to Ollama for explanations and factual questions. The popup and in-page overlay support coding solving, MCQ detection and solving, free-form questions, model selection, default language selection, MCQ auto-ticking, stealth mode, overlay toggling, and backend URL configuration.

Architecture

flowchart LR
      Page[Active web page] --> Content[content.js]
      Content --> Popup[popup.js]
      Popup -->|HTTP JSON| API[FastAPI localhost:3000]
      API --> Router[router_service.py]
      Router -->|intent and MCQ Choice| Jev[TypeSafe Jev AI]
      API --> Ollama[ollama_service.py]
      Ollama -->|local HTTP| Runtime[Ollama localhost:11434]
      Runtime --> Model[Local Ollama model]
      Jev --> API
      Model --> API
      API --> Popup
      Popup --> Content
      Content --> Page
Loading

Browser extension

The extension/ directory is a Manifest V3 extension. popup.js provides the toolbar UI and calls the API; content.js extracts page context, manages the overlay, and interacts with page controls and editors; background.js owns extension messaging and the Alt+S overlay shortcut; and the CSS files style the popup and overlay.

The content script is registered for <all_urls>, but Chrome-restricted pages such as chrome:// pages do not allow normal content-script communication. Use AutoBot on regular http:// or https:// pages.

FastAPI backend

The backend starts from server.py and launches src.main:app on localhost:3000.

  • src/main.py defines request models, CORS configuration, and HTTP routes.
  • src/router_service.py owns Jev AI classification and Jev AI MCQ solving.
  • src/ollama_service.py owns local Ollama calls, model discovery, response parsing, and model caching.

Ollama model instances are cached by model name and response format, with a 30-minute keep-alive to reduce repeated model startup cost.

How TypeSafe Jev AI Is Used

AutoBot uses the typesafe-sdk package and lazily creates one AsyncTypeSafeClient in router_service.py. The client is reused for subsequent requests so the service can benefit from connection pooling.

Intent classification with Choice

The backend defines a TypeSafe Choice with three outcomes:

Intent Meaning Next step
mcq A question with answer options Solve with Jev or selected Ollama model
coding A programming or algorithm problem Generate code with Ollama
text A general or conceptual question Answer with Ollama

The /api/ask route passes the query to Jev AI through system_one:

result = await client.system_one(
      state=query,
      questions={"intent": _ROUTER_CHOICE},
)
intent = result.choices["intent"].choice

This produces a constrained typed decision instead of an unconstrained text label. The returned intent selects the next solver.

MCQ solving with Choice

For MCQs, AutoBot builds a state containing the question and every option, then creates criteria mapping each option letter to its text. Jev is asked to select exactly one correct option. The backend returns an answer key, answer text, confidence value, and reasoning, for example:

{
   "answer_key": "B",
   "answer_text": "Selected option text",
   "confidence": 0.98,
   "reasoning": "Option B selected by TypeSafe Jev AI engine."
}

Jev is used as a fast structured decision engine, not as the code-generation model. Its two jobs are classifying unified queries and selecting a stable MCQ answer key that the extension can use to locate and tick the corresponding page element.

The SDK reads the TypeSafe credential from TYPESAFE_API_KEY. Keep this key in a local environment file and never commit it.

Ollama Responsibilities

Ollama runs locally at http://localhost:11434 when a task needs generated content rather than a constrained choice. Coding requests use a strict JSON prompt with fields for intuition, approach, complexity, code, and explanation. Text requests use a general assistant prompt and return Markdown-compatible text. MCQs can use Ollama when a non-Jev model is explicitly selected.

The default Ollama model is currently phi4-mini. The extension may store names such as ollama:phi4-mini; the backend removes that prefix before creating a ChatOllama instance.

Request Flow

For /api/ask, the flow is:

  1. The client sends a query.
  2. Jev classifies it as mcq, coding, or text.
  3. For an MCQ, supplied options are used or A through D options are extracted from the query.
  4. Coding goes to Ollama for structured generation.
  5. Text goes to Ollama for a Markdown answer.
  6. The backend returns the selected intent and result.

If an MCQ has no detectable options, AutoBot treats it as conceptual text and sends it to Ollama.

Method Route Purpose
GET / Health and engine information
GET /api/models Jev plus locally available Ollama models
POST /api/ask Classify and solve a mixed query
POST /api/solve-coding Generate a coding solution with Ollama
POST /api/solve-mcq Solve an MCQ with Jev or Ollama
POST /api/solve-text Answer free-form text with Ollama

Interactive API documentation is available at http://localhost:3000/docs.

Requirements and Configuration

  • Python 3.14 or newer
  • uv for backend dependencies
  • Ollama installed and running locally with a model such as phi4-mini
  • A TypeSafe API key for Jev routing or MCQ solving
  • Google Chrome or another Chromium-based browser

Create backend/.env for local secrets:

TYPESAFE_API_KEY=your_typesafe_api_key

python-dotenv loads this file when the backend starts. The current Ollama URL is configured as http://localhost:11434 in src/ollama_service.py.

Install and Run the Backend

From the repository root:

cd backend
uv sync
uv run python server.py

The API listens at http://localhost:3000. For development reload mode:

DEV=1 uv run python server.py

Verify the service with:

curl http://localhost:3000/
curl http://localhost:3000/api/models

Add AutoBot to Chrome

AutoBot is loaded as an unpacked developer extension; no Chrome Web Store package is required.

  1. Start the backend and Ollama.
  2. Open chrome://extensions in Chrome.
  3. Enable Developer mode in the upper-right corner.
  4. Click Load unpacked.
  5. Select the repository's extension/ directory, for example /home/onix/Code/auto_bot/extension.
  6. Confirm that the AutoBot extension card appears and is enabled.
  7. Pin the extension from Chrome's extensions menu if desired.
  8. Open a normal http:// or https:// page and click the AutoBot toolbar icon.

In popup settings, confirm the backend is http://localhost:3000, choose jev for Jev routing and MCQs or an Ollama model for local generation, select the page language, and enable auto-ticking if required.

Chrome may show a Reload button on the extension card after source changes. Click it after editing extension files.

The manifest requests activeTab, scripting, storage, and clipboardWrite, plus access to the local backend, Ollama, and supported web pages. Chrome does not permit injection into its own settings, extension, or new-tab pages.

Project Layout

backend/
   server.py                 Backend entry point
   pyproject.toml            Python dependencies and metadata
   src/main.py               FastAPI app, models, and routes
   src/router_service.py     TypeSafe Jev intent and MCQ logic
   src/ollama_service.py     Ollama clients, prompts, and discovery
   tests/                    Backend tests

extension/
   manifest.json             Chrome Manifest V3 configuration
   popup.html/js/css          Toolbar popup UI
   content.js                Page extraction and page interaction
   overlay.css               In-page overlay styling
   background.js              Service worker and extension messaging

Testing

Run tests from backend/:

uv run pytest

The current suite includes model-name normalization coverage. A dependency-free compilation check is:

uv run python -m compileall -q server.py src

Troubleshooting

  • Backend connection: Confirm server.py is running on port 3000 and that the popup backend URL matches.
  • Jev failure: Check backend/.env for a valid TYPESAFE_API_KEY, then restart the backend.
  • Ollama failure: Confirm Ollama is running at http://localhost:11434 and that the selected model is installed.
  • No MCQ detected: The page must expose readable question text and at least two detectable options.
  • No extension response: Refresh the page and reload the extension. Restricted Chrome pages cannot run the content script.

About

AutoBot is a Chrome-compatible browser extension.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages