Spaces:
Runtime error
Runtime error
File size: 1,782 Bytes
f41ebcd bc32a65 f41ebcd dd4e074 02166d0 f41ebcd bc32a65 f41ebcd dd4e074 f41ebcd dd4e074 f41ebcd | 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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import streamlit as st
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
# Inicializa o pipeline do Hugging Face
tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neo-1.3B")
model = AutoModelForCausalLM.from_pretrained("EleutherAI/gpt-neo-1.3B")
llm = pipeline("text-generation", model=model, tokenizer=tokenizer)
# Define os templates de prompt
prompt_template_br = (
"Você é um analista de teste, responsável pela criação de testes unitários, com base na história de usuário {us} "
"e nos critérios de aceites {ca} baseados no gherking, crie os testes unitários para a linguagem de programação {lp} "
"baseados no framework {fw} "
"e explique como usar o código"
)
prompt_template = (
"You are a test analyst, responsible for creating unit tests based on the user story {us} "
"and the acceptance criteria {ca} based on Gherkin. Create the unit tests for the programming language {lp} "
"based on the {fw} framework and explain how to use the code."
)
# Interface do Streamlit
st.title("AutoDevSuite : BDD-based Test Generator")
us = st.text_area("Enter US:")
ca = st.text_area("Enter your Gherkin-based acceptance criteria:")
lp = st.text_input("Enter the programming language:")
fw = st.text_input("Enter the framework:")
prompt = PromptTemplate(
input_variables=["us", "ca", "lp", "fw"],
template=prompt_template
)
chain_1 = LLMChain(llm=llm, prompt=prompt)
if st.button("Generate Unit Tests"):
# Gera o resultado usando os valores de entrada
inputs = {"us": us, "ca": ca, "lp": lp, "fw": fw}
result = chain_1.run(inputs)
# Exibe o resultado
st.write("Results:")
st.write(result)
|