| from typing import Dict, Optional, List |
| from dataclasses import dataclass |
| from haystack.dataclasses import ChatMessage |
| import os |
| import logging |
|
|
| logger = logging.getLogger(__name__) |
|
|
| def load_prompt_template(filename: str) -> str: |
| """Load prompt template from txt file.""" |
| prompt_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "prompts", filename) |
| logger.info(f"Loading prompt template: {filename} from {prompt_path}") |
| with open(prompt_path, "r", encoding="utf-8") as f: |
| content = f.read().strip() |
| logger.info(f"✅ Successfully loaded prompt template: {filename} ({len(content)} chars)") |
| return content |
|
|
| @dataclass |
| class DatasetConfig: |
| name: str |
| split: str = "train" |
| content_field: str = "content" |
| fields: Optional[Dict[str, str]] = None |
| prompt_template: Optional[str] = None |
|
|
| |
| DATASET_CONFIGS = { |
| "awesome-chatgpt-prompts": DatasetConfig( |
| name="fka/awesome-chatgpt-prompts", |
| content_field="prompt", |
| fields={ |
| "role": "act", |
| "prompt": "prompt" |
| }, |
| prompt_template=load_prompt_template("awesome-chatgpt-prompts.txt") |
| ), |
| "settings-dataset": DatasetConfig( |
| name="syntaxhacker/rag_pipeline", |
| content_field="context", |
| fields={ |
| "question": "question", |
| "answer": "answer", |
| "context": "context" |
| }, |
| prompt_template=load_prompt_template("settings-dataset.txt") |
| ), |
| "seven-wonders": DatasetConfig( |
| name="bilgeyucel/seven-wonders", |
| content_field="content", |
| fields={}, |
| prompt_template=load_prompt_template("seven-wonders.txt") |
| ), |
| "psychology-dataset": DatasetConfig( |
| name="jkhedri/psychology-dataset", |
| split="train", |
| content_field="question", |
| fields={ |
| "response_j": "response_j", |
| "response_k": "response_k" |
| }, |
| prompt_template=load_prompt_template("psychology-dataset.txt") |
| ), |
| "developer-portfolio": DatasetConfig( |
| name="syntaxhacker/developer-portfolio-rag", |
| split="train", |
| content_field="answer", |
| fields={ |
| "question": "question", |
| "answer": "answer", |
| "context": "context" |
| }, |
| prompt_template=load_prompt_template("developer-portfolio.txt") |
| ), |
| } |
|
|
| |
| MODEL_CONFIG = { |
| "embedding_model": "Xenova/all-MiniLM-L6-v2", |
| "use_onnx": True, |
| } |
|
|