File size: 838 Bytes
8842640
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from typing import Optional

from src.pipeline import pipeline


def clear():
    return None, None, None, None, None


def generate_text(query_text: str,
                  model_name: Optional[str],
                  is_sustainable: Optional[bool],
                  starting_point: Optional[str],
                  max_tokens: Optional[int] = 1024,
                  temp: Optional[float] = 0.49,
                  ):
    model_params = {
        'max_tokens': max_tokens,
        'temperature': temp
    }
    pipeline_response = pipeline(
        query=query_text,
        model_name=model_name,
        sustainability=is_sustainable,
        starting_point=starting_point,
        **model_params
    )
    if pipeline_response is None:
        return "Error while generating response! Please try again."
    return pipeline_response