kssrag 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kssrag-0.2.0 → kssrag-0.2.1}/PKG-INFO +2 -2
- {kssrag-0.2.0 → kssrag-0.2.1}/README.md +2 -2
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/core/agents.py +2 -1
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/models/openrouter.py +1 -1
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/server.py +19 -6
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag.egg-info/PKG-INFO +2 -2
- {kssrag-0.2.0 → kssrag-0.2.1}/setup.py +1 -1
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/__init__.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/cli.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/config.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/core/__init__.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/core/chunkers.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/core/retrievers.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/core/vectorstores.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/kssrag.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/models/__init__.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/models/local_llms.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/utils/__init__.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/utils/document_loaders.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/utils/helpers.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/utils/ocr.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/utils/ocr_loader.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/utils/preprocessors.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag.egg-info/SOURCES.txt +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag.egg-info/dependency_links.txt +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag.egg-info/entry_points.txt +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag.egg-info/requires.txt +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/kssrag.egg-info/top_level.txt +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/setup.cfg +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/tests/__init__.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/tests/test_basic.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/tests/test_bm25s.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/tests/test_config.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/tests/test_image_chunker.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/tests/test_integration.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/tests/test_ocr.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/tests/test_streaming.py +0 -0
- {kssrag-0.2.0 → kssrag-0.2.1}/tests/test_vectorstores.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kssrag
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: A flexible Retrieval-Augmented Generation framework by Ksschkw
|
|
5
5
|
Home-page: https://github.com/Ksschkw/kssrag
|
|
6
6
|
Author: Ksschkw
|
|
@@ -85,7 +85,7 @@ Dynamic: summary
|
|
|
85
85
|
|
|
86
86
|

|
|
87
87
|

|
|
88
|
-

|
|
89
89
|

|
|
90
90
|

|
|
91
91
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|

|
|
7
|
-

|
|
8
8
|

|
|
9
9
|

