initial setup
Browse files- app.py +15 -0
- requirements.txt +5 -0
app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
model_name = "deepseek-ai/deepseek-coder-6.7b-base"
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 7 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", torch_dtype=torch.float16)
|
| 8 |
+
|
| 9 |
+
def generate_code(prompt):
|
| 10 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 11 |
+
outputs = model.generate(**inputs, max_new_tokens=300)
|
| 12 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 13 |
+
|
| 14 |
+
iface = gr.Interface(fn=generate_code, inputs="text", outputs="text", title="AI Coder Agent")
|
| 15 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
torch
|
| 3 |
+
accelerate
|
| 4 |
+
fastapi
|
| 5 |
+
uvicorn
|