Update app.py
Browse files
app.py
CHANGED
@@ -1,60 +1,27 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
-
from
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
model = AutoModelForCausalLM.from_pretrained(model_name)
|
9 |
-
return tokenizer, model
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
"TheBloke/Python-Code-13B-GGUF": "TheBloke/Python-Code-13B-GGUF",
|
17 |
-
"replit/replit-code-v1_5-3b": "replit/replit-code-v1_5-3b",
|
18 |
-
"neulab/codebert-python": "neulab/codebert-python"
|
19 |
-
}
|
20 |
|
21 |
-
# Load selected datasets
|
22 |
-
datasets = {
|
23 |
-
"kye/all-huggingface-python-code": "kye/all-huggingface-python-code",
|
24 |
-
"ajibawa-2023/Python-Code-23k-ShareGPT": "ajibawa-2023/Python-Code-23k-ShareGPT",
|
25 |
-
"suvadityamuk/huggingface-transformers-code-dataset": "suvadityamuk/huggingface-transformers-code-dataset"
|
26 |
-
}
|
27 |
-
|
28 |
-
# Define the function for code generation
|
29 |
-
def generate_code(prompt, model_name, dataset_name, temperature, max_length):
|
30 |
-
tokenizer, model = load_model(models[model_name])
|
31 |
-
|
32 |
-
# Load dataset (for reference, not directly used)
|
33 |
-
dataset = load_dataset(datasets[dataset_name], split="train")
|
34 |
-
|
35 |
-
# Tokenize input prompt
|
36 |
-
inputs = tokenizer(prompt, return_tensors="pt")
|
37 |
-
|
38 |
-
# Generate output
|
39 |
-
output_ids = model.generate(**inputs, temperature=temperature, max_length=max_length)
|
40 |
-
generated_code = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
41 |
-
|
42 |
-
return generated_code
|
43 |
-
|
44 |
-
# Create Gradio Interface
|
45 |
iface = gr.Interface(
|
46 |
-
fn=
|
47 |
-
inputs=
|
48 |
-
|
49 |
-
gr.
|
50 |
-
gr.
|
51 |
-
gr.Slider(label="Temperature", minimum=0.1, maximum=1.0, value=0.5),
|
52 |
-
gr.Slider(label="Max Length", minimum=10, maximum=1000, value=200)
|
53 |
],
|
54 |
-
|
55 |
-
|
56 |
-
description="Select a model and dataset, input a prompt, and generate Python code using AI models."
|
57 |
)
|
58 |
|
59 |
-
|
60 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from models.codet5 import CodeT5
|
3 |
+
from models.other_models import OtherModels
|
4 |
+
from repositories.github_api import GitHubAPI
|
5 |
|
6 |
+
codet5_model = CodeT5()
|
7 |
+
other_models = OtherModels()
|
8 |
+
github_api = GitHubAPI()
|
|
|
|
|
9 |
|
10 |
+
def analyze_repository(repo_url):
|
11 |
+
repo_data = github_api.get_repository(repo_url)
|
12 |
+
optimization_results = codet5_model.analyze(repo_data, github_api)
|
13 |
+
bug_hunting_results = other_models.analyze(repo_data, github_api)
|
14 |
+
return optimization_results, bug_hunting_results
|
|
|
|
|
|
|
|
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
iface = gr.Interface(
|
17 |
+
fn=analyze_repository,
|
18 |
+
inputs=gr.Textbox(lines=1, placeholder="Enter GitHub Repository URL (e.g., https://github.com/owner/repo)"),
|
19 |
+
outputs=[
|
20 |
+
gr.Textbox(lines=10, label="Optimization Results"),
|
21 |
+
gr.Textbox(lines=10, label="Bug Hunting Results"),
|
|
|
|
|
22 |
],
|
23 |
+
title="GitHub Repository Analyzer",
|
24 |
+
description="Analyze GitHub repositories for optimization suggestions and potential bugs using CodeT5 and other models.",
|
|
|
25 |
)
|
26 |
|
27 |
+
iface.launch()
|
|