File size: 864 Bytes
932274f
 
1c903eb
0f9d981
5e13b07
0f9d981
5e13b07
0f9d981
 
 
 
5e13b07
0f9d981
 
 
5e13b07
 
 
 
 
 
0f9d981
5e13b07
 
 
 
0f9d981
1c903eb
 
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
import gradio as gr

# Load the model
interface = gr.load("models/alexue4/text-normalization-ru-new")

# Function to modify the behavior (example: limiting max tokens and setting examples)
def custom_function(input_text):
    # Custom processing here (e.g., limit max tokens)
    max_tokens = 250  # Set your desired max token limit
    if len(input_text.split()) > max_tokens:
        input_text = ' '.join(input_text.split()[:max_tokens])
    
    # Call the original function from the interface
    original_output = interface.predict(input_text)
    return original_output

examples = [
    ["в 2006-2010 гг. Вася учился в МГУ"],
    ["я купил iphone 10X за 14990 руб без 3-x часов полдень и т.д."]
]

gr.Interface(
    fn=custom_function,
    inputs="text",
    outputs="text",
    examples=examples
).launch()