from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
import gradio as gr
access_token="Why are you even reading this? Are you a thief?"
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-chat-hf",token=access_token)
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b-chat-hf", token=access_token)
def text_generation(input_text):
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
outputs = model.generate(input_ids,num_beams=4, do_sample=True)
generated_text = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
return generated_text
# Vue Property Decorator -> Options API
def propertyDecoratorRemoval(input_code):
prompt = f"""Perform a seamless migration from 'vue-property-decorator' code to the native Vue options API for the provided code snippet. Ensure that the refactoring maintains the functionality of the original code while leveraging the benefits of the Vue options API. Following is the code:
{input_code}
"""
agent_answer = text_generation(prompt)
return agent_answer
propertyDecoratorRemovalTab = gr.Interface(
fn=propertyDecoratorRemoval,
article="This tab will take the inputted code (which utilizes the vue-property-decorator package) and migrates it to the native Options API in Vue.",
inputs=gr.Textbox(lines=30, placeholder="vue-property-decorator code here..."),
outputs=gr.Textbox(lines=30, placeholder="Options API code will be outputted here...")
)
# Vue Property Decorator -> Options API
def vueVersionMigration(input_code):
return "Migration"
vueVersionMigrationTab = gr.Interface(
fn=vueVersionMigration,
description="â Please ensure that your code does not have any breaking changes when migrated to Vue 3.",
article="This tab takes the inputted Vue 2 code and migrates it to Vue 3.",
inputs=gr.Textbox(lines=30, placeholder="To migrate Vue 2 here..."),
outputs=gr.Textbox(lines=30, placeholder="Migrated Vue 3 code will be outputted here...")
)
gr.TabbedInterface([propertyDecoratorRemovalTab, vueVersionMigrationTab], ["Vue Property Decorator removal", "Vue Version Migration"]).queue(default_enabled=False).launch()