Firthous commited on
Commit
37db00d
·
verified ·
1 Parent(s): 07ab6ac

Create app.py

Browse files

import gradio as gr
from transformers import pipeline

# IBM Granite model
model_name = "ibm-granite/granite-3.2-2b-instruct"
generator = pipeline("text-generation", model=model_name)

def smart_city_assistant(prompt):
response = generator(prompt, max_new_tokens=200, do_sample=True, temperature=0.7)
return response[0]['generated_text']

iface = gr.Interface(
fn=smart_city_assistant,
inputs=gr.Textbox(lines=3, placeholder="Ask about smart city, governance, eco tips..."),
outputs="text",
title="🌱 Sustainable Smart City Assistant",
description="Powered by IBM Granite LLM"
)

iface.launch()

Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # IBM Granite model
5
+ model_name = "ibm-granite/granite-3.2-2b-instruct"
6
+ generator = pipeline("text-generation", model=model_name)
7
+
8
+ def smart_city_assistant(prompt):
9
+ response = generator(prompt, max_new_tokens=200, do_sample=True, temperature=0.7)
10
+ return response[0]['generated_text']
11
+
12
+ iface = gr.Interface(
13
+ fn=smart_city_assistant,
14
+ inputs=gr.Textbox(lines=3, placeholder="Ask about smart city, governance, eco tips..."),
15
+ outputs="text",
16
+ title="🌱 Sustainable Smart City Assistant",
17
+ description="Powered by IBM Granite LLM"
18
+ )
19
+
20
+ iface.launch()