Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
import os
|
| 3 |
import requests
|
|
|
|
| 4 |
import nltk
|
| 5 |
from nltk.corpus import stopwords
|
| 6 |
from nltk.tokenize import word_tokenize
|
|
@@ -35,14 +35,12 @@ def call_hf_inference_api(prompt):
|
|
| 35 |
return "β Failed to generate response from AI."
|
| 36 |
|
| 37 |
def generate_roi_and_summary(course_title):
|
| 38 |
-
# Create detailed prompts for summary and ROI
|
| 39 |
summary_prompt = (
|
| 40 |
f"Write a detailed 3-4 paragraph summary about the course titled '{course_title}'."
|
| 41 |
)
|
| 42 |
roi_prompt = (
|
| 43 |
f"Write a detailed 3-4 paragraph explanation of the Return On Investment (ROI) for taking the course titled '{course_title}'."
|
| 44 |
)
|
| 45 |
-
|
| 46 |
summary = call_hf_inference_api(summary_prompt)
|
| 47 |
roi = call_hf_inference_api(roi_prompt)
|
| 48 |
return summary, roi
|
|
@@ -56,10 +54,8 @@ def course_agent(profession, query):
|
|
| 56 |
return "β Could not extract useful keywords.", ""
|
| 57 |
|
| 58 |
search_term = " ".join(keywords) + " course site:educationindia.bmj.com"
|
| 59 |
-
# For simplicity, just create a URL search string instead of Google API
|
| 60 |
course_url = f"https://educationindia.bmj.com/search?q={'+'.join(keywords)}"
|
| 61 |
|
| 62 |
-
# Generate AI summary and ROI
|
| 63 |
summary, roi = generate_roi_and_summary(" ".join(keywords))
|
| 64 |
|
| 65 |
result_text = f"π Course Search URL:\n{course_url}\n\n"
|
|
@@ -68,6 +64,7 @@ def course_agent(profession, query):
|
|
| 68 |
|
| 69 |
return result_text, course_url
|
| 70 |
|
|
|
|
| 71 |
with gr.Blocks(title="π§ AI Course Finder with Summary and ROI") as demo:
|
| 72 |
gr.Markdown("## π― Course Search with AI-Generated Summary & ROI")
|
| 73 |
with gr.Row():
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import requests
|
| 3 |
+
import gradio as gr
|
| 4 |
import nltk
|
| 5 |
from nltk.corpus import stopwords
|
| 6 |
from nltk.tokenize import word_tokenize
|
|
|
|
| 35 |
return "β Failed to generate response from AI."
|
| 36 |
|
| 37 |
def generate_roi_and_summary(course_title):
|
|
|
|
| 38 |
summary_prompt = (
|
| 39 |
f"Write a detailed 3-4 paragraph summary about the course titled '{course_title}'."
|
| 40 |
)
|
| 41 |
roi_prompt = (
|
| 42 |
f"Write a detailed 3-4 paragraph explanation of the Return On Investment (ROI) for taking the course titled '{course_title}'."
|
| 43 |
)
|
|
|
|
| 44 |
summary = call_hf_inference_api(summary_prompt)
|
| 45 |
roi = call_hf_inference_api(roi_prompt)
|
| 46 |
return summary, roi
|
|
|
|
| 54 |
return "β Could not extract useful keywords.", ""
|
| 55 |
|
| 56 |
search_term = " ".join(keywords) + " course site:educationindia.bmj.com"
|
|
|
|
| 57 |
course_url = f"https://educationindia.bmj.com/search?q={'+'.join(keywords)}"
|
| 58 |
|
|
|
|
| 59 |
summary, roi = generate_roi_and_summary(" ".join(keywords))
|
| 60 |
|
| 61 |
result_text = f"π Course Search URL:\n{course_url}\n\n"
|
|
|
|
| 64 |
|
| 65 |
return result_text, course_url
|
| 66 |
|
| 67 |
+
|
| 68 |
with gr.Blocks(title="π§ AI Course Finder with Summary and ROI") as demo:
|
| 69 |
gr.Markdown("## π― Course Search with AI-Generated Summary & ROI")
|
| 70 |
with gr.Row():
|