Compare commits
3
Commits
34455c4603
...
8f6eb4ebab
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f6eb4ebab | ||
|
|
8cab4fd45b | ||
|
|
896561c909 |
No files matched your search
Executable
+77
@@ -0,0 +1,77 @@
|
||||
#!/bin/bash
|
||||
# 절전에서 깨우는 장치를 유선랜(eno1)만 남기고 끈다. 루트로 실행: sudo bash wake-lan-only.sh [install]
|
||||
# 전원 버튼은 ACPI 고정 버튼이라 여기서 끌 수 없고 그대로 깨운다.
|
||||
set -e
|
||||
[ "$(id -u)" = 0 ] || { echo "루트로 실행하세요 (sudo)"; exit 1; }
|
||||
|
||||
# 유선랜이 달린 PCI 장치와 그 상위 브리지/루트포트를 /proc/acpi/wakeup 이름으로 찾는다.
|
||||
# (보드마다 이름이 달라 — 옛 클로서버는 LAN0, z840은 랜카드가 RP01 아래라 RP01)
|
||||
keep_devices() {
|
||||
for n in /sys/class/net/*; do
|
||||
[ -e "$n/device" ] || continue
|
||||
[ "$(cat "$n/device/power/wakeup" 2>/dev/null)" = enabled ] || continue
|
||||
p=$(readlink -f "$n/device")
|
||||
while [ "$p" != / ] && [ "$p" != /sys/devices ]; do
|
||||
b=$(basename "$p")
|
||||
awk -v b="$b" '$4 == "pci:" b {print $1}' /proc/acpi/wakeup
|
||||
p=$(dirname "$p")
|
||||
done
|
||||
done | sort -u
|
||||
echo LAN0 # 옛 보드 호환
|
||||
}
|
||||
|
||||
# 깨우기에 쓸 랜 포트(공백 구분). 2026-10-30 실측: z840의 I210(enp6s0)은 절전(S3) 중 매직패킷으로 안 깨고(2회 실패),
|
||||
# 온보드 e1000e(eno1, MAC 50:65:f3:2c:41:62)는 한 번에 깨어났다("PHY Wakeup cause - Magic Packet"). 그래서 eno1을 쓴다.
|
||||
# 부팅 직후엔 NIC가 깨우기를 끈 채라 keep_devices()가 eno1을 놓치므로, 여기서 먼저 켠다. 케이블을 뺐다 꽂으면 드라이버가
|
||||
# 설정을 되돌리기도 해서(10-30 관찰) 절전 직전 훅(system-sleep)이 이 함수를 매번 다시 돌린다.
|
||||
WOL_NICS="${WOL_NICS:-eno1}"
|
||||
arm_wol_nics() {
|
||||
for nic in $WOL_NICS; do
|
||||
[ -e "/sys/class/net/$nic/device" ] || continue
|
||||
ethtool -s "$nic" wol g 2>/dev/null || true
|
||||
echo enabled > "/sys/class/net/$nic/device/power/wakeup" 2>/dev/null || true
|
||||
done
|
||||
}
|
||||
|
||||
apply() {
|
||||
arm_wol_nics
|
||||
keep=$(keep_devices)
|
||||
# /proc/acpi/wakeup은 쓰면 토글이므로 enabled인 것만 쓴다(끄기), disabled인 보존 대상만 쓴다(켜기)
|
||||
awk '$3 ~ /enabled/ {print $1}' /proc/acpi/wakeup | while read -r d; do
|
||||
echo "$keep" | grep -qx "$d" || echo "$d" > /proc/acpi/wakeup
|
||||
done
|
||||
# set -e 아래에서 반복문의 마지막 항목이 보존 대상이 아니면 grep이 1을 돌려 스크립트가 통째로 끝나므로(10-30 설치 실패),
|
||||
# 조건을 if로 쓰고 반복문 끝에 || true를 둔다.
|
||||
awk '$3 ~ /disabled/ {print $1}' /proc/acpi/wakeup | while read -r d; do
|
||||
if [ "$d" != LAN0 ] && echo "$keep" | grep -qx "$d"; then echo "$d" > /proc/acpi/wakeup; fi
|
||||
done || true
|
||||
# 로지텍 수신기 등 USB 기기 자체의 깨우기도 끔
|
||||
for f in /sys/bus/usb/devices/*/power/wakeup; do echo disabled > "$f" 2>/dev/null || true; done
|
||||
}
|
||||
|
||||
if [ "$1" = install ]; then
|
||||
cp "$0" /usr/local/sbin/wake-lan-only.sh
|
||||
cat > /etc/systemd/system/wake-lan-only.service <<UNIT
|
||||
[Unit]
|
||||
Description=절전 깨우기를 유선랜만 허용
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/sbin/wake-lan-only.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
UNIT
|
||||
# 절전에서 복귀할 때도 설정이 풀릴 수 있어 같은 서비스를 다시 돌린다
|
||||
cat > /usr/lib/systemd/system-sleep/wake-lan-only <<'HOOK'
|
||||
#!/bin/sh
|
||||
[ "$1" = pre ] && /usr/local/sbin/wake-lan-only.sh
|
||||
exit 0
|
||||
HOOK
|
||||
chmod +x /usr/lib/systemd/system-sleep/wake-lan-only
|
||||
systemctl daemon-reload; systemctl enable --now wake-lan-only.service
|
||||
else
|
||||
apply
|
||||
fi
|
||||
echo "--- 결과(enabled인 장치만)"; grep enabled /proc/acpi/wakeup
|
||||
@@ -12,10 +12,9 @@
|
||||
import { getConfig } from '../../config/config.js';
|
||||
import { lightChat } from '../../providers/light-chat.js';
|
||||
|
||||
// "flash"-tier model chosen specifically for latency, not quality — this call is a small
|
||||
// classification task (pick relevant indices from a short list), not a task worth spending
|
||||
// primary-model-grade reasoning time on. Revisit if this model is ever unpulled/renamed.
|
||||
const RERANK_MODEL = 'gemma4:31b-cloud';
|
||||
// 모델은 lightChat()이 활성 provider의 싼 모델(Anthropic이면 Haiku)로 정한다 — 이 호출은 짧은 목록에서 관련
|
||||
// 항목 번호를 고르는 분류 작업이라 주 모델급 추론이 필요 없다. (예전에 여기 박혀 있던 올라마 클라우드 모델
|
||||
// 상수는 10-17 lightChat 전환 후 쓰이지 않아 2026-10-30 제거 — 올라마 구독이 끝나도 영향 없음.)
|
||||
// Only fires on genuinely ambiguous retrieval (see the gating in personality-context.ts) —
|
||||
// most turns never reach this call at all, so a generous timeout here doesn't cost anything
|
||||
// on the common path. 8s was measured to occasionally clip real (successful, just slow)
|
||||
|
||||
@@ -447,25 +447,16 @@ export function registerImagegenRoutes(app: Express): void {
|
||||
: `당신은 이미지/동영상 생성 스튜디오 앱에 내장된 프롬프트 작성 도우미입니다. 사용자가 한국어로 설명하는 이미지를 SDXL/FLUX 같은 이미지 diffusion 모델에 적합한 영어 프롬프트로 다듬어주세요 (스타일, 조명, 구도, 디테일 태그 포함). 대화는 한국어로 하되, 답변 맨 끝에는 반드시 아래 형식의 블록을 붙이세요:\n\`\`\`\nPROMPT: <영어 프롬프트>\nNEGATIVE: <네거티브 프롬프트, 없으면 빈 칸>\n\`\`\``;
|
||||
|
||||
try {
|
||||
const { getConfig } = await import('../../config/config.js');
|
||||
const rawCfg = getConfig().getConfig() as any;
|
||||
const provider: string = rawCfg.llm?.provider || 'ollama';
|
||||
const model: string = rawCfg.llm?.providers?.[provider]?.model || rawCfg.models?.primary || 'gemma4:31b-cloud';
|
||||
const endpoint: string = rawCfg.ollama?.endpoint || 'http://localhost:11434';
|
||||
|
||||
const r = await fetch(`${endpoint}/api/chat`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
model,
|
||||
messages: [{ role: 'system', content: systemPrompt }, ...messages],
|
||||
stream: false,
|
||||
}),
|
||||
signal: AbortSignal.timeout(60_000),
|
||||
});
|
||||
if (!r.ok) return res.status(502).json({ error: `ollama HTTP ${r.status}` });
|
||||
const data: any = await r.json();
|
||||
const reply = String(data?.message?.content || '').trim();
|
||||
// 2026-10-30: 올라마 /api/chat에 활성 모델명을 그대로 보내던 것을 provider 추상화(lightChat)로 교체 —
|
||||
// 주 모델이 Anthropic이면 'claude-haiku-5-5'가 올라마로 가서 404였고, 올라마 구독이 끝나도 안 깨지게 한다.
|
||||
const { lightChat } = await import('../../providers/light-chat.js');
|
||||
const chatMessages = [
|
||||
{ role: 'system' as const, content: systemPrompt },
|
||||
...messages
|
||||
.filter((m: any) => m && (m.role === 'user' || m.role === 'assistant'))
|
||||
.map((m: any) => ({ role: m.role as 'user' | 'assistant', content: String(m.content ?? '') })),
|
||||
];
|
||||
const reply = await lightChat(chatMessages, { max_tokens: 1500, temperature: 0.6, timeoutMs: 60_000 });
|
||||
if (!reply) return res.status(502).json({ error: 'empty response from model' });
|
||||
res.json({ reply });
|
||||
} catch (err: any) {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { visionModelOverride } from '../../providers/light-chat.js';
|
||||
import { visionModelOverride, lightModel } from '../../providers/light-chat.js';
|
||||
import { getProvider } from '../../providers/factory.js';
|
||||
import { contentToString } from '../../providers/content-utils.js';
|
||||
import express from 'express';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { getConfig, getUserWorkspace } from '../../config/config';
|
||||
import { getOllamaClient } from '../../agents/ollama-client';
|
||||
import { filterImageMarkdown } from '../guards/link-validator';
|
||||
import { toPaperSearchQuery } from '../../tools/query-translate.js';
|
||||
import { getToolRegistry } from '../../tools/registry.js';
|
||||
@@ -913,20 +914,21 @@ app.post('/api/pptx/analyze-image', requireGatewayAuth, async (req: express.Requ
|
||||
const b64 = `data:${mime};base64,${buf.toString('base64')}`;
|
||||
|
||||
// Call vision model
|
||||
const ollama2 = getOllamaClient();
|
||||
// 2026-10-30: 올라마 클라이언트를 직접 부르던 것을 활성 provider의 싼 비전 모델(Claude·Gemini·GPT는 모두 비전 지원)로.
|
||||
// 올라마가 활성일 때만 예전처럼 비전용 올라마 모델을 쓴다(visionModelOverride).
|
||||
const rawCfg2 = getConfig().getConfig() as any;
|
||||
const sec2 = rawCfg2.orchestration?.secondary;
|
||||
const visionModel = (sec2?.model && sec2?.vision === true) ? sec2.model : visionModelOverride('mistral-large-3:675b-cloud');
|
||||
const visionModel = (sec2?.model && sec2?.vision === true) ? sec2.model : (visionModelOverride('mistral-large-3:675b-cloud') || lightModel());
|
||||
|
||||
const result = await ollama2.chatWithThinking([{
|
||||
const result: any = await getProvider().chat([{
|
||||
role: 'user' as const,
|
||||
content: [
|
||||
{ type: 'text' as const, text: '이 그림을 한 줄(30자 이내)로 설명하세요. 그래프/차트/다이어그램 종류와 핵심 내용 위주로. 슬라이드에 쓰기 부적합한 그림(흐릿함·텍스트만 있는 표·빈 이미지)이면 "제외"라고만 답하세요.' },
|
||||
{ type: 'image_url' as const, image_url: { url: b64 } },
|
||||
],
|
||||
}], 'executor', { model: visionModel, num_predict: 80 });
|
||||
}] as any, visionModel, { max_tokens: 100, temperature: 0.2 } as any);
|
||||
|
||||
const caption = String(result.message?.content || '').trim().replace(/\n/g, ' ').slice(0, 80);
|
||||
const caption = contentToString(result?.message?.content ?? '').trim().replace(/\n/g, ' ').slice(0, 80);
|
||||
cached[imgUrl] = caption;
|
||||
if (cacheFile) {
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* speech-dates — TTS가 연도 없는 슬래시 날짜를 "십 삼십"으로 읽어 월·일이 빠지던 문제(2026-10-30).
|
||||
* 표본: 같은 날 어시스턴트 답변의 "내일(10/30)", "11/2 월요일", "11/2~11/8", "11/3~4".
|
||||
*/
|
||||
import { test, describe } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const { spellDatesForSpeech: f } = require('../web-ui/js/voice/speech-dates.js');
|
||||
|
||||
describe('spellDatesForSpeech', () => {
|
||||
test('슬래시 날짜는 월·일로', () => {
|
||||
assert.equal(f('내일(10/30)은 강수'), '내일(10월 30일)은 강수');
|
||||
assert.equal(f('기상청 10/28 23시 발표 기준'), '기상청 10월 28일 23시 발표 기준');
|
||||
assert.equal(f('11/5 구름많음'), '11월 5일 구름많음');
|
||||
});
|
||||
test('요일이 붙으면 모호한 꼴도 날짜', () => {
|
||||
assert.equal(f('11/2 월요일은 비'), '11월 2일 월요일은 비');
|
||||
assert.equal(f('9/11(월)'), '9월 11일(월)');
|
||||
assert.equal(f('3/4 토요일'), '3월 4일 토요일');
|
||||
});
|
||||
test('범위: 11/2~11/8, 11/3~4', () => {
|
||||
assert.equal(f('다음 주(11/2~11/8) 예보'), '다음 주(11월 2일에서 11월 8일) 예보');
|
||||
assert.equal(f('11/3~4는 맑고'), '11월 3일에서 4일은 맑고');
|
||||
assert.equal(f('주말 10/30(토)~10/31(일)'), '주말 10월 30일(토)에서 10월 31일(일)');
|
||||
});
|
||||
test('날짜 말머리가 있으면 모호한 꼴도 날짜', () => {
|
||||
assert.equal(f('내일 9/11 도착'), '내일 9월 11일 도착');
|
||||
});
|
||||
test('점 표기는 요일이 붙을 때만', () => {
|
||||
assert.equal(f('10.30(토)'), '10월 30일(토)');
|
||||
assert.equal(f('10.30 토요일'), '10월 30일 토요일');
|
||||
assert.equal(f('기온 10.30도'), '기온 10.30도');
|
||||
assert.equal(f('가격 3.5배'), '가격 3.5배');
|
||||
});
|
||||
test('분수·비율·단위는 건드리지 않는다', () => {
|
||||
assert.equal(f('1/2컵'), '1/2컵');
|
||||
assert.equal(f('3/4 정도'), '3/4 정도');
|
||||
assert.equal(f('24/7 운영'), '24/7 운영');
|
||||
assert.equal(f('풍속 2.6 m/s'), '풍속 2.6 m/s');
|
||||
assert.equal(f('성공률 9/10'), '성공률 9/10');
|
||||
});
|
||||
test('연도가 붙은 날짜는 그대로 둔다(뒤 규칙이 처리)', () => {
|
||||
assert.equal(f('2026/10/30'), '2026/10/30');
|
||||
assert.equal(f('2026-10-30'), '2026-10-30');
|
||||
});
|
||||
test('빈 입력', () => {
|
||||
assert.equal(f(''), '');
|
||||
assert.equal(f(null), '');
|
||||
});
|
||||
});
|
||||
@@ -2148,6 +2148,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="../js/voice/speech-dates.js"></script>
|
||||
<script src="../js/voice/speech-units.js"></script>
|
||||
<script src="../js/voice/speech-tables.js"></script>
|
||||
<script src="../js/voice/voice-call.js"></script>
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
// speech-dates.js — 음성 읽기(TTS)용 "연도 없는 날짜" → "M월 D일" 변환
|
||||
//
|
||||
// 2026-10-30 "스피치 엔진이 월·일을 구분하지 못한다 — '십 삼십 토요일'". 어시스턴트 답변은 날씨·일정에서
|
||||
// "내일(10/30)", "11/2 월요일", "11/2~11/8", "11/3~4"처럼 슬래시 날짜를 자주 쓴다. voice-call.js의 sanitizeForSpeech는
|
||||
// 연도가 붙은 날짜(2026-10-30)만 "월·일"로 바꿨기 때문에, 슬래시 날짜는 숫자만 한글로 풀려 "십 삼십"이 되고 "월·일"이 통째로
|
||||
// 빠졌다. 여기서 "M월 D일"로 바꿔 두면 뒤의 파이프라인이 10월→시월·6월→유월, 숫자→한글 낭독을 이어서 처리한다.
|
||||
//
|
||||
// 분수(1/2, 3/4)·비율·24/7을 날짜로 오인하지 않도록 보수적으로 판정한다:
|
||||
// · 월 1~12, 일 1~31이어야 한다.
|
||||
// · 앞 수가 뒤 수보다 크면(11/5 — 가분수는 거의 안 쓴다) 또는 뒤 수가 12를 넘으면(10/30) 날짜로 본다.
|
||||
// · 그 밖의 모호한 꼴(3/4, 9/11)은 뒤에 요일이 오거나 앞에 날짜 말머리(오늘·내일·기준·발표…)가 있을 때만 날짜.
|
||||
// · 점 표기(10.30)는 소수와 구별이 안 되므로 바로 뒤에 요일 표시가 있을 때만(10.30(토)).
|
||||
// voice-call.js(통화)와 voice.js(읽기 버튼)가 sanitizeForSpeech를 통해 같이 쓴다.
|
||||
(function (root) {
|
||||
var WEEKDAY_AFTER = /^\s*(?:\(\s*[월화수목금토일]\s*\)|[월화수목금토일]요일|[월화수목금토일](?![가-힣A-Za-z0-9]))/;
|
||||
var DATE_LEAD_BEFORE = /(?:오늘|내일|모레|어제|그제|글피|이번|다음|주말|기준|발표|예보|날짜|일정|마감|까지|부터|에서|예정|도착|출발|개봉|시작|종료)\s*[(\[]?\s*$/;
|
||||
|
||||
function validMD(m, d) { return m >= 1 && m <= 12 && d >= 1 && d <= 31; }
|
||||
|
||||
function isDateByContext(m, d, before, after, dotForm) {
|
||||
if (!validMD(m, d)) return false;
|
||||
if (WEEKDAY_AFTER.test(after)) return true;
|
||||
if (dotForm) return false; // 점 표기는 요일이 붙어야만
|
||||
if (m > d || d > 12) return true; // 분수 꼴이 아님(11/5, 10/30)
|
||||
return DATE_LEAD_BEFORE.test(before); // 3/4·9/11 같은 모호한 꼴은 말머리가 있을 때만
|
||||
}
|
||||
|
||||
function spellDatesForSpeech(text) {
|
||||
var src = String(text == null ? '' : text);
|
||||
|
||||
// 1) 범위: 11/2~11/8, 11/3~4, 10/30(토)~10/31(일) → "11월 2일에서 11월 8일", "11월 3일에서 4일", "10월 30일(토)에서 10월 31일(일)"
|
||||
src = src.replace(/(?<![\d./])(\d{1,2})\/(\d{1,2})(\s*\(\s*[월화수목금토일]\s*\))?\s*[~∼~]\s*(?:(\d{1,2})\/)?(\d{1,2})(?![\d/])/g,
|
||||
function (m0, m1, d1, wd1, m2, d2) {
|
||||
var a = +m1, b = +d1, c = m2 === undefined ? null : +m2, e = +d2;
|
||||
if (!validMD(a, b)) return m0;
|
||||
if (c !== null ? !validMD(c, e) : (e < 1 || e > 31)) return m0;
|
||||
var tail = c !== null ? c + '월 ' + e + '일' : e + '일';
|
||||
return a + '월 ' + b + '일' + (wd1 || '') + '에서 ' + tail;
|
||||
});
|
||||
|
||||
// 2) 슬래시 단일 날짜: 10/30, 11/2 월요일, (10/30)
|
||||
src = src.replace(/(?<![\d./])(\d{1,2})\/(\d{1,2})(?![\d/])/g, function (m0, mo, da, offset, whole) {
|
||||
var before = whole.slice(Math.max(0, offset - 12), offset);
|
||||
var after = whole.slice(offset + m0.length);
|
||||
if (!isDateByContext(+mo, +da, before, after, false)) return m0;
|
||||
return +mo + '월 ' + +da + '일';
|
||||
});
|
||||
|
||||
// 3) 점 단일 날짜: 요일이 바로 붙은 10.30(토) / 10.30 토요일만
|
||||
src = src.replace(/(?<![\d./])(\d{1,2})\.(\d{1,2})(?![\d.])/g, function (m0, mo, da, offset, whole) {
|
||||
var before = whole.slice(Math.max(0, offset - 12), offset);
|
||||
var after = whole.slice(offset + m0.length);
|
||||
if (!isDateByContext(+mo, +da, before, after, true)) return m0;
|
||||
return +mo + '월 ' + +da + '일';
|
||||
});
|
||||
|
||||
// 4) "…일" 뒤에 붙은 조사 보정(범위 끝 "4일는" → "4일은")
|
||||
src = src.replace(/(\d)일(는|가)(?![가-힣])/g, function (_m, n, j) { return n + '일' + (j === '는' ? '은' : '이'); });
|
||||
|
||||
return src;
|
||||
}
|
||||
|
||||
if (typeof module !== 'undefined' && module.exports) module.exports = { spellDatesForSpeech: spellDatesForSpeech };
|
||||
if (root) root.spellDatesForSpeech = spellDatesForSpeech;
|
||||
})(typeof window !== 'undefined' ? window : (typeof globalThis !== 'undefined' ? globalThis : null));
|
||||
@@ -473,6 +473,9 @@
|
||||
// "9,500원"이 "구, 오백원"이 되어 "천"이 통째로 사라진다(09-26 "단어가 한번씩 빠진다", 표의 가격 열).
|
||||
// 단위 낭독보다 먼저여야 "$1,200"이 "1달러,200"으로 쪼개지지 않는다.
|
||||
text = String(text || '').replace(/(?<=\d),(?=\d{3}(?!\d))/g, '');
|
||||
// 연도 없는 슬래시 날짜 10/30·11/2~11/8 → "10월 30일"(10-30 "십 삼십 토요일"로 월·일이 빠지던 문제, speech-dates.js).
|
||||
// 연도 있는 날짜 규칙·시월/유월·숫자 낭독보다 먼저여야 뒤 파이프라인이 이어서 처리한다.
|
||||
text = window.spellDatesForSpeech ? window.spellDatesForSpeech(text) : text;
|
||||
text = window.spellUnitsForSpeech ? window.spellUnitsForSpeech(text) : text; // g/kg/GB/Hz… 단위 낭독(speech-units.js)
|
||||
return text
|
||||
// 날짜 2026-10-19 / 2026.10.19 / 2026/10/19 → "2026년 10월 19일"(안 그러면 마이너스·점으로 읽힌다). 월은 아래에서 시월·유월 처리.
|
||||
|
||||
Reference in new issue
Block a user