Skip to main content

Cortexa

Cortexa is a fast, local-first AI assistant for Python. It lets you use a real large language model (LLM) directly from Python with a clean, minimal API.

  • ✅ Runs locally (no API keys required)
  • ✅ Uses Ollama as the AI engine
  • ✅ Streams responses (fast, ChatGPT-style typing)
  • ✅ Concise, readable terminal output
  • ✅ Simple import cortexa usage

What Cortexa Is (and Is Not)

Cortexa is:

  • A Python library that talks to a local AI model
  • Free and offline after setup
  • Ideal for learning, projects, and experimentation

Cortexa is not:

  • A hosted cloud service
  • A replacement for installing an AI runtime

Cortexa uses Ollama to run models locally. Ollama is required.


Requirements

  • Python 3.8+
  • Ollama installed (one-time)

Download Ollama from: https://ollama.com


Installation

1. Install Ollama

After installing Ollama, restart your computer.

Pull a model:

ollama pull llama3

Make sure Ollama is running:

ollama serve

(Or just open the Ollama app.)


2. Install Cortexa

Once published to PyPI:

pip install cortexa

For local development:

pip install requests

Basic Usage

import cortexa

ai = cortexa.Cortexa()

ai.chat("Explain recursion simply")
ai.chat("Write a Python function to reverse a list")

Responses stream live in the terminal.


Features

  • Streaming output (fast, responsive)
  • Concise answers by default
  • Terminal-friendly formatting
  • Conversation memory (limited for speed)
  • Offline & private

Configuration

ai = cortexa.Cortexa(
    model="llama3",     # Any Ollama model
    max_history=4,      # Context window size
    width=80            # Terminal wrap width
)

Smaller models = faster responses.


Troubleshooting

Ollama already running error

This is normal:

Only one usage of each socket address is permitted

It means Ollama is already running.

Slow responses

  • Use a smaller model
  • Reduce max_history
  • Make sure no other heavy apps are running

Project Structure

cortexa/
│
├── cortexa/
│   ├── __init__.py
│   ├── core.py
│   ├── llm.py
│   ├── memory.py
│   └── prompts.py
│
└── test.py

License

MIT License


Disclaimer

Cortexa runs AI models locally using Ollama. Model quality, speed, and hardware usage depend on your system and chosen model.


Roadmap (Planned)

  • CLI interface (cortexa chat)
  • Hybrid local / API mode
  • Tool usage (files, calculator)
  • Persistent memory

Author

Samarth Ankit Chugh

Metadata

Release files for cortexa 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cortexa 1.0.1
File Size Uploaded
cortexa-1.0.1.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cortexa 1.0.1
File Interpreter ABI Platform
cortexa-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.1 kB

Release files / cortexa-1.0.1.tar.gz

Download URL cortexa-1.0.1.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f148de97f22128210f07428efa68ea23c5929dbfec5dd629e55cee2d3d662ca9
BLAKE2b-256 checksum
How to use checksums
880c79fbec690af840c4897967d8645c9ffadd04b129b9a314a02624846fb882
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.13

Release files / cortexa-1.0.1-py3-none-any.whl

Download URL cortexa-1.0.1-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2265ff5da2228f114401997b6c566af9cc84152207f1d7c24d5ecf93648b5deb
BLAKE2b-256 checksum
How to use checksums
d91dcd215fb66e0f40bddb76e0dd1ae4e13b1330431b0a9d8d039b1d0079c0b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.13

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page