File size: 1,277 Bytes
1b9f020
 
 
 
 
 
 
 
 
6355201
1b9f020
 
6355201
 
 
 
1b9f020
 
 
 
 
 
 
6355201
1b9f020
 
 
 
 
 
 
040f332
1b9f020
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from langchain.llms import OpenAI
from pydantic import BaseModel
from langchain.llms.base import BaseLLM
from typing import Type, Callable



class ReasoningConfig(BaseModel):
    """
    A configuration class for the reasoning strategy.

    Attributes:
        temperature (float): The temperature parameter for the language model.
        max_tokens (int): The maximum number of tokens to generate.
        llm_class (Type[BaseLLM]): The language model class to use for reasoning.
        usage (str): String describing when it is appropriate to use this reasoning strategy. 
    """
    temperature: float = 0.7
    max_tokens: int = 1500
    llm_class: Type[BaseLLM] = OpenAI
    usage: str

class ReasoningStrategy:
    """Base class for Reasoning Strategies"""
    def __init__(self, config: ReasoningConfig, display: Callable):
        self.llm = config.llm_class(temperature=config.temperature, max_tokens=config.max_tokens) # ign
        self.display = display
        self.usage = config.usage
    def run(self, question):
        raise NotImplementedError()
    
def get_reasoning_config(temperature: float = 0.7) -> ReasoningConfig:
    usage = "This is the default reasoning model that should only be used as a last resort"
    return ReasoningConfig(usage=usage)