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.
Files changed (38) hide show
  1. {kssrag-0.2.0 → kssrag-0.2.1}/PKG-INFO +2 -2
  2. {kssrag-0.2.0 → kssrag-0.2.1}/README.md +2 -2
  3. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/core/agents.py +2 -1
  4. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/models/openrouter.py +1 -1
  5. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/server.py +19 -6
  6. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag.egg-info/PKG-INFO +2 -2
  7. {kssrag-0.2.0 → kssrag-0.2.1}/setup.py +1 -1
  8. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/__init__.py +0 -0
  9. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/cli.py +0 -0
  10. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/config.py +0 -0
  11. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/core/__init__.py +0 -0
  12. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/core/chunkers.py +0 -0
  13. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/core/retrievers.py +0 -0
  14. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/core/vectorstores.py +0 -0
  15. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/kssrag.py +0 -0
  16. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/models/__init__.py +0 -0
  17. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/models/local_llms.py +0 -0
  18. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/utils/__init__.py +0 -0
  19. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/utils/document_loaders.py +0 -0
  20. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/utils/helpers.py +0 -0
  21. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/utils/ocr.py +0 -0
  22. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/utils/ocr_loader.py +0 -0
  23. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag/utils/preprocessors.py +0 -0
  24. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag.egg-info/SOURCES.txt +0 -0
  25. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag.egg-info/dependency_links.txt +0 -0
  26. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag.egg-info/entry_points.txt +0 -0
  27. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag.egg-info/requires.txt +0 -0
  28. {kssrag-0.2.0 → kssrag-0.2.1}/kssrag.egg-info/top_level.txt +0 -0
  29. {kssrag-0.2.0 → kssrag-0.2.1}/setup.cfg +0 -0
  30. {kssrag-0.2.0 → kssrag-0.2.1}/tests/__init__.py +0 -0
  31. {kssrag-0.2.0 → kssrag-0.2.1}/tests/test_basic.py +0 -0
  32. {kssrag-0.2.0 → kssrag-0.2.1}/tests/test_bm25s.py +0 -0
  33. {kssrag-0.2.0 → kssrag-0.2.1}/tests/test_config.py +0 -0
  34. {kssrag-0.2.0 → kssrag-0.2.1}/tests/test_image_chunker.py +0 -0
  35. {kssrag-0.2.0 → kssrag-0.2.1}/tests/test_integration.py +0 -0
  36. {kssrag-0.2.0 → kssrag-0.2.1}/tests/test_ocr.py +0 -0
  37. {kssrag-0.2.0 → kssrag-0.2.1}/tests/test_streaming.py +0 -0
  38. {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.0
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
  ![Python Version](https://img.shields.io/badge/python-3.8%2B-blue)
87
87
  ![License](https://img.shields.io/badge/license-MIT-green)
88
- ![Version](https://img.shields.io/badge/version-0.1.30-brightgreen)
88
+ ![Version](https://img.shields.io/badge/version-0.2.0-brightgreen)
89
89
  ![Framework](https://img.shields.io/badge/framework-RAG-orange)
90
90
  ![Documentation](https://img.shields.io/badge/docs-comprehensive-brightgreen)
91
91
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  ![Python Version](https://img.shields.io/badge/python-3.8%2B-blue)
6
6
  ![License](https://img.shields.io/badge/license-MIT-green)
7
- ![Version](https://img.shields.io/badge/version-0.1.30-brightgreen)
7
+ ![Version](https://img.shields.io/badge/version-0.2.0-brightgreen)
8
8
  ![Framework](https://img.shields.io/badge/framework-RAG-orange)
9
9
  ![Documentation](https://img.shields.io/badge/docs-comprehensive-brightgreen)
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": "KSS RAG Agent"
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 = "KSS RAG API"
32
- description: str = "A Retrieval-Augmented Generation API by Ksschkw"
33
- version: str = "0.1.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=OpenRouterLLM(stream=True),
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
- for chunk in agent.llm.predict_stream(agent._build_messages(query)):
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 KSS RAG API",
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.0
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
  ![Python Version](https://img.shields.io/badge/python-3.8%2B-blue)
87
87
  ![License](https://img.shields.io/badge/license-MIT-green)
88
- ![Version](https://img.shields.io/badge/version-0.1.30-brightgreen)
88
+ ![Version](https://img.shields.io/badge/version-0.2.0-brightgreen)
89
89
  ![Framework](https://img.shields.io/badge/framework-RAG-orange)
90
90
  ![Documentation](https://img.shields.io/badge/docs-comprehensive-brightgreen)
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.0",
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