Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
5a3798f
init open router, create .env.example
bestian Aug 10, 2025
2747846
Update .env.example
bestian Aug 10, 2025
b871765
Update .gitignore
bestian Aug 11, 2025
8d90b2e
建立工程設計與分支的todo list初稿,建立一個方向,實作過程中還會再修。work on #3
bestian Aug 11, 2025
1efcb4a
設定工程基本方向
bestian Aug 11, 2025
cabb3fb
Update 工程設計.md
bestian Aug 11, 2025
46db0b7
建立鷹架資料夾和hello_World, work on #2
bestian Aug 11, 2025
80aca62
use .ts
bestian Aug 11, 2025
8c38046
Update package-lock.json
bestian Aug 11, 2025
76a8cdf
以測試用的小程式,先確保 openai-sdk可以被串接上, close #2
bestian Aug 11, 2025
cf1c5bb
讓simple_ai_prompt.ts支持google/gemini-2.5-pro的不同格式回應, work on #5
bestian Aug 11, 2025
7908fcc
測試幾個主要模型的文字輸出格式, work on #5
bestian Aug 11, 2025
ae7af86
建立文字轉換函式, work on #6
bestian Aug 11, 2025
e0a5894
實驗結構化輸出, work on #7
bestian Aug 12, 2025
bd09fe4
Update branch_todo.md
bestian Aug 12, 2025
2272001
複製核心類型定義,實作openrouter核心模型組件, work on #8
bestian Aug 12, 2025
5d334f8
將 README中的範例程式建立鷹架版,以openrouter跑動, work on #9
bestian Aug 12, 2025
18a6c2c
Update test.md
bestian Aug 12, 2025
20b72a0
預設使用gpt-oss-120b, work on #10
bestian Aug 12, 2025
0b15d08
建立example/tutorial.ts和相關說明在README.md
bestian Aug 12, 2025
ff35b51
設定規格化輸出為嚴格模式
bestian Aug 12, 2025
75ad083
讓.env位置移到根目錄
bestian Aug 13, 2025
4ac42bc
複刻runner_utils和第一個runner.ts,work on #1 work on #
bestian Aug 13, 2025
4f073fe
查找每個讀取.env的檔,讓它們優先讀取系統環境變數,讀不到才讀.env檔, work on #12
bestian Aug 14, 2025
3586e15
Update .gitignore
bestian Aug 14, 2025
708bcf2
set "stream: false"
bestian Aug 15, 2025
efaa9b3
init multilang support, before test, work on #14
bestian Aug 15, 2025
3fcc94b
debug and work on #14
bestian Aug 15, 2025
e47b5cb
debug 參數傳導問題 and add logs and close #15
bestian Aug 15, 2025
d9c4cb8
初始化打包
bestian Aug 17, 2025
6742297
debug 語言設定參數傳導,和將模型串流限制為非串流。
bestian Aug 18, 2025
d9d0793
remove dist-worker
bestian Aug 18, 2025
bc79b2a
增加防護措施
bestian Aug 18, 2025
61a5514
讓程式預設並可以處理stream
bestian Aug 18, 2025
40889cd
Update openrouter_model.ts
bestian Aug 18, 2025
fe19733
Merge remote-tracking branch 'upstream/main' into new-feature-multilang
bestian Aug 19, 2025
102ca71
debug streamed response processing
bestian Aug 19, 2025
2cccae4
debug JSON fix logic
bestian Aug 19, 2025
d214a52
讓回應處理更彈性以適應open router的回應格式
bestian Aug 19, 2025
de6b65e
修改categorization和model的處理邏輯以適應streaming回應
bestian Aug 19, 2025
5de4fd8
Create fix_csv_columns_simple.py
bestian Aug 19, 2025
c94824f
創建並修訂csv修理轉換器,給polis.tw和pol.is的檔案用
bestian Aug 20, 2025
1acdb14
準備好以npm pack的方式打包讓後端專案測試
bestian Aug 21, 2025
64db791
為了打包給 Cloudflare Workers 安裝,在環境中不使用 TypeBox 編譯器
bestian Aug 21, 2025
2dbc997
調整環境變數的讀取方式以適配CF_worker
bestian Aug 21, 2025
d574378
統計時增加彈性
bestian Aug 21, 2025
f4c6c5e
Update openrouter_model.ts
bestian Aug 21, 2025
a98cb8b
Update env_loader.ts
bestian Aug 21, 2025
0c5f47f
add max_tokens to prevent truncation error
bestian Aug 21, 2025
46db2b5
add maxRetries from 3 to 5
bestian Aug 21, 2025
177aee2
close #16
bestian Aug 22, 2025
e2273c9
close #17
bestian Aug 22, 2025
42d7292
reduce logs
bestian Aug 22, 2025
420b615
解決子主題學習驗證邏輯過於嚴格的問題
bestian Aug 22, 2025
97d8ccd
修正驗證邏輯,before realdata test
bestian Aug 22, 2025
cba2b51
加上西班牙文、日文和簡体中文支援,並加重語言指定語氣。
bestian Aug 23, 2025
5968475
test use system prompt. work on #15
bestian Aug 23, 2025
3f82cca
把system指令和user指令分開,work on #15 #24
bestian Aug 24, 2025
407fac4
將容易出錯的區塊提示語本身換成多語言, work on #15
bestian Aug 24, 2025
d5eb91e
修復 executeConcurrently, work on #30
bestian Aug 24, 2025
1d0ce12
Merge branch 'new-feature-open-router' into new-feature-multilang
bestian Aug 24, 2025
57d39b6
修改summarization和overview使之能生成多語言內容,work on #28
bestian Aug 24, 2025
999d92f
LearnTopic階段的prompt改為多語言
bestian Aug 24, 2025
86e4846
JSON修復邏輯優化
bestian Aug 24, 2025
0812246
移除檢測到所有主題都是籠統名稱 (), 觸發 retry的邏輯
bestian Aug 24, 2025
76c1bd1
Update categorization.ts
bestian Aug 24, 2025
3a6b0e6
Revert "Update categorization.ts"
bestian Aug 24, 2025
4f7cb4b
Revert "移除檢測到所有主題都是籠統名稱 (), 觸發 retry的邏輯"
bestian Aug 24, 2025
4f9e85c
Revert "JSON修復邏輯優化"
bestian Aug 24, 2025
a5450a7
Revert "LearnTopic階段的prompt改為多語言"
bestian Aug 24, 2025
6dff3ac
Learn Topic階段, 意見相違分析的prompt改為多語言
bestian Aug 24, 2025
b0b0c29
Update README.md
bestian Aug 24, 2025
665b508
處理沒有學到新主題時的問題
bestian Aug 24, 2025
bf4db41
將取得共同意見的提示語也轉成多語言,before realdata test
bestian Aug 24, 2025
0f95db4
修復提示語中缺少的markdown格式提示
bestian Aug 25, 2025
7eca4f0
修復錯誤的多語言提示語
bestian Aug 25, 2025
f018228
把getSubtopicSummary的提示語抽成多語言
bestian Aug 25, 2025
efde9a0
新增從markdown中提取JSON的試驗邏輯,以增加LLM呼叫準確率,減少retry次數。
bestian Aug 25, 2025
7afff11
對topic是否存在的校驗,使用更寬鬆的檢查,處理可能的格式變化
bestian Aug 25, 2025
b6d7b8c
XX statements 改成 多語言 模版
bestian Aug 25, 2025
552cb52
"moderately low alignment"部份改成多語言
bestian Aug 25, 2025
9b4dbe2
對齊日文提示語
bestian Aug 25, 2025
031fed5
補上缺少的函式和多語言文字
bestian Aug 25, 2025
75cc322
將Summery結果的Other轉成多語言,before test
bestian Aug 25, 2025
6ae1481
將報告最後的靜態文字statements改成多語言
bestian Aug 25, 2025
e214eba
優化open router model的JSON修復邏輯
bestian Aug 25, 2025
d6d00ce
debug優化JSON修復邏輯
bestian Aug 25, 2025
aadc45e
修改Learn Subtopic 相關的提示語,要LLM不可以傳回空陣列或空白的內容
bestian Aug 25, 2025
05284f5
Revert "debug優化JSON修復邏輯"
bestian Aug 25, 2025
bed99b2
Revert "優化open router model的JSON修復邏輯"
bestian Aug 25, 2025
a19d2fa
modify test files and types.ts to make sure all tests in /library can…
bestian Aug 27, 2025
33fd7ce
rename csv_fixer_for_polis_tw
bestian Jan 2, 2026
ade2c0d
Merge README, work on #41
bestian Jan 2, 2026
c61a5e3
remove design and scaffold
bestian Jan 2, 2026
ad5abe1
remove design notes
bestian Jan 2, 2026
a80620e
Update model.ts
bestian Jan 2, 2026
8738a15
Update categorization.ts
bestian Jan 2, 2026
b565233
Update types.ts
bestian Jan 2, 2026
ce05680
Merge remote-tracking branch 'upstream/main' into new-feature-open-ro…
bestian Jan 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# OpenRouter API Configuration
OPENROUTER_API_KEY=your_openrouter_api_key_here
OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
OPENROUTER_MODEL=openai/gpt-oss-120b

