Instructions to use Hamzajutt17/60540 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Hamzajutt17/60540 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("Hamzajutt17/60540") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
| import os | |
| import gradio as gr | |
| import google.generativeai as genai | |
| # Configure Gemini API | |
| API_KEY = os.getenv("GEMINI_API_KEY") | |
| if not API_KEY: | |
| raise ValueError("Please add GEMINI_API_KEY as a Hugging Face Secret.") | |
| genai.configure(api_key=API_KEY) | |
| model = genai.GenerativeModel("gemini-2.5-flash") | |
| def ask_gemini(prompt): | |
| try: | |
| response = model.generate_content(prompt) | |
| return response.text | |
| except Exception as e: | |
| return f"Error: {e}" | |
| def chat(message): | |
| prompt = f""" | |
| You are a professional AI Study Assistant. | |
| Answer clearly, professionally and accurately. | |
| Question: | |
| {message} | |
| """ | |
| return ask_gemini(prompt) | |
| def summarize(text): | |
| prompt = f""" | |
| Summarize the following notes in bullet points. | |
| {text} | |
| """ | |
| return ask_gemini(prompt) | |
| def explain(topic): | |
| prompt = f""" | |
| Explain the following topic like a university professor. | |
| Topic: | |
| {topic} | |
| """ | |
| return ask_gemini(prompt) | |
| def mcq(topic): | |
| prompt = f""" | |
| Generate 10 multiple-choice questions on: | |
| {topic} | |
| Provide four options and the correct answer. | |
| """ | |
| return ask_gemini(prompt) | |
| def quiz(topic): | |
| prompt = f""" | |
| Create a quiz on: | |
| {topic} | |
| Include answers at the end. | |
| """ | |
| return ask_gemini(prompt) | |
| def assignment(topic): | |
| prompt = f""" | |
| Write a detailed assignment on: | |
| {topic} | |
| Include: | |
| - Introduction | |
| - Main Discussion | |
| - Conclusion | |
| """ | |
| return ask_gemini(prompt) | |
| def grammar(text): | |
| prompt = f""" | |
| Correct grammar and improve writing. | |
| {text} | |
| """ | |
| return ask_gemini(prompt) | |
| def translate(text): | |
| prompt = f""" | |
| Translate the following text into Urdu. | |
| {text} | |
| """ | |
| return ask_gemini(prompt) | |
| def planner(goal): | |
| prompt = f""" | |
| Create a detailed study plan for: | |
| {goal} | |
| """ | |
| return ask_gemini(prompt) | |
| with gr.Blocks(title="AI Study Assistant") as demo: | |
| gr.Markdown( | |
| """ | |
| # π AI Study Assistant | |
| Built using: | |
| - Google Gemini | |
| - Python | |
| - Gradio | |
| - Hugging Face Spaces | |
| """ | |
| ) | |
| with gr.Tab("π¬ Chat"): | |
| inp = gr.Textbox(label="Ask Anything") | |
| out = gr.Textbox(lines=12) | |
| btn = gr.Button("Generate") | |
| btn.click(chat, inp, out) | |
| with gr.Tab("π Explain Topic"): | |
| inp = gr.Textbox(label="Topic") | |
| out = gr.Textbox(lines=15) | |
| btn = gr.Button("Explain") | |
| btn.click(explain, inp, out) | |
| with gr.Tab("π Summarizer"): | |
| inp = gr.Textbox(lines=10, label="Paste Notes") | |
| out = gr.Textbox(lines=12) | |
| btn = gr.Button("Summarize") | |
| btn.click(summarize, inp, out) | |
| with gr.Tab("β MCQ Generator"): | |
| inp = gr.Textbox(label="Topic") | |
| out = gr.Textbox(lines=20) | |
| btn = gr.Button("Generate MCQs") | |
| btn.click(mcq, inp, out) | |
| with gr.Tab("π Quiz Generator"): | |
| inp = gr.Textbox(label="Topic") | |
| out = gr.Textbox(lines=20) | |
| btn = gr.Button("Generate Quiz") | |
| btn.click(quiz, inp, out) | |
| with gr.Tab("π Assignment"): | |
| inp = gr.Textbox(label="Assignment Topic") | |
| out = gr.Textbox(lines=20) | |
| btn = gr.Button("Generate Assignment") | |
| btn.click(assignment, inp, out) | |
| with gr.Tab("β Grammar Checker"): | |
| inp = gr.Textbox(lines=10) | |
| out = gr.Textbox(lines=10) | |
| btn = gr.Button("Correct") | |
| btn.click(grammar, inp, out) | |
| with gr.Tab("π Translator"): | |
| inp = gr.Textbox(lines=8) | |
| out = gr.Textbox(lines=8) | |
| btn = gr.Button("Translate") | |
| btn.click(translate, inp, out) | |
| with gr.Tab("π Study Planner"): | |
| inp = gr.Textbox(label="Goal") | |
| out = gr.Textbox(lines=15) | |
| btn = gr.Button("Generate Plan") | |
| btn.click(planner, inp, out) | |
| demo.launch() |