File size: 969 Bytes
932274f
 
5e13b07
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 pre-built interface
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

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

# Define the new Gradio interface with custom function and examples
gr.Interface(
    fn=custom_function,
    inputs="text",
    outputs="text",
    examples=examples
).launch()