You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/_sources/LLMs.md.txt
+76-14Lines changed: 76 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,78 @@
1
1
## Large Language Models (LLMs) features
2
-
Our library offers a lightweight, unified interface for interacting with Large Language Models (LLMs), currently supporting two providers:
3
2
4
-
-**Gemini**, which provides free-tier access to powerful models—ideal for getting started with no cost
3
+
Our library offers two ways to interact with Large Language Models (LLMs):
5
4
6
-
-**Deepseek**, a cost-effective alternative via the OpenAI SDK (for users who don't have access to Gemini)
7
-
8
-
Instead of relying on heavier frameworks like LangChain, we built our own minimal wrapper to keep things simple: no extra dependencies beyond the provider SDKs, a clean and focused API (generate, translate, count_tokens, etc.), and fast, low-overhead execution.
5
+
1. **`psyflow-mcp` (Recommended)**: A lightweight server that provides a simple, high-level interface for common task-related operations like cloning, transforming, and localizing PsyFlow tasks. This is the easiest and recommended way to get started.
6
+
2. **Built-in `LLMClient` (Lower-Level)**: A minimal wrapper around LLM provider SDKs (Gemini, Deepseek) for more direct control. This is suitable for developers who need to customize the LLM interaction beyond the scope of `psyflow-mcp`.
9
7
10
8
**Why It Matters**: Large Language Models (LLMs) significantly enhance the usability and reproducibility of cognitive task development. They enable researchers to translate configuration files for localization, generate detailed documentation from code, and prototype or refine task variants using natural language—all while avoiding repetitive formatting work. By integrating LLMs directly into the PsyFlow ecosystem, we accelerate development, promote clearer communication, and expand accessibility for both developers and collaborators.
11
9
10
+
---
12
11
13
-
**How It Works**: The `LLMClient` class in PsyFlow provides a unified and lightweight interface for interacting with different LLM backends. It abstracts away provider-specific details and offers a simple API with methods like `generate()` for general-purpose generation, `translate_config()` for localizing YAML content, `task2doc()` for auto-generating documentation, `test()` for verifying connection and basic output, and `list_models()` to enumerate available models. This modular interface keeps your workflow consistent and efficient across providers like Gemini and DeepSeek.
12
+
### 1. `psyflow-mcp` (Recommended)
13
+
14
+
`psyflow-mcp` is a lightweight server that simplifies the use of LLMs for managing PsyFlow tasks. It exposes a set of tools that can be easily integrated with LLM agents like the Gemini CLI or Cursor.
15
+
16
+
**How It Works**
17
+
18
+
The `psyflow-mcp` server acts as a bridge between the user's natural language prompts and the underlying PsyFlow task management functions. The workflow is as follows:
19
+
20
+
.. image:: _static/LLM_flowchart.png
21
+
:alt: Illustration of the MCP Workflow
22
+
:align: center
23
+
:width: 85%
24
+
25
+
1. **User Prompt**: The user provides a prompt describing the desired action (e.g., "Create an SST task with sound-based stop signals" or "Give me a French version of the SST task").
26
+
2. **LLM**: The LLM interprets the prompt and selects the appropriate tool from `psyflow-mcp`.
27
+
3. **MCP (Model Context Protocol)**: The `psyflow-mcp` server executes the requested tool, which may involve:
28
+
* `build_task`: Cloning a task template and preparing it for modification.
29
+
* `localize`: Translating a task's configuration file.
30
+
* `download_task`: Fetching a task from the registry.
31
+
* `list_tasks`: Listing available tasks.
32
+
* `list_voices`: Listing available text-to-speech voices.
33
+
34
+
**Quick Start**
35
+
36
+
The easiest way to use `psyflow-mcp` is with `uvx`, which handles the installation and execution in a single command.
37
+
38
+
1. **Install `uvx`**:
39
+
```bash
40
+
pip install uvx
41
+
```
42
+
2. **Configure your LLM tool**:
43
+
Create a JSON configuration file for your LLM tool (e.g., Gemini CLI) with the following content:
44
+
```json
45
+
{
46
+
"name": "psyflow_mcp",
47
+
"type": "stdio",
48
+
"description": "Local FastMCP server for PsyFlow task operations. Uses uvx for automatic setup.",
49
+
"isActive": true,
50
+
"command": "uvx",
51
+
"args": [
52
+
"psyflow_mcp"
53
+
]
54
+
}
55
+
```
56
+
With this setup, your LLM agent can now use the `psyflow_mcp` tools. For more details, refer to the [`psyflow-mcp` documentation](https://github.com/TaskBeacon/psyflow-mcp).
57
+
58
+
---
14
59
60
+
### 2. Built-in `LLMClient` (Lower-Level)
15
61
16
-
In addition to using LLMs for documentation and localization, we are actively expanding support for full task generation from natural language. Our experimental `doc2task()` function allows users to convert a free-form task description into a structured, runnable TAPS-compliant task package. This includes generating key files like `main.py`, `run_trial.py`, and `config.yaml`, enabling rapid prototyping of cognitive tasks with minimal manual coding. As this feature evolves, it will form the foundation of an interactive assistant for building, customizing, and sharing reproducible paradigms directly from natural language input.
62
+
Our library also offers a lightweight, unified interface for interacting with Large Language Models (LLMs), currently supporting two providers:
17
63
64
+
- Gemini, which provides free-tier access to powerful models—ideal for getting started with no cost
65
+
66
+
- Deepseek, a cost-effective alternative via the OpenAI SDK (for users who don’t have access to Gemini)
67
+
68
+
Instead of relying on heavier frameworks like LangChain, we built our own minimal wrapper to keep things simple: no extra dependencies beyond the provider SDKs, a clean and focused API (generate, translate, count_tokens, etc.), and fast, low-overhead execution.
69
+
70
+
**How It Works**: The `LLMClient` class in PsyFlow provides a unified and lightweight interface for interacting with different LLM backends. It abstracts away provider-specific details and offers a simple API with methods like `generate()` for general-purpose generation, `translate_config()` for localizing YAML content, `task2doc()` for auto-generating documentation, `test()` for verifying connection and basic output, and `list_models()` to enumerate available models. This modular interface keeps your workflow consistent and efficient across providers like Gemini and DeepSeek.
71
+
72
+
#### 2.1. Verify the Native SDKs
73
+
74
+
##### 2.1.1. Google-GenAI (Gemini)
18
75
19
-
### 1. Verify the Native SDKs
20
-
#### 1.1 Google-GenAI (Gemini)
21
76
```python
22
77
from google import genai
23
78
@@ -40,7 +95,8 @@ print(response.text)
40
95
# I am doing well, thank you for asking! How are you today?
print("🔊 Deepseek wrapper echo:", deep.test(ping='who are you?', max_tokens=5))
90
146
```
91
147
148
+
---
92
149
93
150
### 3. LLMs-Powered Task Documentation
94
151
95
152
Our platform leverages Large Language Models (LLMs) to automatically generate human-readable documentation for cognitive tasks. This feature is designed to help developers, collaborators, and reviewers quickly understand the structure and parameters of a task—without having to dig through source code.
96
153
154
+
While this can be done manually with the `LLMClient`, it is more easily accomplished using the `build_task` tool in `psyflow-mcp`.
155
+
97
156
Our `LLMClient` includes a powerful `task2doc()` utility that lets you **automatically generate a detailed `README.md`** file for any PsyFlow-based cognitive task.
98
157
99
158
`task2doc()` analyzes four types of files:
@@ -128,10 +187,13 @@ Each generated `README.md` is organized into the following sections:
128
187
129
188
This automatic documentation feature reduces the burden on developers, promotes transparency in cognitive task design, and supports open and reproducible science.
130
189
190
+
---
131
191
132
192
### 4. LLMs-Powered Localization
133
193
134
-
The `LLMClient` also supports automatic translation of task configurations using the `translate_config()` method. This localization feature enables your task templates to be easily adapted into other languages while preserving placeholder tokens and formatting. By combining this with PsyFlow’s localization-ready structure, you can easily localize tasks for global deployment.
194
+
The `LLMClient` also supports automatic translation of task configurations using the `translate_config()` method. This localization feature enables your task templates to be easily adapted into other languages while preserving placeholder tokens and formatting. By combining this with PsyFlow’s localization-ready structure, you can easily localize tasks for global deployment.
195
+
196
+
This is more easily accomplished using the `localize` tool in `psyflow-mcp`.
135
197
136
198
`translate_config()` translate the following content in configuration:
@@ -30,4 +29,4 @@ We are continuously working to expand the number of curated tasks and enhance au
30
29
31
30
This project is licensed under the `MIT License <https://github.com/TaskBeacon/taskbeacon.github.io/blob/main/LICENSE>`_.
32
31
33
-
All components of this repository—including the core **PsyFlow** library, individual **tasks**, and their **variants**—are released under the MIT License, unless explicitly stated otherwise in a specific folder.
32
+
All components of this repository—including the core **psyFlow** library, individual **tasks**, and their **variants**—are released under the MIT License, unless explicitly stated otherwise in a specific folder.
0 commit comments