Jtrumble12 commited on
Commit
d213a4b
·
verified ·
1 Parent(s): b2801b6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +26 -13
README.md CHANGED
@@ -1,13 +1,26 @@
1
- ---
2
- title: CodeGeni
3
- emoji: 🔥
4
- colorFrom: yellow
5
- colorTo: gray
6
- sdk: gradio
7
- sdk_version: 5.33.0
8
- app_file: app.py
9
- pinned: false
10
- short_description: Helps code your apps
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import InferenceApi
3
+
4
+ # No token passed—using public endpoint
5
+ inference = InferenceApi(repo_id="bigcode/starcoderbase")
6
+
7
+ def generate_code(prompt):
8
+ try:
9
+ output = inference({"inputs": f"'''\n# Task: {prompt}\n'''"})
10
+ # output may be dict or string
11
+ if isinstance(output, dict) and "generated_text" in output:
12
+ return output["generated_text"]
13
+ return output if isinstance(output, str) else str(output)
14
+ except Exception as e:
15
+ return f"Error: {e}"
16
+
17
+ demo = gr.Interface(
18
+ fn=generate_code,
19
+ inputs=gr.Textbox(lines=2, placeholder="Describe coding task..."),
20
+ outputs="text",
21
+ title="CodeM8 AI (public)",
22
+ description="Generate or explain code; no token needed."
23
+ )
24
+
25
+ if __name__ == "__main__":
26
+ demo.launch()