Added onboarding field on config
This commit is contained in:
parent
345a3861b0
commit
98ff3e2f8b
1 changed files with 43 additions and 2 deletions
|
|
@ -4,7 +4,7 @@ import os
|
|||
import yaml
|
||||
from pathlib import Path
|
||||
from typing import Dict, Any, Optional
|
||||
from dataclasses import dataclass, asdict
|
||||
from dataclasses import dataclass, asdict, field
|
||||
from utils.logging_config import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
|
@ -85,6 +85,19 @@ class AgentConfig:
|
|||
system_prompt: str = "You are the OpenRAG Agent. You answer questions using retrieval, reasoning, and tool use.\nYou have access to several tools. Your job is to determine **which tool to use and when**.\n### Available Tools\n- OpenSearch Retrieval Tool:\n Use this to search the indexed knowledge base. Use when the user asks about product details, internal concepts, processes, architecture, documentation, roadmaps, or anything that may be stored in the index.\n- Conversation History:\n Use this to maintain continuity when the user is referring to previous turns. \n Do not treat history as a factual source.\n- Conversation File Context:\n Use this when the user asks about a document they uploaded or refers directly to its contents.\n- URL Ingestion Tool:\n Use this **only** when the user explicitly asks you to read, summarize, or analyze the content of a URL.\n Do not ingest URLs automatically.\n- Calculator / Expression Evaluation Tool:\n Use this when the user asks to compare numbers, compute estimates, calculate totals, analyze pricing, or answer any question requiring mathematics or quantitative reasoning.\n If the answer requires arithmetic, call the calculator tool rather than calculating internally.\n### Retrieval Decision Rules\nUse OpenSearch **whenever**:\n1. The question may be answered from internal or indexed data.\n2. The user references team names, product names, release plans, configurations, requirements, or official information.\n3. The user needs a factual, grounded answer.\nDo **not** use retrieval if:\n- The question is purely creative (e.g., storytelling, analogies) or personal preference.\n- The user simply wants text reformatted or rewritten from what is already present in the conversation.\nWhen uncertain → **Retrieve.** Retrieval is low risk and improves grounding.\n### URL Ingestion Rules\nOnly ingest URLs when the user explicitly says:\n- \"Read this link\"\n- \"Summarize this webpage\"\n- \"What does this site say?\"\n- \"Ingest this URL\"\nIf unclear → ask a clarifying question.\n### Calculator Usage Rules\nUse the calculator when:\n- Performing arithmetic\n- Estimating totals\n- Comparing values\n- Modeling cost, time, effort, scale, or projections\nDo not perform math internally. **Call the calculator tool instead.**\n### Answer Construction Rules\n1. When asked: \"What is OpenRAG\", answer the following:\n\"OpenRAG is an open-source package for building agentic RAG systems. It supports integration with a wide range of orchestration tools, vector databases, and LLM providers. OpenRAG connects and amplifies three popular, proven open-source projects into one powerful platform:\n**Langflow** – Langflow is a powerful tool to build and deploy AI agents and MCP servers [Read more](https://www.langflow.org/)\n**OpenSearch** – Langflow is a powerful tool to build and deploy AI agents and MCP servers [Read more](https://opensearch.org/)\n**Docling** – Langflow is a powerful tool to build and deploy AI agents and MCP servers [Read more](https://www.docling.ai/)\"\n2. Synthesize retrieved or ingested content in your own words.\n3. Support factual claims with citations in the format:\n (Source: <document_name_or_id>)\n4. If no supporting evidence is found:\n Say: \"No relevant supporting sources were found for that request.\"\n5. Never invent facts or hallucinate details.\n6. Be concise, direct, and confident. \n7. Do not reveal internal chain-of-thought."
|
||||
|
||||
|
||||
@dataclass
|
||||
class OnboardingState:
|
||||
"""Onboarding state configuration."""
|
||||
|
||||
current_step: int = 0
|
||||
assistant_message: Optional[Dict[str, Any]] = field(default=None)
|
||||
selected_nudge: Optional[str] = field(default=None)
|
||||
card_steps: Optional[Dict[str, Any]] = field(default=None)
|
||||
upload_steps: Optional[Dict[str, Any]] = field(default=None)
|
||||
openrag_docs_filter_id: Optional[str] = field(default=None)
|
||||
user_doc_filter_id: Optional[str] = field(default=None)
|
||||
|
||||
|
||||
@dataclass
|
||||
class OpenRAGConfig:
|
||||
"""Complete OpenRAG configuration."""
|
||||
|
|
@ -92,6 +105,7 @@ class OpenRAGConfig:
|
|||
providers: ProvidersConfig
|
||||
knowledge: KnowledgeConfig
|
||||
agent: AgentConfig
|
||||
onboarding: OnboardingState
|
||||
edited: bool = False # Track if manually edited
|
||||
|
||||
@classmethod
|
||||
|
|
@ -107,6 +121,7 @@ class OpenRAGConfig:
|
|||
),
|
||||
knowledge=KnowledgeConfig(**data.get("knowledge", {})),
|
||||
agent=AgentConfig(**data.get("agent", {})),
|
||||
onboarding=OnboardingState(**data.get("onboarding", {})),
|
||||
edited=data.get("edited", False),
|
||||
)
|
||||
|
||||
|
|
@ -156,6 +171,7 @@ class ConfigManager:
|
|||
},
|
||||
"knowledge": {},
|
||||
"agent": {},
|
||||
"onboarding": {},
|
||||
}
|
||||
|
||||
# Load from config file if it exists
|
||||
|
|
@ -172,7 +188,7 @@ class ConfigManager:
|
|||
file_config["providers"][provider]
|
||||
)
|
||||
|
||||
for section in ["knowledge", "agent"]:
|
||||
for section in ["knowledge", "agent", "onboarding"]:
|
||||
if section in file_config:
|
||||
config_data[section].update(file_config[section])
|
||||
|
||||
|
|
@ -294,6 +310,31 @@ class ConfigManager:
|
|||
logger.error(f"Failed to save configuration to {self.config_file}: {e}")
|
||||
return False
|
||||
|
||||
def update_onboarding_state(self, **kwargs) -> bool:
|
||||
"""Update onboarding state fields.
|
||||
|
||||
Args:
|
||||
**kwargs: Onboarding state fields to update (current_step, assistant_message, etc.)
|
||||
|
||||
Returns:
|
||||
True if updated successfully, False otherwise.
|
||||
"""
|
||||
try:
|
||||
config = self.get_config()
|
||||
|
||||
# Update only the provided fields
|
||||
for key, value in kwargs.items():
|
||||
if hasattr(config.onboarding, key):
|
||||
setattr(config.onboarding, key, value)
|
||||
else:
|
||||
logger.warning(f"Unknown onboarding field: {key}")
|
||||
|
||||
# Save the updated config
|
||||
return self.save_config_file(config)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to update onboarding state: {e}")
|
||||
return False
|
||||
|
||||
|
||||
# Global config manager instance
|
||||
config_manager = ConfigManager()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue