File size: 634 Bytes
582689e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from huggingface_hub import InferenceClient

client = InferenceClient(model="codellama/CodeLlama-7b-Instruct-hf")

def explain_code(code):
    response = client.text_generation(
        prompt=f"Explain this code:\n\n{code}",
        max_new_tokens=200,
        temperature=0.7
    )
    return response

demo = gr.Interface(
    fn=explain_code,
    inputs=gr.Textbox(lines=10, placeholder="Paste your code here...", label="Code"),
    outputs="textbox",
    title="🧠 IHCP Code Agent",
    description="Explains React, Python, or Solidity code using CodeLlama via Hugging Face Inference API."
)

demo.launch()