Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 7 additions & 9 deletions agent/src/agentModeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,15 @@ export const parseModeResult = (
if (!isObject(parsed)) {
parsed = { answerMarkdown: rawText.trim() };
}
const warnings = stringArray((parsed as Record<string, unknown>).warnings);
const parsedChecklist = Array.isArray(
(parsed as Record<string, unknown>).checklist,
)
? ((parsed as Record<string, unknown>).checklist as unknown[])
const p = parsed as Record<string, unknown>;
const warnings = stringArray(p.warnings);
const parsedChecklist = Array.isArray(p.checklist)
? (p.checklist as unknown[])
: undefined;
const analysisGuard = analysisGuardFrom(request, parsedChecklist);
const answerMarkdown = requireString(
(parsed as Record<string, unknown>).answerMarkdown,
{ fieldName: "answerMarkdown" },
);
const answerMarkdown = requireString(p.answerMarkdown, {
fieldName: "answerMarkdown",
});
return {
markdown: answerMarkdown,
warnings,
Expand Down
45 changes: 16 additions & 29 deletions agent/src/pi/piSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,34 +185,22 @@ export const runPiSession = async (
});
await loader.reload();

const baseOptions = {
model,
thinkingLevel: "high" as const,
authStorage: registry.authStorage,
modelRegistry: registry,
resourceLoader: loader,
sessionManager: SessionManager.inMemory(),
settingsManager: SettingsManager.inMemory({
compaction: { enabled: false },
retry: { enabled: true, maxRetries: 1 },
}),
};
const sessionOptions =
tools.length > 0
? {
model,
thinkingLevel: "high" as const,
authStorage: registry.authStorage,
modelRegistry: registry,
resourceLoader: loader,
sessionManager: SessionManager.inMemory(),
settingsManager: SettingsManager.inMemory({
compaction: { enabled: false },
retry: { enabled: true, maxRetries: 1 },
}),
customTools: tools,
}
: {
model,
thinkingLevel: "high" as const,
authStorage: registry.authStorage,
modelRegistry: registry,
resourceLoader: loader,
sessionManager: SessionManager.inMemory(),
settingsManager: SettingsManager.inMemory({
compaction: { enabled: false },
retry: { enabled: true, maxRetries: 1 },
}),
noTools: "all" as const,
};
? { ...baseOptions, customTools: tools }
: { ...baseOptions, noTools: "all" as const };

const { session } = await createAgentSession(sessionOptions);

Expand All @@ -223,10 +211,9 @@ export const runPiSession = async (
const toolTraces: TraceLogEntry[] = [];
const abortController = new AbortController();

const traceVal = (process.env.GONGSIRI_TRACE_STDOUT ?? "true").toLowerCase();
const traceEnabled =
(process.env.GONGSIRI_TRACE_STDOUT ?? "true").toLowerCase() !== "0" &&
(process.env.GONGSIRI_TRACE_STDOUT ?? "true").toLowerCase() !== "false" &&
(process.env.GONGSIRI_TRACE_STDOUT ?? "true").toLowerCase() !== "off";
traceVal !== "0" && traceVal !== "false" && traceVal !== "off";
const tracePrefix = `pi:${promptCtx?.mode ?? "run"}:${(promptCtx?.traceId ?? "--------").slice(0, 8)}`;
const traceLog = (msg: string) => {
if (traceEnabled) console.log(`[${tracePrefix}] ${msg}`);
Expand Down
22 changes: 14 additions & 8 deletions frontend/app/(app)/portfolio/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ import RiskBadge from "@/components/ui/RiskBadge";
import AddStockModal from "@/app/(app)/watchlist/_components/AddStockModal";
import type { PortfolioItem, RiskLevel } from "@/lib/types";

const RISK_BAR_COLOR: Record<RiskLevel, string> = {
high: "#E24B4A",
caution: "#BA7517",
normal: "#639922",
};

function toRiskLevel(score: number): RiskLevel {
if (score >= 4) return "high";
if (score >= 2) return "caution";
return "normal";
}

const MOCK: PortfolioItem[] = [
{
corp_code: "00258801",
Expand Down Expand Up @@ -39,8 +51,7 @@ export default function PortfolioPage() {
return sum + (i.risk_score ?? 0) * weight;
}, 0);

const overallLevel: RiskLevel =
weightedScore >= 4 ? "high" : weightedScore >= 2 ? "caution" : "normal";
const overallLevel = toRiskLevel(weightedScore);

return (
<div>
Expand Down Expand Up @@ -110,12 +121,7 @@ export default function PortfolioPage() {
style={{
height: "100%",
width: `${(weightedScore / 6) * 100}%`,
background:
overallLevel === "high"
? "#E24B4A"
: overallLevel === "caution"
? "#BA7517"
: "#639922",
background: RISK_BAR_COLOR[overallLevel],
borderRadius: 100,
}}
/>
Expand Down
136 changes: 56 additions & 80 deletions frontend/app/(app)/report/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export default async function ReportListPage() {
) : (
reportSummaries.map((r, i) => {
const hasReport = r.hasReport !== false;
return hasReport ? (
const isLast = i === reportSummaries.length - 1;
return (
<Link
key={r.corpCode}
href={`/report/${r.corpCode}`}
Expand All @@ -96,14 +97,14 @@ export default async function ReportListPage() {
<div
style={{
padding: "14px 16px",
borderBottom:
i < reportSummaries.length - 1
? "0.5px solid var(--color-border-tertiary)"
: "none",
borderBottom: isLast
? "none"
: "0.5px solid var(--color-border-tertiary)",
display: "flex",
alignItems: "center",
gap: 12,
cursor: "pointer",
opacity: hasReport ? 1 : 0.75,
}}
>
<div style={{ flex: 1 }}>
Expand All @@ -116,87 +117,62 @@ export default async function ReportListPage() {
>
{r.corpName}
</p>
<p
className="font-mono"
style={{
fontSize: 10,
color: "var(--color-text-tertiary)",
marginTop: 2,
}}
>
{r.analyzedAt} 분석
</p>
{hasReport ? (
<p
className="font-mono"
style={{
fontSize: 10,
color: "var(--color-text-tertiary)",
marginTop: 2,
}}
>
{r.analyzedAt} 분석
</p>
) : (
<p
style={{
fontSize: 10,
color: "var(--color-text-tertiary)",
marginTop: 2,
letterSpacing: "-0.02em",
}}
>
리포트 미생성
</p>
)}
</div>
<RiskBadge level={r.riskLevel} size="sm" />
<p
className="font-mono"
style={{
fontSize: 12,
color: "var(--color-text-tertiary)",
minWidth: 32,
textAlign: "right",
}}
>
{r.riskScore}/6
</p>
</div>
</Link>
) : (
<Link
key={r.corpCode}
href={`/report/${r.corpCode}`}
style={{ textDecoration: "none", color: "inherit" }}
>
<div
style={{
padding: "14px 16px",
borderBottom:
i < reportSummaries.length - 1
? "0.5px solid var(--color-border-tertiary)"
: "none",
display: "flex",
alignItems: "center",
gap: 12,
cursor: "pointer",
opacity: 0.75,
}}
>
<div style={{ flex: 1 }}>
<p
{hasReport ? (
<>
<RiskBadge level={r.riskLevel} size="sm" />
<p
className="font-mono"
style={{
fontSize: 12,
color: "var(--color-text-tertiary)",
minWidth: 32,
textAlign: "right",
}}
>
{r.riskScore}/6
</p>
</>
) : (
<span
style={{
fontSize: 14,
fontSize: 11,
fontWeight: 500,
letterSpacing: "-0.03em",
}}
>
{r.corpName}
</p>
<p
style={{
fontSize: 10,
color: "var(--color-text-tertiary)",
marginTop: 2,
color: "#185FA5",
background: "#E6F1FB",
border: "0.5px solid #3B8BFF",
borderRadius: 6,
padding: "3px 10px",
letterSpacing: "-0.02em",
whiteSpace: "nowrap",
}}
>
리포트 미생성
</p>
</div>
<span
style={{
fontSize: 11,
fontWeight: 500,
color: "#185FA5",
background: "#E6F1FB",
border: "0.5px solid #3B8BFF",
borderRadius: 6,
padding: "3px 10px",
letterSpacing: "-0.02em",
whiteSpace: "nowrap",
}}
>
리포트 생성
</span>
리포트 생성
</span>
)}
</div>
</Link>
);
Expand Down
2 changes: 1 addition & 1 deletion frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
".next/dev/types/**/*.ts",
"**/*.mts"
],
"exclude": ["node_modules"]
"exclude": ["node_modules", "e2e"]
}
Loading