Commit ·
9933b92
1
Parent(s): df70a57
license
Browse files- LICENSE +21 -0
- models/README.md +0 -16
- multi_doc_chat/logger/__init__.py +0 -9
- multi_doc_chat/logger/cutom_logger.py +0 -42
- multi_doc_chat/prompts/__init__.py +0 -0
- multi_doc_chat/prompts/prompt_library.py +0 -32
- templates/index.html +1 -1
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2025 (https://github.com/LeonardoMdSACode)
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
models/README.md
DELETED
|
@@ -1,16 +0,0 @@
|
|
| 1 |
-
# models/
|
| 2 |
-
|
| 3 |
-
This directory should hold local model weights for running inference without cloud APIs.
|
| 4 |
-
|
| 5 |
-
Recommended:
|
| 6 |
-
- small quantized ggml/gguf models for llama-cpp (7B q4_0 or smaller) placed as:
|
| 7 |
-
models/ggml-model-q4_0.bin
|
| 8 |
-
|
| 9 |
-
Where to get models:
|
| 10 |
-
- Search Hugging Face for "ggml" or "gguf" builds (TheBloke has many community builds).
|
| 11 |
-
- Always check license/usage terms before downloading.
|
| 12 |
-
|
| 13 |
-
Note: large model files should not be committed to the repo. Add them to `.gitignore`:
|
| 14 |
-
|
| 15 |
-
models/*
|
| 16 |
-
!models/README.md
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
multi_doc_chat/logger/__init__.py
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
|
| 2 |
-
from .cutom_logger import CustomLogger as _CustomLogger # backward compat
|
| 3 |
-
try:
|
| 4 |
-
from .cutom_logger import CustomLogger
|
| 5 |
-
except Exception:
|
| 6 |
-
CustomLogger = _CustomLogger
|
| 7 |
-
|
| 8 |
-
# Expose a global structlog-style logger used across the codebase
|
| 9 |
-
GLOBAL_LOGGER = CustomLogger().get_logger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
multi_doc_chat/logger/cutom_logger.py
DELETED
|
@@ -1,42 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import logging
|
| 3 |
-
from datetime import datetime
|
| 4 |
-
import structlog
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
class CustomLogger:
|
| 8 |
-
def __init__(self, log_dir="logs"):
|
| 9 |
-
self.logs_dir = os.path.join(os.getcwd(), log_dir)
|
| 10 |
-
os.makedirs(self.logs_dir, exist_ok=True)
|
| 11 |
-
log_file = f"{datetime.now().strftime('%m_%d_%Y_%H_%M_%S')}.log"
|
| 12 |
-
self.log_file_path = os.path.join(self.logs_dir, log_file)
|
| 13 |
-
|
| 14 |
-
def get_logger(self, name=__file__):
|
| 15 |
-
logger_name = os.path.basename(name)
|
| 16 |
-
|
| 17 |
-
file_handler = logging.FileHandler(self.log_file_path)
|
| 18 |
-
file_handler.setLevel(logging.INFO)
|
| 19 |
-
file_handler.setFormatter(logging.Formatter("%(message)s"))
|
| 20 |
-
|
| 21 |
-
console_handler = logging.StreamHandler()
|
| 22 |
-
console_handler.setLevel(logging.INFO)
|
| 23 |
-
console_handler.setFormatter(logging.Formatter("%(message)s"))
|
| 24 |
-
|
| 25 |
-
logging.basicConfig(
|
| 26 |
-
level=logging.INFO,
|
| 27 |
-
format="%(message)s",
|
| 28 |
-
handlers=[console_handler, file_handler]
|
| 29 |
-
)
|
| 30 |
-
|
| 31 |
-
structlog.configure(
|
| 32 |
-
processors=[
|
| 33 |
-
structlog.processors.TimeStamper(fmt="iso", utc=True, key="timestamp"),
|
| 34 |
-
structlog.processors.add_log_level,
|
| 35 |
-
structlog.processors.EventRenamer(to="event"),
|
| 36 |
-
structlog.processors.JSONRenderer()
|
| 37 |
-
],
|
| 38 |
-
logger_factory=structlog.stdlib.LoggerFactory(),
|
| 39 |
-
cache_logger_on_first_use=True,
|
| 40 |
-
)
|
| 41 |
-
|
| 42 |
-
return structlog.get_logger(logger_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
multi_doc_chat/prompts/__init__.py
DELETED
|
File without changes
|
multi_doc_chat/prompts/prompt_library.py
DELETED
|
@@ -1,32 +0,0 @@
|
|
| 1 |
-
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
| 2 |
-
|
| 3 |
-
contextualize_question_prompt = ChatPromptTemplate.from_messages([
|
| 4 |
-
("system", (
|
| 5 |
-
"Given a conversation history and the most recent user query, rewrite the query as a standalone question "
|
| 6 |
-
"that makes sense without relying on the previous context. Do not provide an answer—only reformulate the "
|
| 7 |
-
"question if necessary; otherwise, return it unchanged."
|
| 8 |
-
)),
|
| 9 |
-
MessagesPlaceholder("chat_history"),
|
| 10 |
-
("human", "{input}"),
|
| 11 |
-
])
|
| 12 |
-
|
| 13 |
-
# Prompt for answering based on context
|
| 14 |
-
context_qa_prompt = ChatPromptTemplate.from_messages([
|
| 15 |
-
("system", (
|
| 16 |
-
"You are an assistant designed to answer questions using the provided context. Rely only on the retrieved "
|
| 17 |
-
"information to form your response. If the answer is not found in the context, respond with 'I don't know.' "
|
| 18 |
-
"Keep your answer concise and no longer than three sentences.\n\n{context}"
|
| 19 |
-
)),
|
| 20 |
-
MessagesPlaceholder("chat_history"),
|
| 21 |
-
("human", "{input}"),
|
| 22 |
-
])
|
| 23 |
-
|
| 24 |
-
# Central dictionary to register prompts
|
| 25 |
-
PROMPT_REGISTRY = {
|
| 26 |
-
"contextualize_question": contextualize_question_prompt,
|
| 27 |
-
"context_qa": context_qa_prompt,
|
| 28 |
-
}
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
## 1. Hello thier i want to study about RAG
|
| 32 |
-
## 2. what is the full form of it
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/index.html
CHANGED
|
@@ -125,7 +125,7 @@
|
|
| 125 |
</head>
|
| 126 |
<body>
|
| 127 |
<header>
|
| 128 |
-
<h1>
|
| 129 |
</header>
|
| 130 |
|
| 131 |
<main>
|
|
|
|
| 125 |
</head>
|
| 126 |
<body>
|
| 127 |
<header>
|
| 128 |
+
<h1>RAG Solution</h1>
|
| 129 |
</header>
|
| 130 |
|
| 131 |
<main>
|