-
Notifications
You must be signed in to change notification settings - Fork 0
Wire CLIProxy-backed source-grounded generation #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
072964c
eec053b
d4808b1
0518949
92b2b54
3051be3
34bdad0
e2dd003
8960048
f29fc75
92f25b8
dc0106d
c7eee52
21399b5
ee4bf96
4b162a8
eccacc6
65f7160
6b39c5f
c307268
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,31 @@ | ||
| # OpenMath agent — environment variables. | ||
| # 모두 optional. 미설정 시 src/config/env.ts 기본값 또는 src/index.ts fallback 사용. | ||
|
|
||
| # --- 서버 --- | ||
| # 다른 프로세스(예: Mantis 등)가 3000 점유 시 PORT 변경 + 동시에 | ||
| # packages/web/.env.local 의 NEXT_PUBLIC_AGENT_URL 도 같이 갱신해야 web↔agent 연결됨. | ||
| PORT=3000 | ||
| MATH_ENGINE_URL=http://localhost:8000 | ||
| CORPUS_JSONL=/Users/tw81512/dev/AI_HUB_data/rag_problem_generation_dataset/openmath_rag_records.jsonl | ||
|
|
||
| # LLM Provider: "openai" or "cliproxy" | ||
| LLM_PROVIDER=openai | ||
| # --- RAG --- | ||
| # 미설정 시 ./data/corpus/math-sample-unified-v1.jsonl (repo 동봉) 사용. | ||
| # 별도 corpus 경로 쓰려면 절대경로 또는 packages/agent/ 기준 상대경로로 지정. | ||
| # CORPUS_JSONL=./data/corpus/math-sample-unified-v1.jsonl | ||
|
|
||
| # OpenAI Direct | ||
| OPENAI_API_KEY=your-api-key-here | ||
| OPENAI_MODEL=gpt-4o | ||
| # --- LLM 환경 (필수 — 미설정 시 seed fallback 으로 생성/검증 100% 실패) --- | ||
| # LLM_PROVIDER: "openai" | "openai-compatible" | "anthropic-via-compatible" | "cliproxy" | ||
| LLM_PROVIDER=cliproxy | ||
|
|
||
| # CLIProxyAPI (alternative) | ||
| CLIPROXY_BASE_URL=http://localhost:8080/v1 | ||
| # (옵션 1) CLIProxyAPI 로컬 라우터 — Claude/GPT/Gemini 통합 (https://github.com/router-for-me/CLIProxyAPI) | ||
| CLIPROXY_BASE_URL=http://localhost:8317/v1 | ||
| CLIPROXY_API_KEY=dummy-key | ||
| CLIPROXY_MODEL=gpt-4o | ||
|
|
||
| # (옵션 2) OpenAI 직접 — 비용/속도 안정. LLM_PROVIDER=openai 와 함께. | ||
| # OPENAI_API_KEY=sk-... | ||
| # OPENAI_MODEL=gpt-4o | ||
|
|
||
| # Canonical aliases — 위 3가지 옵션 중 어느 것도 매핑되지 않으면 이 3개로 직접 지정 가능 | ||
| LLM_BASE_URL=http://localhost:8317/v1 | ||
| LLM_API_KEY=dummy-key | ||
| LLM_MODEL=gpt-4o | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| code: 9수01-05 | ||
| title: 제곱근의 뜻과 실수의 분류를 이해한다 | ||
| school_level: middle | ||
| grade: 3 | ||
| techniques: | ||
| required_at_least_one_of: | ||
| - square_root_definition | ||
| - real_number_classification | ||
| forbidden: | ||
| - calculus | ||
| evaluation_dimensions: | ||
| - id: A | ||
| description: 제곱근의 뜻을 식으로 해석한다 | ||
| must_preserve: true | ||
| - id: B | ||
| description: 양수의 두 제곱근을 모두 구한다 | ||
| must_preserve: true | ||
| - id: C | ||
| description: 근호를 사용해 정확한 값을 표현한다 | ||
| must_preserve: true | ||
| - id: D | ||
| description: 실수 범위에서 해를 판단한다 | ||
| must_preserve: true | ||
| difficulty_range: | ||
| - easy | ||
| - medium | ||
| problem_types_supported: | ||
| - short_answer | ||
| - objective | ||
| structural_transforms: | ||
| - kind: coefficient_swap | ||
| range: [2, 20] | ||
| exclude_zero: true | ||
| - kind: variable_rename | ||
| allowed: [x, y] | ||
| conceptual_transforms: | ||
| - kind: inverse_question | ||
| hint: 제곱하면 같은 수가 되는 두 실수를 묻는다 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| code: 9수02-03 | ||
| title: 일차방정식을 풀 수 있다 | ||
| school_level: middle | ||
| grade: 1 | ||
| techniques: | ||
| required_at_least_one_of: | ||
| - inverse_operation | ||
| - equation_simplification | ||
| forbidden: | ||
| - quadratic_formula | ||
| evaluation_dimensions: | ||
| - id: A | ||
| description: 등식의 성질을 이용해 미지수를 고립시킨다 | ||
| must_preserve: true | ||
| - id: B | ||
| description: 구한 값을 원래 식에 대입해 확인한다 | ||
| must_preserve: true | ||
| difficulty_range: | ||
| - easy | ||
| - medium | ||
| problem_types_supported: | ||
| - short_answer | ||
| - objective | ||
| structural_transforms: | ||
| - kind: coefficient_swap | ||
| range: [-20, 20] | ||
| exclude_zero: true | ||
| conceptual_transforms: | ||
| - kind: rephrase_as_word_problem | ||
| context: | ||
| - 수량 관계 | ||
| - 비율 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| code: 9수02-09 | ||
| title: 이차방정식을 풀 수 있다 | ||
| school_level: middle | ||
| grade: 3 | ||
| techniques: | ||
| required_at_least_one_of: | ||
| - factorization | ||
| - root_relation | ||
| forbidden: | ||
| - calculus | ||
| evaluation_dimensions: | ||
| - id: A | ||
| description: 이차식을 인수분해하여 해를 구한다 | ||
| must_preserve: true | ||
| - id: B | ||
| description: 해를 원래 식에 대입해 검산한다 | ||
| must_preserve: true | ||
| difficulty_range: | ||
| - easy | ||
| - medium | ||
| problem_types_supported: | ||
| - short_answer | ||
| - objective | ||
| structural_transforms: | ||
| - kind: coefficient_swap | ||
| range: [-12, 12] | ||
| exclude_zero: true | ||
| - kind: sign_flip | ||
| conceptual_transforms: | ||
| - kind: present_via_root_relations | ||
| hint: 두 근의 합과 곱 조건으로 다시 제시 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| {"id":{"problem_id":"seed-9수02-09-001","source_dataset":"111","split":"train","source_label_type":"seed"},"curriculum":{"school_level":"middle","grade":3,"semester":1,"topic_code":"9수02-09","topic_name":"이차방정식","achievement_standard":"9수02-09","achievement_confidence":1.0},"problem":{"question_text":"x**2 - 5*x + 6 = 0","answer_text":"2, 3","explanation_text":"(x - 2)(x - 3) = 0 이므로 x = 2 또는 x = 3","choice_blocks":null,"problem_type":"short_answer","difficulty":"easy"}} | ||
| {"id":{"problem_id":"seed-9수02-09-002","source_dataset":"111","split":"train","source_label_type":"seed"},"curriculum":{"school_level":"middle","grade":3,"semester":1,"topic_code":"9수02-09","topic_name":"이차방정식","achievement_standard":"9수02-09","achievement_confidence":1.0},"problem":{"question_text":"x**2 + 4*x - 12 = 0","answer_text":"2, -6","explanation_text":"(x - 2)(x + 6) = 0 이므로 x = 2 또는 x = -6","choice_blocks":null,"problem_type":"short_answer","difficulty":"medium"}} | ||
| {"id":{"problem_id":"seed-9수02-09-003","source_dataset":"111","split":"train","source_label_type":"seed"},"curriculum":{"school_level":"middle","grade":3,"semester":1,"topic_code":"9수02-09","topic_name":"이차방정식","achievement_standard":"9수02-09","achievement_confidence":1.0},"problem":{"question_text":"x**2 - 4*x + 4 = 0","answer_text":"2","explanation_text":"(x - 2)**2 = 0 이므로 x = 2","choice_blocks":null,"problem_type":"short_answer","difficulty":"easy"}} | ||
| {"id":{"problem_id":"seed-9수02-03-001","source_dataset":"111","split":"train","source_label_type":"seed"},"curriculum":{"school_level":"middle","grade":1,"semester":1,"topic_code":"9수02-03","topic_name":"일차방정식","achievement_standard":"9수02-03","achievement_confidence":1.0},"problem":{"question_text":"3*x + 5 = 14","answer_text":"3","explanation_text":"3x = 9 이므로 x = 3","choice_blocks":null,"problem_type":"short_answer","difficulty":"easy"}} | ||
| {"id":{"problem_id":"seed-9수02-03-002","source_dataset":"111","split":"train","source_label_type":"seed"},"curriculum":{"school_level":"middle","grade":1,"semester":1,"topic_code":"9수02-03","topic_name":"일차방정식","achievement_standard":"9수02-03","achievement_confidence":1.0},"problem":{"question_text":"4*(x - 1) = 8","answer_text":"3","explanation_text":"4x - 4 = 8, 4x = 12 이므로 x = 3","choice_blocks":null,"problem_type":"short_answer","difficulty":"easy"}} | ||
| {"id":{"problem_id":"seed-9수02-07-001","source_dataset":"111","split":"train","source_label_type":"seed"},"curriculum":{"school_level":"middle","grade":2,"semester":1,"topic_code":"9수02-07","topic_name":"연립일차방정식","achievement_standard":"9수02-07","achievement_confidence":1.0},"problem":{"question_text":"x + y = 5; x - y = 1","answer_text":"x = 3, y = 2","explanation_text":"두 식을 더하면 2x = 6, x = 3이고 y = 2","choice_blocks":null,"problem_type":"short_answer","difficulty":"medium"}} | ||
| {"id":{"problem_id":"seed-9수01-05-001","source_dataset":"111","split":"train","source_label_type":"seed"},"curriculum":{"school_level":"middle","grade":3,"semester":1,"topic_code":"9수01-05","topic_name":"제곱근과 실수","achievement_standard":"9수01-05","achievement_confidence":1.0},"problem":{"question_text":"x**2 - 5 = 0","answer_text":"sqrt(5), -sqrt(5)","explanation_text":"x**2 = 5 이므로 x = sqrt(5) 또는 x = -sqrt(5)","choice_blocks":null,"problem_type":"short_answer","difficulty":"medium"}} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| id: problem-generator | ||
| version: 0.1.0 | ||
| model: gpt-4o | ||
| temperature: 0.7 | ||
| temperature: 0.35 | ||
| max_tokens: 2000 | ||
| schema: GeneratedProblemSchema | ||
| variables: | ||
|
|
@@ -23,6 +23,15 @@ updated: 2026-05-18 | |
|
|
||
| `{{request.mode}}` — `structural` 이면 같은 풀이법, 다른 숫자/표현. `conceptual` 이면 같은 학습 목표·평가 차원, 다른 풀이 경로. | ||
|
|
||
| # Selected Source Problem | ||
|
|
||
| 이 문제를 반드시 변형의 기준으로 삼아라: `{{request.source_problem_text}}` | ||
|
|
||
| - 원문을 그대로 복사하지 말 것. | ||
| - structural: 식의 골격과 풀이 단계는 유지하되 계수·상수·근을 바꾼다. | ||
| - conceptual: 평가 차원은 보존하되 식의 형태를 바꾼다. 예: `x**2 - a = 0` 기준이면 `(x - h)**2 - a = 0` 또는 전개형 `x**2 + b*x + c = 0`처럼 다른 표현 경로를 사용한다. | ||
| - `{{request.difficulty}}` 난이도에 맞춘다. medium 이상에서는 `x**2 - a = 0`처럼 너무 직접적인 기본형만 내지 말고 한 단계 변형된 식을 낸다. | ||
|
|
||
| # Intent | ||
|
|
||
| 학습 목표: {{intent.objective_description}} (`{{intent.objective_code}}`) | ||
|
|
@@ -47,10 +56,14 @@ updated: 2026-05-18 | |
|
|
||
| # Output | ||
|
|
||
| `GeneratedProblem` 스키마(`docs/specs/domain.md` §2.3)에 맞춰 JSON으로 응답. | ||
| - `question_text`, `expected_answer`는 LaTeX (`\frac` 통일, `\dfrac` 금지) | ||
| - `proposed_solution_trace`에 풀이 단계 명시 | ||
| - `inferred_intent.objective_code == intent.objective_code` (I-G1) | ||
| JSON으로만 응답. | ||
| - `question_text`는 KaTeX가 바로 렌더링할 수 있는 LaTeX `x` 방정식 문자열이어야 한다. `**`, `*`를 쓰지 말고 지수는 `x^{2}`, 곱셈은 `5x`, 제곱근은 `\\sqrt{7}`처럼 쓴다. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P0: Prompt instructs LLM to output Prompt for AI agents |
||
| - `expected_answer`도 LaTeX로 쓴다. 예: `2, 5`, `\\sqrt{7}, -\\sqrt{7}`. | ||
| - 예시 출력: `{ "question_text": "x^{2} - 7x + 10 = 0", "expected_answer": "2, 5", "proposed_solution_trace": "인수분해하면 (x - 2)(x - 5) = 0이므로 x = 2 또는 x = 5이다." }` | ||
| - 서버가 SymPy로 다시 계산해 최종 정답을 검증한다. | ||
| - `proposed_solution_trace`에 풀이 단계와 출제 의도를 한국어로 명시한다. | ||
| - 풀이 가능하고 답이 실수인 중학교 수준 방정식만 생성한다. | ||
| - 결과 문제는 source problem과 달라야 하며, structural/conceptual 모드 차이가 풀이 설명에 드러나야 한다. | ||
|
|
||
| # TODO | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: Canonical alias priority is described backwards. The comment says to use
LLM_BASE_URL/LLM_API_KEY/LLM_MODEL"when none of the above 3 options map" (fallback), but insrc/index.tsthey are the highest-priority values checked first via??. If a user follows 옵션 2 (OpenAI direct) by uncommentingOPENAI_API_KEY/OPENAI_MODELand switchingLLM_PROVIDER=openaiwithout also disabling the canonical aliases,LLM_BASE_URL=http://localhost:8317/v1andLLM_API_KEY=dummy-keywould silently override the OpenAI settings — routing to CLIProxy with dummy key instead of OpenAI.Prompt for AI agents