Skip to content

v0.0.6 버전 업데이트 - #8

Merged
Gyuho-Han merged 1 commit into
mainfrom
v0.0.6
Jun 21, 2026
Merged

Gyuho-Han merged 1 commit into
mainfrom
v0.0.6

Conversation

@Gyuho-Han

@Gyuho-Han Gyuho-Han commented Jun 21, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

Release Notes

  • New Features

    • Added Redis-based answer caching for improved response speed with 7-day expiration
    • Added cache management interface to view cached answers and clear cache
    • Implemented graceful degradation—app continues functioning if Redis is unavailable
  • Documentation

    • Expanded setup documentation with Redis configuration and Docker deployment instructions

@coderabbitai

coderabbitai Bot commented Jun 21, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cb2da9a9-eb47-4b7a-a8c0-5778e59193fd

📥 Commits

Reviewing files that changed from the base of the PR and between 9d8267b and 212e708.

⛔ Files ignored due to path filters (3)
  • cleaned_creation_science_data.csv is excluded by !**/*.csv
  • cleaned_dataset.csv is excluded by !**/*.csv
  • creation_science_data.csv is excluded by !**/*.csv
📒 Files selected for processing (11)
  • README.md
  • VERSIONS.md
  • app.py
  • cache.py
  • chain.py
  • config.py
  • data_pipeline.py
  • docker-compose.yml
  • ingest_vector_db.py
  • requirements.txt
  • retriever.py

📝 Walkthrough

Walkthrough

Version 0.0.6 adds Redis-backed answer caching with graceful degradation, migrates embeddings from Ollama to Google Gemini, extends the LLM prompt with a CoT reasoning block and a 16384-token context window, refactors the Streamlit app into page-routed functions (render_chat, render_cache_view), simplifies the data pipeline, and adds docker-compose.yml for Redis.

Changes

v0.0.6: Redis Caching, Gemini Embeddings, Prompt/LLM Updates, App Refactor

Layer / File(s) Summary
Config, dependencies, and Docker infrastructure
config.py, requirements.txt, docker-compose.yml
config.py gains load_dotenv(), GEMINI_API_KEY, Redis constants (REDIS_URL, CACHE_ENABLED, CACHE_TTL), Gemini embedding constants, updated chunking params, and drops RAW_CSV_PATH. requirements.txt adds langchain-google-genai, python-dotenv, and redis. docker-compose.yml defines a Redis service with persistence, health check, and restart policy.
Redis cache module
cache.py
New module implementing key normalization (_normalize, _make_key via SHA-256), get_cached_answer, set_cached_answer (stores question/answer/created_at hash with TTL), list_cached_answers (scan-based, sorted by recency), clear_cache, and cache_available; all operations fail silently when Redis is unavailable.
Gemini embedding migration
retriever.py, ingest_vector_db.py
Both files replace OllamaEmbeddings with GoogleGenerativeAIEmbeddings, add GEMINI_API_KEY presence guards, and construct Chroma via chromadb.PersistentClient. retriever.py additionally adds a 3-attempt retry loop with incremental sleep.
LLM prompt and context window
chain.py
Rewrites PROMPT_TEMPLATE with a stricter no-URL directive, a two-sentence conclusion + titled bullet output structure, and an explicit CoT step-by-step block. Introduces LLM_NUM_CTX = 16384 wired into ChatOllama via model_kwargs.
App refactor: page routing and cache integration
app.py
Adds cache module imports and a sidebar page selector with cache management UI. render_chat() encapsulates vectorstore init, serializes chat_history_str, short-circuits via get_cached_answer, performs reranking with fallback, streams generation via extract_think_and_answer, assembles final_answer_with_refs, and conditionally stores via set_cached_answer. New render_cache_view() lists cached entries with expanders.
Data pipeline simplification
data_pipeline.py
clean_data default input_file changes from RAW_CSV_PATH to CLEANED_CSV_PATH; main() removes the clean_data() call and its result check, calling preprocess_for_rag() directly.
Documentation
README.md, VERSIONS.md
README.md adds Redis to prerequisites, documents the caching section and .env variables, and updates the file structure list. VERSIONS.md prepends a v0.0.6 entry covering all feature and configuration changes.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant render_chat
  participant cache.py
  participant Retriever
  participant generation_chain

  rect rgba(135, 206, 235, 0.5)
    note over render_chat,cache.py: Cache lookup
    User->>render_chat: submit query
    render_chat->>render_chat: serialize chat_history_str
    render_chat->>cache.py: get_cached_answer(query, chat_history_str)
  end

  alt Cache hit
    cache.py-->>render_chat: cached answer
    render_chat-->>User: display cached answer (no LLM call)
  else Cache miss
    rect rgba(255, 165, 0, 0.5)
      note over render_chat,generation_chain: RAG + streaming generation
      render_chat->>Retriever: invoke(query) [reranker or base fallback]
      Retriever-->>render_chat: docs + refs_str
      render_chat->>generation_chain: stream(context, query, chat_history)
      generation_chain-->>render_chat: streamed chunks
      render_chat->>render_chat: extract_think_and_answer → final_answer_with_refs
      render_chat-->>User: display final answer
    end
    rect rgba(144, 238, 144, 0.5)
      note over render_chat,cache.py: Conditional cache store
      alt reranking did not fail
        render_chat->>cache.py: set_cached_answer(query, final_answer_with_refs, chat_history_str)
        cache.py->>cache.py: _normalize + SHA-256 key
        cache.py-->>render_chat: stored with CACHE_TTL
      end
    end
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Gyuho-Han/chatdds#3: Introduced extract_think_and_answer in app.py's streaming flow, which the current PR continues to rely on inside render_chat().
  • Gyuho-Han/chatdds#6: Established the refs_str / final_answer_with_refs assembly pattern in app.py that this PR extends by caching the assembled result.
  • Gyuho-Han/chatdds#7: The v0.0.5 baseline that last modified chain.py's PROMPT_TEMPLATE, init_generation_chain(), and retriever.py's embedding setup—all of which are further changed in this PR.

Poem

🐇 Hop, hop! A cache appears,
SHA-256 keys, no duplicate fears.
Gemini embeddings shine so bright,
CoT reasoning guides the light.
Redis stores each answer neat—
This bunny's work is quite complete! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v0.0.6

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Gyuho-Han
Gyuho-Han merged commit 25ed014 into main Jun 21, 2026
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant