sidbhasin commited on
Commit
f29a297
·
verified ·
1 Parent(s): 0687664

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -0
app.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
+
4
+ # Initialize the Qwen client
5
+ client = InferenceClient("Qwen/Qwen2.5-Coder")
6
+
7
+ def generate_code(prompt):
8
+ messages = [
9
+ {"role": "system", "content": "You are an expert Python developer who creates clean, efficient code."},
10
+ {"role": "user", "content": f"Create a Python tool for the following requirement: {prompt}"}
11
+ ]
12
+
13
+ response = client.text_generation(
14
+ messages,
15
+ max_new_tokens=1024,
16
+ temperature=0.7,
17
+ top_p=0.9,
18
+ repetition_penalty=1.1
19
+ )
20
+
21
+ return response["generated_text"]
22
+
23
+ # Create the Gradio interface
24
+ with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple")) as demo:
25
+ gr.Markdown("# 🛠️ AI Tool Builder by Syncmerce")
26
+ gr.Markdown("Enter your tool requirements and get production-ready Python code!")
27
+
28
+ with gr.Row():
29
+ with gr.Column():
30
+ prompt_input = gr.Textbox(
31
+ label="Tool Requirements",
32
+ placeholder="Describe the tool you want to build...",
33
+ lines=4
34
+ )
35
+ generate_btn = gr.Button("Generate Tool", variant="primary")
36
+
37
+ with gr.Column():
38
+ code_output = gr.Code(
39
+ label="Generated Code",
40
+ language="python",
41
+ lines=20
42
+ )
43
+
44
+ generate_btn.click(
45
+ fn=generate_code,
46
+ inputs=prompt_input,
47
+ outputs=code_output
48
+ )
49
+
50
+ gr.Markdown("### Examples:")
51
+ gr.Examples(
52
+ [
53
+ ["Create a PDF text extractor tool that can process multiple files"],
54
+ ["Build a web scraper that extracts product prices from e-commerce sites"],
55
+ ["Make a tool for batch image resizing with a progress bar"]
56
+ ],
57
+ inputs=prompt_input
58
+ )
59
+
60
+ demo.launch()