Skip to content

Commit 7884d73

Browse files
committed
update LLM
1 parent 6ce8079 commit 7884d73

19 files changed

+245
-58
lines changed

docs/.doctrees/LLMs.doctree

12.2 KB
Binary file not shown.

docs/.doctrees/environment.pickle

18.1 KB
Binary file not shown.

docs/.doctrees/index.doctree

-276 Bytes
Binary file not shown.

docs/.doctrees/text2voice.doctree

-20 Bytes
Binary file not shown.

docs/LLMs.html

Lines changed: 82 additions & 16 deletions
Large diffs are not rendered by default.

docs/_images/flowchart.png

137 KB
Loading

docs/_sources/LLMs.md.txt

Lines changed: 76 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,78 @@
11
## Large Language Models (LLMs) features
2-
Our library offers a lightweight, unified interface for interacting with Large Language Models (LLMs), currently supporting two providers:
32

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):
54

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`.
97

108
**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.
119

10+
---
1211

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+
---
1459

60+
### 2. Built-in `LLMClient` (Lower-Level)
1561

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:
1763

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)
1875

19-
### 1. Verify the Native SDKs
20-
#### 1.1 Google-GenAI (Gemini)
2176
```python
2277
from google import genai
2378

@@ -40,7 +95,8 @@ print(response.text)
4095
# I am doing well, thank you for asking! How are you today?
4196
```
4297

43-
#### 1.2 OpenAI / Deepseek
98+
##### 2.1.2. OpenAI / Deepseek
99+
44100
```python
45101
from openai import OpenAI
46102
client = OpenAI(api_key="…your key…", base_url="https://api.deepseek.com")
@@ -63,12 +119,12 @@ response = client.chat.completions.create(
63119
)
64120
print(response.choices[0].message.content)
65121
# Hello! How can I assist you today? 😊
66-
67122
```
68123

69-
### 2. Use Psyflow LLMClient Wrapper
124+
#### 2.2. Use Psyflow LLMClient Wrapper
125+
70126
```python
71-
from psyflow import LLMClient, LLMUtil
127+
from psyflow import LLMClient
72128
import os
73129

74130
# 2a) Instantiate
@@ -89,11 +145,14 @@ print("🔊 Gemini wrapper echo:", gemini.test(ping='who are you?', max_tokens=5
89145
print("🔊 Deepseek wrapper echo:", deep.test(ping='who are you?', max_tokens=5))
90146
```
91147

148+
---
92149

93150
### 3. LLMs-Powered Task Documentation
94151

95152
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.
96153

154+
While this can be done manually with the `LLMClient`, it is more easily accomplished using the `build_task` tool in `psyflow-mcp`.
155+
97156
Our `LLMClient` includes a powerful `task2doc()` utility that lets you **automatically generate a detailed `README.md`** file for any PsyFlow-based cognitive task.
98157

99158
`task2doc()` analyzes four types of files:
@@ -128,10 +187,13 @@ Each generated `README.md` is organized into the following sections:
128187

129188
This automatic documentation feature reduces the burden on developers, promotes transparency in cognitive task design, and supports open and reproducible science.
130189

190+
---
131191

132192
### 4. LLMs-Powered Localization
133193

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`.
135197

136198
`translate_config()` translate the following content in configuration:
137199
- `subinfo_mapping` labels (e.g., `"age"`, `"gender"`)

docs/_sources/index.rst.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ TaskBeacon also provides features that enhance reusability, localization, and co
1818

1919
- :doc:`Text-to-voice </text2voice>` – Automatically generate voice instructions from translated text for consistent and accessible delivery
2020
- :doc:`Localization </localization>` – Enables cross-cultural localization by separating text components from task logic
21-
- :doc:`LLMs </LLMs>` – Leverage Large Language Models to assist with task documentation and localization
22-
- :doc:`Track variants </versioning>` – Manage task variants using GitHub branches
21+
- :doc:`Track variants </versioning>` – Manage task variants using GitHub branches
22+
- :doc:`LLMs </LLMs>` – Leverage Large Language Models to assist with task development, documentation and localization
2323

24-
We are continuously working to expand the number of curated tasks and enhance automation in LLM-powered task generation.
2524

2625
**Join Us**: `TaskBeacon Organization <https://github.com/TaskBeacon>`_
2726

@@ -30,4 +29,4 @@ We are continuously working to expand the number of curated tasks and enhance au
3029

3130
This project is licensed under the `MIT License <https://github.com/TaskBeacon/taskbeacon.github.io/blob/main/LICENSE>`_.
3231

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.

docs/_sources/text2voice.md.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The result will be registered as `welcome_voice` and available like any other st
4747
Use the built-in helper to explore available voices:
4848

4949
```python
50-
from psyflow.tts_utils import list_supported_voices
50+
from psyflow import list_supported_voices
5151

5252
# Print all voices
5353
list_supported_voices(human_readable=True)

docs/_static/LLM_flowchart.png

67.8 KB
Loading

0 commit comments

Comments
 (0)