Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
cleanup
Browse files- README.md +37 -7
- params.cfg +1 -1
README.md
CHANGED
|
@@ -148,28 +148,58 @@ Abstraction layer for managing different retriever configurations:
|
|
| 148 |
|
| 149 |
Helper functions
|
| 150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
## Configuration
|
| 152 |
|
| 153 |
### Configuration File (`params.cfg`)
|
| 154 |
|
| 155 |
```ini
|
| 156 |
[file_processing]
|
| 157 |
-
#
|
|
|
|
|
|
|
|
|
|
| 158 |
DIRECT_OUTPUT = True
|
| 159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
[retriever]
|
| 161 |
-
RETRIEVER = https://
|
| 162 |
-
|
|
|
|
| 163 |
|
| 164 |
[generator]
|
| 165 |
-
GENERATOR = https://
|
| 166 |
|
| 167 |
[ingestor]
|
| 168 |
-
INGESTOR = https://
|
| 169 |
|
| 170 |
[general]
|
| 171 |
-
#
|
| 172 |
-
MAX_CONTEXT_CHARS = 15000
|
| 173 |
```
|
| 174 |
|
| 175 |
### Environment Variables
|
|
|
|
| 148 |
|
| 149 |
Helper functions
|
| 150 |
|
| 151 |
+
#### Conversation Context Management
|
| 152 |
+
|
| 153 |
+
The `build_conversation_context()` function manages conversation history to provide relevant context to the generator while respecting token limits and conversation flow.
|
| 154 |
+
|
| 155 |
+
**Key Features:**
|
| 156 |
+
|
| 157 |
+
- **Context Selection**: Always includes the first user and assistant messages to maintain conversation context
|
| 158 |
+
- **Recent Turn Limiting**: Includes only the last N complete turns (user + assistant pairs) to focus on recent conversation (default: 3)
|
| 159 |
+
- **Character Limit Management**: Truncates to maximum character limits to prevent context overflow
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
**Function Parameters:**
|
| 163 |
+
|
| 164 |
+
```python
|
| 165 |
+
def build_conversation_context(
|
| 166 |
+
messages, # List of Message objects from conversation
|
| 167 |
+
max_turns: int = 3, # Maximum number of recent turns to include
|
| 168 |
+
max_chars: int = 8000 # Maximum total characters in context
|
| 169 |
+
) -> str
|
| 170 |
+
```
|
| 171 |
+
|
| 172 |
## Configuration
|
| 173 |
|
| 174 |
### Configuration File (`params.cfg`)
|
| 175 |
|
| 176 |
```ini
|
| 177 |
[file_processing]
|
| 178 |
+
# Enable direct output mode: when True, ingestor results are returned directly
|
| 179 |
+
# without going through the generator. When False, all files go through full RAG pipeline.
|
| 180 |
+
# This also prevents ChatUI from resending the file in the conversation history with each turn
|
| 181 |
+
# Note: File type validation is handled by the ChatUI frontend
|
| 182 |
DIRECT_OUTPUT = True
|
| 183 |
|
| 184 |
+
[conversation_history]
|
| 185 |
+
# Limit the context window for the conversation history
|
| 186 |
+
MAX_TURNS = 3
|
| 187 |
+
MAX_CHARS = 12000
|
| 188 |
+
|
| 189 |
[retriever]
|
| 190 |
+
RETRIEVER = https://giz-chatfed-retriever0-3.hf.space/
|
| 191 |
+
# Optional
|
| 192 |
+
COLLECTION_NAME = EUDR
|
| 193 |
|
| 194 |
[generator]
|
| 195 |
+
GENERATOR = https://giz-eudr-chabo-generator.hf.space
|
| 196 |
|
| 197 |
[ingestor]
|
| 198 |
+
INGESTOR = https://giz-eudr-chabo-ingestor.hf.space
|
| 199 |
|
| 200 |
[general]
|
| 201 |
+
# need to include this for HF inference endpoint limits
|
| 202 |
+
MAX_CONTEXT_CHARS = 15000
|
| 203 |
```
|
| 204 |
|
| 205 |
### Environment Variables
|
params.cfg
CHANGED
|
@@ -8,7 +8,7 @@ DIRECT_OUTPUT = True
|
|
| 8 |
[conversation_history]
|
| 9 |
# Limit the context window for the conversation history
|
| 10 |
MAX_TURNS = 3
|
| 11 |
-
MAX_CHARS =
|
| 12 |
|
| 13 |
[retriever]
|
| 14 |
RETRIEVER = https://giz-chatfed-retriever0-3.hf.space/
|
|
|
|
| 8 |
[conversation_history]
|
| 9 |
# Limit the context window for the conversation history
|
| 10 |
MAX_TURNS = 3
|
| 11 |
+
MAX_CHARS = 12000
|
| 12 |
|
| 13 |
[retriever]
|
| 14 |
RETRIEVER = https://giz-chatfed-retriever0-3.hf.space/
|