Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ from langfuse import Langfuse
|
|
| 3 |
from langfuse.decorators import observe, langfuse_context
|
| 4 |
|
| 5 |
from config.config import settings
|
| 6 |
-
|
| 7 |
|
| 8 |
# Initialize Langfuse
|
| 9 |
os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-9f2c32d2-266f-421d-9b87-51377f0a268c"
|
|
@@ -14,40 +14,7 @@ langfuse = Langfuse()
|
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
-
# config.py
|
| 18 |
-
from dataclasses import dataclass, field
|
| 19 |
-
from enum import Enum
|
| 20 |
-
from typing import Dict, Any, Optional
|
| 21 |
-
|
| 22 |
-
class GenerationStrategy(str, Enum):
|
| 23 |
-
DEFAULT = "default"
|
| 24 |
-
MAJORITY_VOTING = "majority_voting"
|
| 25 |
-
BEST_OF_N = "best_of_n"
|
| 26 |
-
BEAM_SEARCH = "beam_search"
|
| 27 |
-
DVTS = "dvts"
|
| 28 |
-
COT = "chain_of_thought"
|
| 29 |
-
REACT = "react"
|
| 30 |
|
| 31 |
-
@dataclass
|
| 32 |
-
class ModelConfig:
|
| 33 |
-
model_kwargs: Dict[str, Any] = field(default_factory=dict)
|
| 34 |
-
tokenizer_kwargs: Dict[str, Any] = field(default_factory=dict)
|
| 35 |
-
quantization_kwargs: Dict[str, Any] = field(default_factory=dict)
|
| 36 |
-
|
| 37 |
-
@dataclass
|
| 38 |
-
class GenerationConfig:
|
| 39 |
-
num_samples: int = 5
|
| 40 |
-
depth: int = 3
|
| 41 |
-
breadth: int = 2
|
| 42 |
-
max_history_turns: int = 1
|
| 43 |
-
max_new_tokens: int = 50
|
| 44 |
-
temperature: float = 0.7
|
| 45 |
-
top_p: float = 0.9
|
| 46 |
-
top_k: int = 50
|
| 47 |
-
repetition_penalty: float = 1.1
|
| 48 |
-
length_penalty: float = 1.0
|
| 49 |
-
do_sample: bool = True
|
| 50 |
-
strategy: GenerationStrategy = GenerationStrategy.DEFAULT
|
| 51 |
|
| 52 |
# model_manager.py
|
| 53 |
import torch
|
|
@@ -187,7 +154,7 @@ from typing import AsyncGenerator, Dict, Any, Optional, List, Tuple
|
|
| 187 |
from dataclasses import dataclass
|
| 188 |
from logging import getLogger
|
| 189 |
|
| 190 |
-
from .config import GenerationConfig, ModelConfig
|
| 191 |
|
| 192 |
class BaseGenerator(ABC):
|
| 193 |
"""Base class for all generator implementations."""
|
|
|
|
| 3 |
from langfuse.decorators import observe, langfuse_context
|
| 4 |
|
| 5 |
from config.config import settings
|
| 6 |
+
import os
|
| 7 |
|
| 8 |
# Initialize Langfuse
|
| 9 |
os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-9f2c32d2-266f-421d-9b87-51377f0a268c"
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# model_manager.py
|
| 20 |
import torch
|
|
|
|
| 154 |
from dataclasses import dataclass
|
| 155 |
from logging import getLogger
|
| 156 |
|
| 157 |
+
from config.config import GenerationConfig, ModelConfig
|
| 158 |
|
| 159 |
class BaseGenerator(ABC):
|
| 160 |
"""Base class for all generator implementations."""
|