Commit Graph

95 Commits

Author SHA1 Message Date
Dominik Seemann 1f256f3683 Merge remote-tracking branch 'origin/main' into feat/25-i18n-oasis-profile-generator-prompts
# Conflicts:
#	.kiro/specs/i18n-oasis-profile-generator-prompts/design.md
#	.kiro/specs/i18n-oasis-profile-generator-prompts/requirements.md
#	.kiro/specs/i18n-oasis-profile-generator-prompts/spec.json
#	.kiro/specs/i18n-oasis-profile-generator-prompts/tasks.md
#	backend/app/services/oasis_profile_generator.py
2026-05-11 11:19:46 +02:00
Dominik Seemann 8189c08166 docs(i18n): translate chinese docstrings/comments in backend/services 2026-05-09 10:59:40 +00:00
Dominik Seemann b5a8996692 docs(i18n): translate chinese docstrings/comments in backend/api 2026-05-09 10:59:36 +00:00
Dominik Seemann 6439e58eb5 Merge branch 'main' into docs/i18n-7-translate-backend-comments
# Conflicts:
#	backend/app/services/ontology_generator.py
2026-05-09 10:40:10 +00:00
Dominik Seemann e6f939592c
Merge pull request #34 from salestech-group/feat/i18n-3-translate-oasis-profile-prompts
feat(i18n): translate oasis_profile_generator prompts to english
2026-05-08 11:09:17 +02:00
Dominik Seemann ec669c1d10
Merge pull request #31 from salestech-group/fix/24-externalize-remaining-backend-log-strings
fix(i18n): externalize remaining chinese backend log strings
2026-05-08 11:08:56 +02:00
Dominik Seemann 3793c960e8 feat(i18n): translate oasis_profile_generator prompts to english
Translate the system prompt and the individual / group persona prompt
builders in backend/app/services/oasis_profile_generator.py from
Chinese to English. The base prompt language was biasing persona
prose (bio, persona, profession, interested_topics) toward Chinese
even under Accept-Language: en, despite the existing
get_language_instruction() postfix mechanism. Translating the base
prompts removes that bias.

All locale-steering call sites are preserved verbatim (the inline
{get_language_instruction()} in each builder, the system-prompt
assembly), so non-English locales continue to receive Chinese output
of equivalent quality. Locale-independent constraints stay English
inside the prompt: gender stays the literal "male"/"female" enum
for individuals and "other" for groups; age stays an integer (30
for institutional accounts). The two attrs_str / context_str fallback
defaults ("无", "无额外上下文") are translated to "None" /
"No additional context" so they compose with the English body.

The country-language hint country: 国家(使用中文,如"中国") is
dropped during translation; locale now decides the country language
via the postfix.