|
|
10
10
|
|
|
@@ -756,4 +756,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
756
756
|
|
|
757
757
|
[Get Started](#quick-start) • [Explore Features](#features) • [View Examples](#examples)
|
|
758
758
|
|
|
759
|
-
</div>
|
|
759
|
+
</div>
|
|
@@ -97,11 +97,12 @@ class RAGAgent:
|
|
|
97
97
|
|
|
98
98
|
# Stream response from LLM
|
|
99
99
|
if hasattr(self.llm, 'predict_stream'):
|
|
100
|
+
full_response = ""
|
|
100
101
|
for chunk in self.llm.predict_stream(messages):
|
|
102
|
+
full_response += chunk
|
|
101
103
|
yield chunk
|
|
102
104
|
|
|
103
105
|
# Add the complete response to conversation history
|
|
104
|
-
full_response = "".join([chunk for chunk in self.llm.predict_stream(messages)])
|
|
105
106
|
self.add_message("assistant", full_response)
|
|
106
107
|
else:
|
|
107
108
|
# Fallback to non-streaming
|
|
@@ -18,7 +18,7 @@ class OpenRouterLLM:
|
|
|
18
18
|
"Authorization": f"Bearer {self.api_key}",
|
|
19
19
|
"Content-Type": "application/json",
|
|
20
20
|
"HTTP-Referer": "https://github.com/Ksschkw/kssrag",
|
|
21
|
-
"X-Title": "
|
|
21
|
+
"X-Title": "KSSRAG"
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
def predict(self, messages: List[Dict[str, str]]) -> str:
|
|
@@ -28,9 +28,9 @@ class ServerConfig(BaseModel):
|
|
|
28
28
|
cors_allow_credentials: bool = config.CORS_ALLOW_CREDENTIALS
|
|
29
29
|
cors_allow_methods: List[str] = config.CORS_ALLOW_METHODS
|
|
30
30
|
cors_allow_headers: List[str] = config.CORS_ALLOW_HEADERS
|
|
31
|
-
title: str = "
|
|
32
|
-
description: str = "
|
|
33
|
-
version: str = "0.
|
|
31
|
+
title: str = "KSSSwagger"
|
|
32
|
+
description: str = "[kssrag](https://github.com/Ksschkw/kssrag)"
|
|
33
|
+
version: str = "0.2.0"
|
|
34
34
|
|
|
35
35
|
def create_app(rag_agent: RAGAgent, server_config: Optional[ServerConfig] = None):
|
|
36
36
|
"""Create a FastAPI app for the RAG agent with configurable CORS"""
|
|
@@ -98,20 +98,33 @@ def create_app(rag_agent: RAGAgent, server_config: Optional[ServerConfig] = None
|
|
|
98
98
|
raise HTTPException(status_code=400, detail="Query cannot be empty")
|
|
99
99
|
|
|
100
100
|
try:
|
|
101
|
+
# Get or create session - USE THE SAME LLM INSTANCE
|
|
101
102
|
if session_id not in sessions:
|
|
103
|
+
logger.info(f"Creating new streaming session: {session_id}")
|
|
104
|
+
# Use the same LLM configuration but enable streaming
|
|
102
105
|
sessions[session_id] = RAGAgent(
|
|
103
106
|
retriever=rag_agent.retriever,
|
|
104
|
-
llm=
|
|
107
|
+
llm=rag_agent.llm, # Use the same LLM instance
|
|
105
108
|
system_prompt=rag_agent.system_prompt
|
|
106
109
|
)
|
|
107
110
|
|
|
108
111
|
agent = sessions[session_id]
|
|
109
112
|
|
|
113
|
+
# Build messages using agent's conversation history
|
|
114
|
+
context_docs = agent.retriever.retrieve(query, top_k=5)
|
|
115
|
+
context = agent._build_context(context_docs)
|
|
116
|
+
messages = agent._build_messages(query, context)
|
|
117
|
+
|
|
110
118
|
async def generate():
|
|
119
|
+
full_response = ""
|
|
111
120
|
try:
|
|
112
|
-
|
|
121
|
+
# Use the agent's query_stream method instead of calling LLM directly
|
|
122
|
+
for chunk in agent.query_stream(query, top_k=5):
|
|
123
|
+
full_response += chunk
|
|
113
124
|
yield f"data: {json.dumps({'chunk': chunk, 'done': False})}\n\n"
|
|
125
|
+
|
|
114
126
|
yield f"data: {json.dumps({'chunk': '', 'done': True})}\n\n"
|
|
127
|
+
|
|
115
128
|
except Exception as e:
|
|
116
129
|
logger.error(f"Streaming error: {str(e)}")
|
|
117
130
|
yield f"data: {json.dumps({'error': str(e), 'done': True})}\n\n"
|
|
@@ -156,7 +169,7 @@ def create_app(rag_agent: RAGAgent, server_config: Optional[ServerConfig] = None
|
|
|
156
169
|
async def root():
|
|
157
170
|
"""Root endpoint with API information"""
|
|
158
171
|
return {
|
|
159
|
-
"message": "Welcome to
|
|
172
|
+
"message": "Welcome to KSSRAG API",
|
|
160
173
|
"version": server_config.version,
|
|
161
174
|
"docs": "/docs",
|
|
162
175
|
"health": "/health"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kssrag
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: A flexible Retrieval-Augmented Generation framework by Ksschkw
|
|
5
5
|
Home-page: https://github.com/Ksschkw/kssrag
|
|
6
6
|
Author: Ksschkw
|
|
@@ -85,7 +85,7 @@ Dynamic: summary
|
|
|
85
85
|
|
|
86
86
|

|
|
87
87
|

|
|
88
|
-

|
|
89
89
|

|
|
90
90
|

|
|
91
91
|
|
|
@@ -6,7 +6,7 @@ long_description = (here / "README.md").read_text(encoding="utf-8")
|
|
|
6
6
|
|
|
7
7
|
setup(
|
|
8
8
|
name="kssrag",
|
|
9
|
-
version="0.2.
|
|
9
|
+
version="0.2.1",
|
|
10
10
|
description="A flexible Retrieval-Augmented Generation framework by Ksschkw",
|
|
11
11
|
long_description=long_description,
|
|
12
12
|
long_description_content_type="text/markdown",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|