# Optional: Custom headers for OpenRouter
OPENROUTER_X_TITLE=Sensemaking Tools
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ private_*
GEMINI.md
todo.md
*.env
/files
.vscode
*.pkl
*.tgz
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,48 @@ There is also a simple CLI set up for testing. There are three tools:
* [./library/runner-cli/categorization\_runner.ts](https://github.com/Jigsaw-Code/sensemaking-tools/blob/main/library/runner-cli/categorization_runner.ts): takes in a CSV representing a conversation and outputs another CSV with the comments categorized into topics and subtopics.
* [./library/runner-cli/advanced\_runner.ts](https://github.com/Jigsaw-Code/sensemaking-tools/blob/main/library/runner-cli/advanced_runner.ts): takes in a CSV representing a conversation and outputs three files for an advanced user more interested in the statistics. The first is a JSON of topics, their sizes, and their subtopics. The second is a JSON with all of the comments and their alignment scores and values. Third is the summary object as a JSON which can be used for additional processing.

**CSV Format Conversion:**

If your CSV file is exported from pol.is or polis.tw, you need to convert it to the required format before using the CLI tools.

* For CSV files from **pol.is**, use [./polis_csv_fixer/csv_converter.py](https://github.com/bestian/sensemaking-tools/blob/new-feature-open-router/polis_csv_fixer/csv_converter.py):

```bash
python polis_csv_fixer/csv_converter.py input.csv output.csv
```

* For CSV files from **polis.tw**, use [./polis_csv_fixer/csv_converter_for_polis_tw.py](https://github.com/bestian/sensemaking-tools/blob/new-feature-open-router/polis_csv_fixer/csv_converter_for_polis_tw.py):

```bash
python polis_csv_fixer/csv_converter_for_polis_tw.py input.csv [output.csv]
```

**OpenRouter CLI Tools:**

* [./library/runner-cli/runner\_openrouter.ts](https://github.com/bestian/sensemaking-tools/blob/new-feature-open-router/library/runner-cli/runner_openrouter.ts): Same usage as `runner.ts`, but uses OpenRouter models. Supports multi-language output via the `--output_lang` parameter.

```bash
npx ts-node ./library/runner-cli/runner_openrouter.ts \
--outputBasename out \
--inputFile "./files/comments.csv" \
--additionalContext "Description of the conversation" \
--output_lang zh-TW
```

The `--output_lang` parameter supports: `en` (default), `zh-TW`, `zh-CN`, `fr`, `es`, `ja`.

* [./library/runner-cli/categorization\_runner\_openrouter.ts](https://github.com/bestian/sensemaking-tools/blob/new-feature-open-router/library/runner-cli/categorization_runner_openrouter.ts): Uses OpenRouter models for topic categorization. Supports custom model selection and topic depth configuration.

```bash
npx ts-node ./library/runner-cli/categorization_runner_openrouter.ts \
--inputFile "./files/comments.csv" \
--outputFile "./files/categorized_comments.csv" \
--topicDepth 2 \
--additionalContext "Description of the conversation"
```

Set the `OPENROUTER_API_KEY` environment variable before running these tools. The model can be specified via `OPENROUTER_MODEL` environment variable.

These tools process CSV input files. These must contain the columns `comment_text` and `comment-id`. For deliberations without group information, vote counts should be set in columns titled `agrees`, `disagrees` and `passes`. If you do not have vote information, these can be set to 0. For deliberations with group breakdowns, you can set the columns `{group_name}-agree-count`, `{group_name}-disagree-count`, `{group_name}-pass-count`.

## **Generating a Report \- Get a webpage presentation of the report**
Expand Down
1 change: 1 addition & 0 deletions library/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/.eslintcache
/.venv
.DS_Store
/dist
120 changes: 120 additions & 0 deletions library/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Development files
*.test.ts
*.spec.ts
jest.config.ts
jest.setup.ts
eslint.config.mjs
.prettierrc
.husky/
lint-staged.config.js

# Build artifacts
dist/
build/
*.tsbuildinfo

# Documentation
docs/
*.md
!README.md

# Examples and templates
examples/
templates/
scaffold/
scaffold-*/
**/scaffold/
**/scaffold-*/

# Python files
requirements.txt
*.py
__pycache__/
**/*.py
**/__pycache__/

# Binaries
bin/
runner-cli/
**/bin/
**/runner-cli/

# Evaluation files
evals/
**/evals/

# Development dependencies
node_modules/
**/node_modules/

# IDE and OS files
.vscode/
.idea/
.DS_Store
*.swp
*.swo
**/.vscode/
**/.idea/
**/.DS_Store

# Git
.git/
.gitignore
**/.git/
**/.gitignore

# Environment files
.env
.env.local
.env.*.local
**/.env*
**/.env.*.local

# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
**/*.log

# Coverage
coverage/
.nyc_output/
**/coverage/
**/.nyc_output/

# Temporary files
tmp/
temp/
**/tmp/
**/temp/

# Source files (only include dist)
src/
**/src/
!dist/
!dist/**/*

# Test files
test/
tests/
**/test/
**/tests/

# Configuration files
tsconfig*.json
eslint*
prettier*
jest*
babel*
webpack*
rollup*
vite*
**/tsconfig*.json
**/eslint*
**/prettier*
**/jest*
**/babel*
**/webpack*
**/rollup*
**/vite*
Loading