File size: 1,240 Bytes
c3340ef
 
 
 
5754774
c3340ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5754774
c3340ef
 
 
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
# import gradio as gr

# gr.Interface.load("models/NousResearch/Yarn-Mistral-7b-128k").launch()

import gradio as gr
from transformers import pipeline

# Load a small GPT model fine-tuned for Python code generation
# generator = pipeline('text-generation', model='microsoft/CodeGPT-small-py')
generator = pipeline('text-generation', model='NousResearch/Yarn-Mistral-7b-128k')

def generate_code(prompt):
    # Generate code from the model
    responses = generator(prompt, max_length=500, num_return_sequences=1, temperature=0.1)
    return responses[0]['generated_text']

input_textbox = gr.Textbox(label="Please click any button below or enter the last 4 digits of your Amazon.in order-id, name and email along with your questions. We shall get back to you!", lines=3)
outputs = gr.Markdown(label="Generated Code")
title = "Schogini Toys - AI Chatbot V2.03"

# Create a Gradio Interface
iface = gr.Interface(
    fn=generate_code,
    inputs=input_textbox, #[gr.Textbox(lines=10, label="Type your code description here")],
    outputs=outputs, #[gr.Textbox(label="Generated Code")],
    examples=[["Define a Python function to calculate factorial."]],
    title=title,
)

# Run the interface
if __name__ == "__main__":
    iface.launch()