feat: agent node
This commit is contained in:
33
README.md
33
README.md
@@ -95,5 +95,38 @@ For self-hosting (e.g. Tailscale/HTTPS): set `CORS_ORIGIN` to your frontend URL;
|
||||
| PUT | `/api/todos/:id` | Update. |
|
||||
| DELETE | `/api/todos/:id` | Delete. |
|
||||
| GET | `/health` | Health check (e.g. for Docker). |
|
||||
| POST | `/api/agent` | Run AI agent; body `{ "prompt", "context?", "contextNodes?" }` → `{ "markdown" }`. |
|
||||
|
||||
Data is in-memory (resets on restart). Add a JSON file or DB later if needed.
|
||||
|
||||
---
|
||||
|
||||
## Agent node (local LLM or OpenAI)
|
||||
|
||||
The **Agent** node uses an OpenAI-compatible API. You can use:
|
||||
|
||||
**1. Local LLM (e.g. LM Studio)**
|
||||
|
||||
1. Install [LM Studio](https://lmstudio.ai/) and load a model.
|
||||
2. Start the local server: in LM Studio open the **Developer** tab and run the **Local Server** (default: `http://localhost:1234`).
|
||||
3. In the project root or `backend/`, set:
|
||||
|
||||
```bash
|
||||
export AI_BASE_URL=http://localhost:1234/v1
|
||||
# Optional: set to the model name shown in LM Studio (e.g. the loaded model id). Default is "local-model".
|
||||
export AI_MODEL=your-model-name
|
||||
```
|
||||
|
||||
4. Start the backend (`cd backend && npm run dev`). The Agent node will use your local model.
|
||||
|
||||
**2. OpenAI**
|
||||
|
||||
Set `OPENAI_API_KEY` to your API key. The backend will use `gpt-4o-mini` unless you set `AI_MODEL`.
|
||||
|
||||
**Env summary (backend)**
|
||||
|
||||
| Variable | When to use | Description |
|
||||
|----------|--------------|-------------|
|
||||
| `AI_BASE_URL` | Local LLM (LM Studio, Ollama, etc.) | OpenAI-compatible base URL, e.g. `http://localhost:1234/v1`. |
|
||||
| `AI_MODEL` | Optional | Model id (for local: use the name shown in LM Studio; for OpenAI: e.g. `gpt-4o-mini`). |
|
||||
| `OPENAI_API_KEY` | OpenAI only | Your OpenAI API key. Not required when using `AI_BASE_URL` only. |
|
||||
|
||||
Reference in New Issue
Block a user