FastAPI backend and CLI for Scientific OS protocol generation.
Project description
Python Scientific OS
FastAPI backend equivalent of the TypeScript scientific OS server.
Setup
python -m venv .venv
source .venv/bin/activate
pip install -e .
cp .env.example .env
Add OPENAI_API_KEY and optionally TAVILY_API_KEY to .env.
By default, local development uses SQLite and local file storage, so Docker is optional.
For the full optional stack, install extras:
pip install -e ".[all]"
Package Usage
Install the package in editable mode while developing:
pip install -e .
Install optional Postgres/MinIO support:
pip install -e ".[postgres,s3]"
Build a wheel:
python -m pip wheel . --no-deps -w dist
Install the built wheel:
pip install dist/python_scientific_os-0.1.0-py3-none-any.whl
Start the server
Start the FastAPI server from the project root:
scientific-os-server --reload --port 8000
The API will be available at http://127.0.0.1:8000.
You can also run the app directly with Uvicorn:
uvicorn scientific_os.main:app --reload --port 8000
CLI Chat
With the server running, send a prompt from another terminal:
scientific-os "Create a simple protocol for extracting strawberry DNA."
The CLI prints the response and writes returned IDs, including conversationId and jobId, to stderr.
Use that ID to continue the same conversation:
scientific-os \
--conversation-id 00000000-0000-0000-0000-000000000000 \
"Make it safer for a classroom demo."
Replace the placeholder UUID with the real conversationId.
You can also pipe prompt text into the CLI:
echo "Create a protocol for testing soil pH." | scientific-os
Use --pretty to print the full JSON response:
scientific-os --pretty "List the protocol sections you generated."
Each chat request is tracked as a job. List recent jobs:
scientific-os --list-jobs
Fetch a single job:
scientific-os --job-id 00000000-0000-0000-0000-000000000000
Filter jobs by status:
scientific-os --list-jobs --status failed
If the server is running somewhere else, pass a custom base URL:
scientific-os --server http://127.0.0.1:8001 "Hello"
Without installing the package, the CLI still works as a module:
python -m scientific_os.cli "Hello"
HTTP Chat
Send a chat request to the local server:
curl -sS http://127.0.0.1:8000/api/chat \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"role": "user",
"content": "Create a simple protocol for extracting strawberry DNA."
}
]
}'
To continue a conversation, include the conversationId returned by the previous response:
curl -sS http://127.0.0.1:8000/api/chat \
-H "Content-Type: application/json" \
-d '{
"conversationId": "00000000-0000-0000-0000-000000000000",
"messages": [
{
"role": "user",
"content": "Make it safer for a classroom demo."
}
]
}'
Replace the placeholder UUID with the real conversationId.
Chat and protocol search requests are tracked as jobs. List recent jobs over HTTP:
curl -sS http://127.0.0.1:8000/api/jobs
Fetch a single job:
curl -sS http://127.0.0.1:8000/api/jobs/00000000-0000-0000-0000-000000000000
Optional Docker Services
To use Postgres/pgvector and MinIO instead, set these values in .env:
DATABASE_URL=postgresql://myuser:mypassword@localhost:5432/mydb
STORAGE_BACKEND=s3
S3_ENDPOINT=http://localhost:9000
S3_PUBLIC_ENDPOINT=http://localhost:9000
Then start the backing services with docker compose up -d.
The compatible API routes are:
POST /api/chatGET /api/jobsGET /api/jobs/{job_id}GET /api/conversationsGET /api/conversations/{conversation_id}GET /api/protocols/searchGET /api/protocols/{protocol_id}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_scientific_os-0.1.0.tar.gz.
File metadata
- Download URL: python_scientific_os-0.1.0.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a7e535e71ddb49e6e34f2bb6e6092b1f248ada99cb147eed24c7e81e5c5f029
|
|
| MD5 |
fad76ad7737f10c49c9c75a6f19ff267
|
|
| BLAKE2b-256 |
d682dc975b19a732aafcac2eceadabb32b29b1b94cd7a36e3bdc817e08b138da
|
File details
Details for the file python_scientific_os-0.1.0-py3-none-any.whl.
File metadata
- Download URL: python_scientific_os-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdadd797cea07c5e3b107edca02a08a230e7a99cf6aea35a3416097ea00d053b
|
|
| MD5 |
63540c37a951ae2cdcbe2a49f0926980
|
|
| BLAKE2b-256 |
ee0b49ed6fcde8ff208437dd252fd492ccd0faaa79937d5c1c7a03871aa808b5
|