Commit 7d5d9e73 authored by Your Name's avatar Your Name

Add condensation enhancements and server configuration

- Add max_context field to CondensationConfig
- Support 'internal' keyword for local HuggingFace model in condensation
- Add internal model initialization with temperature=0.3, top_p=0.8, repeat_penalty=1.1
- Create condensation system prompts (conversational, semantic)
- Add aisbf.json for server configuration (host, port, dashboard auth)
- Update main.py to read server config from aisbf.json
- Update providers.json with max_context example for condensation
parent 1ea22adb
......@@ -41,6 +41,7 @@ class CondensationConfig(BaseModel):
model: Optional[str] = None
rotation_id: Optional[str] = None
enabled: bool = True
max_context: Optional[int] = None # Maximum context size for condensation model
class ProviderConfig(BaseModel):
......
This diff is collapsed.
{
"server": {
"host": "0.0.0.0",
"port": 8000
},
"dashboard": {
"enabled": true,
"username": "admin",
"password": "admin"
},
"internal_model": {
"model_id": "huihui-ai/Qwen2.5-0.5B-Instruct-abliterated-v3"
}
}
# Conversational Context Condensation
You are a specialized AI assistant for context condensation. Your task is to create a concise, high-density summary of conversation history while preserving all critical information.
## Your Role
You will receive a conversation history between a user and an AI assistant. Your job is to:
1. **Identify Key Information**: Extract facts, decisions, goals, and important context
2. **Preserve Continuity**: Maintain the logical flow and relationships between topics
3. **Compress Efficiently**: Remove redundancy while keeping essential details
4. **Maintain Accuracy**: Never invent or hallucinate information
## Guidelines
- Focus on **actionable information** and **decisions made**
- Include **technical details** that may be referenced later
- Preserve **user preferences** and **constraints** mentioned
- Keep **error messages** and **solutions** that were discussed
- Maintain **chronological order** when relevant
- Use **clear, concise language**
## Output Format
Provide a structured summary that includes:
- Current goal or task
- Key facts and context
- Decisions made
- Important technical details
- Any constraints or preferences
Keep the summary comprehensive but concise. Aim for maximum information density.
# Semantic Context Pruning
You are a specialized AI assistant for semantic context pruning. Your task is to extract only the information that is directly relevant to the current query or task.
## Your Role
You will receive:
1. A conversation history
2. A current query or task description
Your job is to identify and extract ONLY the information from the conversation that is relevant to answering or completing the current query/task.
## Guidelines
- **Be Selective**: Remove all information that doesn't directly relate to the current query
- **Preserve Dependencies**: Keep information that provides necessary context for understanding relevant parts
- **Maintain Accuracy**: Never modify or invent information
- **Focus on Recency**: Prioritize recent information over older information when both are relevant
- **Keep Technical Details**: Preserve specific technical information (code, commands, configurations) that may be needed
## What to Keep
- Facts directly related to the current query
- Technical details needed to answer the query
- Recent decisions that affect the current task
- Error messages or issues being addressed
- Constraints or requirements mentioned
## What to Remove
- Unrelated conversations or topics
- Resolved issues that don't affect current task
- Redundant information
- Off-topic discussions
- Historical context not needed for current query
## Output Format
Provide a concise extraction of relevant information. Structure it logically, grouping related facts together. Be ruthlessly efficient - if information isn't needed for the current query, don't include it.
......@@ -2,7 +2,8 @@
"condensation": {
"provider_id": "gemini",
"model": "gemini-1.5-flash",
"enabled": true
"enabled": true,
"max_context": 8000
},
"providers": {
"gemini": {
......
......@@ -38,6 +38,51 @@ from logging.handlers import RotatingFileHandler
from datetime import datetime, timedelta
from collections import defaultdict
from pathlib import Path
import json
def load_server_config():
"""Load server configuration from aisbf.json"""
# Try user config first
config_path = Path.home() / '.aisbf' / 'aisbf.json'
if not config_path.exists():
# Try installed locations
installed_dirs = [
Path('/usr/share/aisbf'),
Path.home() / '.local' / 'share' / 'aisbf',
]
for installed_dir in installed_dirs:
test_path = installed_dir / 'aisbf.json'
if test_path.exists():
config_path = test_path
break
else:
# Fallback to source tree config directory
source_dir = Path(__file__).parent / 'config'
test_path = source_dir / 'aisbf.json'
if test_path.exists():
config_path = test_path
# Load config or use defaults
if config_path.exists():
try:
with open(config_path) as f:
config_data = json.load(f)
server_config = config_data.get('server', {})
return {
'host': server_config.get('host', '0.0.0.0'),
'port': server_config.get('port', 8000)
}
except Exception as e:
logger = logging.getLogger(__name__)
logger.warning(f"Error loading aisbf.json: {e}, using defaults")
# Return defaults
return {
'host': '0.0.0.0',
'port': 8000
}
class BrokenPipeFilter(logging.Filter):
"""Filter to suppress BrokenPipeError logging errors"""
......@@ -533,8 +578,14 @@ async def catch_all_post(provider_id: str, request: Request):
def main():
"""Main entry point for the AISBF server"""
import uvicorn
logger.info("Starting AI Proxy Server on http://127.0.0.1:17765")
uvicorn.run(app, host="127.0.0.1", port=17765)
# Load server configuration
server_config = load_server_config()
host = server_config['host']
port = server_config['port']
logger.info(f"Starting AI Proxy Server on http://{host}:{port}")
uvicorn.run(app, host=host, port=port)
if __name__ == "__main__":
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment