Spaces:
Paused
Paused
Update config_provider.py
Browse files- config_provider.py +45 -3
config_provider.py
CHANGED
|
@@ -8,11 +8,45 @@ from pathlib import Path
|
|
| 8 |
from typing import Any, Dict, List, Optional, Union
|
| 9 |
from datetime import datetime
|
| 10 |
import commentjson
|
| 11 |
-
|
| 12 |
from utils import log
|
| 13 |
-
from pydantic import BaseModel, Field, HttpUrl, ValidationError, field_validator
|
| 14 |
from encryption_utils import decrypt
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
class GlobalConfig(BaseModel):
|
| 17 |
work_mode: str = Field("hfcloud", pattern=r"^(hfcloud|cloud|on-premise|gpt4o|gpt4o-mini)$")
|
| 18 |
cloud_token: Optional[str] = None
|
|
@@ -39,7 +73,9 @@ class GlobalConfig(BaseModel):
|
|
| 39 |
"enable_punctuation": True,
|
| 40 |
"interim_results": True
|
| 41 |
})
|
| 42 |
-
|
|
|
|
|
|
|
| 43 |
users: List["UserConfig"] = []
|
| 44 |
|
| 45 |
def is_gpt_mode(self) -> bool:
|
|
@@ -369,6 +405,12 @@ class ConfigProvider:
|
|
| 369 |
'enable_punctuation': True,
|
| 370 |
'interim_results': True
|
| 371 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 372 |
config_section.setdefault('users', [])
|
| 373 |
|
| 374 |
# Convert string body/headers to dict if needed
|
|
|
|
| 8 |
from typing import Any, Dict, List, Optional, Union
|
| 9 |
from datetime import datetime
|
| 10 |
import commentjson
|
|
|
|
| 11 |
from utils import log
|
| 12 |
+
from pydantic import BaseModel, Field, HttpUrl, ValidationError, field_validator, validator
|
| 13 |
from encryption_utils import decrypt
|
| 14 |
|
| 15 |
+
# ---------------- Parameter Collection Config ---------
|
| 16 |
+
class ParameterCollectionConfig(BaseModel):
|
| 17 |
+
"""Configuration for smart parameter collection"""
|
| 18 |
+
max_params_per_question: int = Field(default=2, ge=1, le=5)
|
| 19 |
+
smart_grouping: bool = Field(default=True)
|
| 20 |
+
retry_unanswered: bool = Field(default=True)
|
| 21 |
+
collection_prompt: str = Field(default="""
|
| 22 |
+
You are a helpful assistant collecting information from the user.
|
| 23 |
+
|
| 24 |
+
Conversation context:
|
| 25 |
+
{{conversation_history}}
|
| 26 |
+
|
| 27 |
+
Intent: {{intent_name}} - {{intent_caption}}
|
| 28 |
+
|
| 29 |
+
Already collected:
|
| 30 |
+
{{collected_params}}
|
| 31 |
+
|
| 32 |
+
Still needed:
|
| 33 |
+
{{missing_params}}
|
| 34 |
+
|
| 35 |
+
Previously asked but not answered:
|
| 36 |
+
{{unanswered_params}}
|
| 37 |
+
|
| 38 |
+
Rules:
|
| 39 |
+
1. Ask for maximum {{max_params}} parameters in one question
|
| 40 |
+
2. Group parameters that naturally go together (like from/to cities, dates)
|
| 41 |
+
3. If some parameters were asked before but not answered, include them again
|
| 42 |
+
4. Be natural and conversational in {{project_language}}
|
| 43 |
+
5. Use context from the conversation to make the question flow naturally
|
| 44 |
+
|
| 45 |
+
Generate ONLY the question, nothing else.""")
|
| 46 |
+
|
| 47 |
+
class Config:
|
| 48 |
+
extra = "allow"
|
| 49 |
+
|
| 50 |
class GlobalConfig(BaseModel):
|
| 51 |
work_mode: str = Field("hfcloud", pattern=r"^(hfcloud|cloud|on-premise|gpt4o|gpt4o-mini)$")
|
| 52 |
cloud_token: Optional[str] = None
|
|
|
|
| 73 |
"enable_punctuation": True,
|
| 74 |
"interim_results": True
|
| 75 |
})
|
| 76 |
+
|
| 77 |
+
parameter_collection_config: ParameterCollectionConfig = Field(default_factory=ParameterCollectionConfig)
|
| 78 |
+
|
| 79 |
users: List["UserConfig"] = []
|
| 80 |
|
| 81 |
def is_gpt_mode(self) -> bool:
|
|
|
|
| 405 |
'enable_punctuation': True,
|
| 406 |
'interim_results': True
|
| 407 |
})
|
| 408 |
+
|
| 409 |
+
pcc = config_data['config'].get('parameter_collection_config')
|
| 410 |
+
if pcc is None:
|
| 411 |
+
# Yoksa default değerlerle ekle
|
| 412 |
+
config_data['config']['parameter_collection_config'] = ParameterCollectionConfig()
|
| 413 |
+
|
| 414 |
config_section.setdefault('users', [])
|
| 415 |
|
| 416 |
# Convert string body/headers to dict if needed
|