Out of scope (untouched): logger calls (issue #6, already merged),
docstrings and comments (issue #7), the rule-based fallback
_generate_profile_rule_based, and the resilience helpers
_fix_truncated_json / _try_fix_json. No public API change, no new
dependencies, no edits outside the target file.

Closes #3
2026-05-08 05:44:00 +00:00
Dominik Seemann 7f74e0a3f8 fix(i18n): translate oasis profile generator prompts to english
The oasis_profile_generator.py system prompt, both user-message
templates (individual + group personas), the context-builder section
labels embedded into the prompt context, the fallback persona templates,
and the per-batch console output banners were all written in Chinese.
Even when Accept-Language was en, the Chinese base prompt and embedded
section labels biased the LLM toward Chinese persona output.

Translate every owned prompt-assembly literal to English while
preserving all functional contracts: f-string interpolations, the
required JSON output keys, the gender/age literal-token rules, the
get_language_instruction() postfix call sites, the _normalize_gender
mapping (which still accepts Chinese gender keys from upstream),
and the rule-based country: "中国" data default. Logger calls,
docstrings, and inline comments are out of scope (issues #6 / #7)
and were not touched.

Closes #25
2026-05-07 23:36:42 +00:00
Dominik Seemann e60a5a93d3 fix(i18n): externalize remaining chinese backend log strings
Replace the last hard-coded Chinese log/print strings in the Flask
graph API, OASIS profile generator, and retry utility with calls to
the existing t() helper, completing the backend i18n coverage started
by ticket #6 so EN-locale operators see English logs end to end.

Adds nine entries to locales/{en,zh}.json: log.graph_api.m027-m029,
log.profile_generator.m024-m025, and a new log.retry.m001-m004
sub-namespace for the retry utility.

Closes #24
2026-05-07 22:40:18 +00:00
Dominik Seemann b8de81a539 fix(graphiti): surface embedding failures and document ollama embedder
Replace the silent placeholder-UUID fallback in
_GraphNamespace.add_batch with logger.exception(...) + raise so
embedder misconfiguration (404 unknown model, connection refused, etc.)
fails the surrounding graph-build Task with a visible error instead of
producing a Task that looks completed while the graph stays empty.

Document the existing-but-undocumented Ollama embedder configuration
in .env.example, CLAUDE.md, README.md, and docker-compose.yml.
mxbai-embed-large is the recommended local model because its 1024-dim
output matches Graphiti's default EMBEDDING_DIM. Adds a curl smoke
test to verify embedder reachability before the first graph build.

No new env var or provider literal: Ollama is reached through the
existing openai-provider branch by setting EMBEDDING_BASE_URL,
EMBEDDING_API_KEY, and EMBEDDING_MODEL.

Closes #18
2026-05-07 20:39:42 +00:00
Dominik Seemann b15dc2ea2c
Merge pull request #19 from salestech-group/feat/i18n-6-externalize-backend-logs
feat(i18n): externalize chinese log and api response strings
2026-05-07 17:09:38 +02:00
Dominik Seemann 4f6d5d19a8
Merge pull request #17 from salestech-group/feat/i18n-5-translate-report-agent-prompts
feat(i18n): translate report_agent react prompts to english
2026-05-07 17:08:22 +02:00
Dominik Seemann 0f3ba443dd
Merge pull request #16 from salestech-group/feat/i18n-4-translate-sim-config-prompts
feat(i18n): translate simulation_config_generator prompts to english
2026-05-07 17:07:52 +02:00
Dominik Seemann e1019d91cb docs(i18n): translate chinese docstrings/comments in backend root, api init, simulation_ipc, simulation_manager, zep_entity_reader 2026-05-07 14:49:20 +00:00
Dominik Seemann e3f7defefc docs(i18n): translate chinese docstrings/comments in backend/app/{models,utils} and partial services 2026-05-07 14:44:08 +00:00
Dominik Seemann 74997fd088 feat(i18n): externalize chinese log and api response strings
Extract every Chinese string inside backend logger.{info,warning,error,
debug,exception} calls and inside user-facing jsonify({"error|message":
...}) responses across the listed in-scope modules into
locales/{en,zh}.json under nested namespaces (log.<module>.*,
api.{error,message}.<scope>.*). Locale dictionaries stay structurally
identical; the existing flat frontend-facing keys at log.* / api.* are
left untouched. The locale helper (backend/app/utils/locale.py) now
emits a single deduplicated mirofish.locale warning per (locale, key)
pair when a translation is missing instead of silently returning the
raw key, so unknown keys are visible without crashing requests or
background tasks. A repo-root scripts/check_i18n_logs.py verifier
performs an AST-aware source scan for residual Chinese inside the
in-scope logger/jsonify calls and a recursive parity diff between
en.json and zh.json — both modes pass.

Why: backend logs and API errors previously emitted Chinese-only
strings, leaving English-speaking operators with unreadable log
aggregator output and API consumers with locale-mismatched error
messages. The t() helper and per-thread set_locale propagation already
existed; this change makes every backend caller route through them.

Closes #6
2026-05-07 13:52:22 +00:00
Dominik Seemann 22a3ca7af5 feat(i18n): translate report_agent react prompts to english
translate every llm-facing string-literal in
backend/app/services/report_agent.py — the four tool-description
constants, the plan/section/chat system+user prompts, the react loop
templates, the inline messages re-injected during the section and chat
loops, the _execute_tool error returns, and the plan_outline default and
fallback outline content. preserve every {interpolation} token, the
literal final answer: trigger and <tool_call> xml tag, the four primary
tool names, and all three get_language_instruction() postfix call sites.
also switch the unused-tools join separator from "、" to ", " so it
renders naturally inside the now-english react templates.

removes the chinese language bias that the english postfix alone could
not overcome — under accept-language: en the report agent now produces
english-flavoured analytical reports and chat replies; under
accept-language: zh the postfix continues to steer the model into
chinese with no semantic delta. logger calls (#6) and docstrings or
comments (#7) are deliberately untouched.

Closes #5
2026-05-07 12:49:23 +00:00
Dominik Seemann 6c2a412196 feat(i18n): translate simulation_config_generator prompts to english
translate the three llm prompt blocks plus the two prompt-feeding helpers
(_build_context, _summarize_entities) in
backend/app/services/simulation_config_generator.py from chinese to english.
the chinese base prompts were biasing the model toward chinese structure
and lexical choice for content, narrative_direction, hot_topics, and
reasoning fields even when accept-language was en, because
get_language_instruction() only steers the response language as a
postfix.

translation is in-place and preserves every functional contract: the
json output schema for all three prompts, every variable interpolation,
the per-entity-type heuristic ranges in the agent-config prompt, the
trailing english IMPORTANT directives that lock poster_type to
PascalCase and stance to {supportive,opposing,neutral,observer}, and
all three get_language_instruction() postfix call sites. the two
default-path reasoning literals are translated to locale-agnostic
english so generation_reasoning no longer mixes chinese and english on
the failure path.

logger calls, docstrings, and inline comments are intentionally left
chinese (out of scope; covered by issues #6 and #7). public api,
dataclasses, class constants, and the SimulationParameters payload
shape are unchanged.

Closes #4
2026-05-07 11:43:47 +00:00
Dominik Seemann 080683295d feat(i18n): translate ontology_generator prompts to english
translate the system prompt constant and the user-message template in
backend/app/services/ontology_generator.py from chinese to english.
the chinese base prompt was biasing the model toward chinese structure
and word choice even when accept-language was en, leaving ontology
descriptions and analysis_summary fields chinese-flavoured.

translation is in-place and preserves every functional contract: the
json output schema, the entity-type and relationship-type taxonomies
verbatim, the reserved-attribute-name list, the count and length
constraints, and all f-string interpolations. the
get_language_instruction() postfix call site and the trailing english
identifier-format directive are unchanged, so zh and other locales
continue to receive locale-appropriate descriptions.

logger calls, docstrings, and inline comments are intentionally left
in chinese — they are owned by issues #6 and #7.

a small static guard script (backend/scripts/test_ontology_prompts_no_cjk.py)
ast-parses the module and asserts zero cjk in the system prompt and in
every string literal of _build_user_message except the docstring, so
the regression cannot reappear silently.

Closes #2
2026-05-07 09:40:27 +00:00
Dominik Seemann 2badf568e7 feat(graphiti): finalize neo4j migration with provider switch
Adds a Neo4j service to docker-compose so `docker compose up -d` works
on a clean checkout, and unhardcodes Graphiti's LLM/embedder so the
documented default provider (Qwen via Dashscope) actually works.

- docker-compose: neo4j:5-community service with cypher-shell
  healthcheck, named volumes, and `depends_on: service_healthy` on the
  app container; in-Docker NEO4J_URI override leaves the host-mode
  default untouched.
- Config: new GRAPHITI_LLM_PROVIDER (openai|gemini, default openai) plus
  optional EMBEDDING_API_KEY / EMBEDDING_BASE_URL that fall back to the
  chat LLM credentials.
- graphiti_adapter: provider switch inside the singleton factory with
  lazy per-provider imports; Gemini path is preserved exactly. The
  no-op `_GeminiReranker` becomes a provider-agnostic
  `_PassthroughReranker`, still injected explicitly so Graphiti does
  not fall back to its OpenAI-only default reranker.
- Drop the ignored `reranker=` kwarg from `_GraphNamespace.search` and
  the misleading callers in `zep_tools.py` and
  `oasis_profile_generator.py`.
- Refresh `.env.example` to mirror the README env section.

Spec, requirements, and design under
`.kiro/specs/graphiti-neo4j-finalize/`.

Closes #1
2026-05-07 08:43:36 +00:00
stg 62648289d1 Merge remote-tracking branch 'abhiyadav2345/feat/graphiti-neo4j-migration' 2026-05-05 15:03:47 +02:00
BaiFu af71244974
Merge pull request #428 from Ghostubborn/feat/i18n
feat(i18n): 添加多语言切换功能,支持中英文
2026-04-02 14:27:04 +08:00
ghostubborn f2404903d6 fix(i18n): validate Accept-Language header against registered locales 2026-04-02 14:20:15 +08:00
ghostubborn 24e9bee5be feat(i18n): replace all user-visible Chinese logger messages in zep_tools.py
These are shown to users via ConsoleLogger in the report page.
2026-04-01 17:46:39 +08:00
ghostubborn e79569ab4f feat(i18n): replace all user-visible Chinese in report_agent.py
Covers ReportLogger message fields and logger messages shown via ConsoleLogger.
2026-04-01 17:44:52 +08:00
666ghj e3350a919d fix(graph): enforce PascalCase for entity names and SCREAMING_SNAKE_CASE for edge names in ontology validation 2026-04-01 17:42:27 +08:00
ghostubborn 380e456d41 fix(i18n): replace hardcoded Chinese stage names in simulation prepare SSE 2026-04-01 17:31:00 +08:00
ghostubborn 0e55e4cf6b feat(i18n): replace remaining Chinese in config generator and profile generator
Also update simulation prompts to be locale-neutral for timezone/schedule.
2026-04-01 17:19:12 +08:00
ghostubborn 7c07237544 fix(i18n): pass locale to background threads via thread-local storage
Background threads (graph building, simulation prep, report generation,
profile generation) now inherit the requesting user's locale preference.
Previously these fell back to 'zh' because Flask request context was
unavailable in spawned threads.
2026-04-01 16:55:51 +08:00
ghostubborn 592ee52f59 feat(i18n): replace remaining hardcoded Chinese in progress callbacks 2026-04-01 16:53:29 +08:00
ghostubborn da2490ec31 fix(i18n): protect JSON field values from language instruction in config generator
Ensure poster_type stays PascalCase English and stance stays English enum
values regardless of language setting. Only natural language fields follow
the user's language preference.
2026-04-01 16:41:22 +08:00
ghostubborn 97aa58384e fix(i18n): ensure ontology names stay PascalCase regardless of language setting
The language instruction was causing LLM to change entity/relation naming
conventions. Now explicitly enforce PascalCase/UPPER_SNAKE_CASE for technical
identifiers while only applying language preference to description fields.
2026-04-01 16:40:17 +08:00
ghostubborn 9d43b77511 feat(i18n): replace hardcoded Chinese in backend SSE progress messages 2026-04-01 16:32:10 +08:00
ghostubborn f75c6487b3 fix(i18n): replace remaining hardcoded language directives in LLM prompts
- oasis_profile_generator: replace hardcoded "使用中文" with dynamic get_language_instruction()
- ontology_generator: remove hardcoded "(中文)" from schema annotation
- report_agent: replace Chinese-specific language consistency rules with language-neutral ones
- zep_tools: dynamically select quote style based on locale
2026-04-01 15:55:04 +08:00
ghostubborn 74f673a238 feat(i18n): replace hardcoded Chinese in backend API responses with t() calls 2026-04-01 15:32:24 +08:00
ghostubborn 8f6110df0f feat(i18n): inject language instruction into LLM system prompts 2026-04-01 15:24:12 +08:00
ghostubborn 0c18e1aeca feat(i18n): add backend translation utility with shared locale files 2026-04-01 15:22:14 +08:00
Abhishek Yadav 2703d3dbfe fix: update error handling to check for NEO4J_PASSWORD instead of ZEP_API_KEY in simulation API
- Changed error messages to reflect the new configuration requirement for Neo4j.
- Ensured consistent handling of missing credentials across multiple functions.
2026-03-22 01:54:51 +05:30
Abhishek Yadav 28827067c0 feat: migrate knowledge graph from Zep Cloud to Graphiti + local Neo4j
Replaces the paid, rate-limited Zep Cloud service with Graphiti (graphiti-core
0.11.6) backed by a local Neo4j instance — free, unlimited, and self-hosted.

Key changes:
- Add GraphitiAdapter: drop-in Zep-compatible wrapper around Graphiti with a
  persistent event-loop thread to avoid asyncio/Neo4j driver conflicts
- Switch LLM client to native GeminiClient + GeminiEmbedder (text-embedding-004
  fails on Gemini compat endpoint; use google-genai SDK directly)
- Add _GeminiReranker passthrough replacing OpenAIRerankerClient (which
  hardcodes gpt-4.1-nano and uses logprobs unsupported by Gemini)
- Fix Cypher queries: use s.uuid/t.uuid for edge source/target instead of
  r.source_node_uuid (null property in Graphiti's schema)
- Add ontology-based entity type classifier (_classify_entity_type) so nodes
  get colored by type in the D3 graph visualization instead of all being Entity
- Apply classifier in ZepEntityReader so filter_defined_entities finds entities
  (previously 0 personas loaded because all labels were ['Entity'])
- Add startup recovery: auto-mark graph_building projects as graph_completed
  on backend restart if Neo4j already has their data
- Add resume capability to graph build: skip already-processed episodes after
  a restart (断点续传)
- Add non-blocking graph data cache with background refresh in graph.py
- Add EMBEDDING_MODEL config (default: gemini-embedding-001 for Gemini users)
- Add CLAUDE.md with project architecture and dev commands

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-22 01:30:28 +05:30
666ghj 985f89f49a fix: resolve 500 error caused by <think> tags and markdown code fences in content field from reasoning models like MiniMax/GLM 2026-03-06 00:30:31 +08:00
666ghj da6548e96f feat(graph): implement pagination for fetching nodes and edges; add utility functions for streamlined data retrieval 2026-02-27 15:53:29 +08:00
666ghj 25aa4f75d2 fix(report_agent): refine tool call handling and response validation; enforce strict separation between tool calls and final answers 2026-02-24 17:47:44 +08:00
666ghj 08ec856a58 fix(report_agent): update max_agents parameter description and enforce maximum limit of 10 agents 2026-02-14 18:35:05 +08:00
666ghj ddd9ff2479 feat(report_agent): update report language consistency guidelines; ensure all quoted content is translated to the report language for clarity 2026-02-14 18:24:03 +08:00
666ghj 7601d78fd4 feat(report_agent): enhance interview text processing and response handling; improve quote extraction and formatting for better clarity 2026-02-14 16:56:48 +08:00
666ghj dc0a9261d1 feat(report_agent): add detailed tool descriptions and prompts for future prediction report generation 2026-02-14 15:16:17 +08:00
666ghj d2041f6fb8 fix(report_agent): update description of insight_forge tool to remove "最强大" and enhance clarity 2026-02-14 14:48:23 +08:00
666ghj 0a59bace92 fix(report_agent): increase minimum tool call requirement from 2 to 3 per chapter and enhance user prompts to encourage diverse tool usage 2026-02-06 19:37:52 +08:00
666ghj e004fe8f14 fix(report_agent): update tool call requirements in content generation to allow up to 5 tool calls per chapter and clarify user prompts for insufficient data 2026-02-06 18:34:19 +08:00
666ghj f9abaf8e9f refactor(report_agent, Step4Report): simplify logging and remove subsection handling; update UI to reflect changes in section content generation 2026-02-06 18:13:30 +08:00