Abhaykumar04 commited on
Commit
3c1118a
·
verified ·
1 Parent(s): 19036a8

Upload 8 files

Browse files
Files changed (8) hide show
  1. .env +1 -0
  2. API.yml +12 -0
  3. app.py +287 -0
  4. courses.json +470 -0
  5. create_embeddings_together +129 -0
  6. llm_retrieval_conversation_rerank.py +239 -0
  7. requriments.txt +8 -0
  8. scrape_data.py +80 -0
.env ADDED
@@ -0,0 +1 @@
 
 
1
+ PINECONE_INDEX_NAME= embeddings
API.yml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #openai:
2
+ #api_key: "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"
3
+ pinecone_index_name : "embeddings"
4
+ pinecone_api_key: "pcsk_68KQkG_JBFUYTFA5eoND98wVAHvjStQpZNRkKmVQNZUAP1JgfaMKZ17hCxJWWBybSgqdsw"
5
+ pinecone_env: "aws-starter"
6
+ together_ai_api_key: "456b4bf845157be3699b4a78d6651e9dcb32f98cd2e199c560bb5dfdcbe52a04"
7
+ cohere_api_key: "po8LkIuh7RAjkQ7DNdOv6bmXGUvo8F9pMBEJjZVZ"
8
+ #huggingface:
9
+ #model_name: "sentence-transformers/all-mpnet-base-v2"
10
+
11
+
12
+
app.py ADDED
@@ -0,0 +1,287 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import yaml
2
+ from together import Together
3
+ from langchain.llms.together import Together as TogetherLLM
4
+ from langchain.prompts import PromptTemplate
5
+ from langchain.schema.runnable import RunnablePassthrough
6
+ from langchain.schema.output_parser import StrOutputParser
7
+ from pinecone import Pinecone
8
+ import gradio as gr
9
+ from dotenv import load_dotenv
10
+ import os
11
+
12
+ load_dotenv()
13
+
14
+
15
+ API_FILE_PATH = r"C:\Users\abhay\Analytics Vidhya\API.yml"
16
+ COURSES_FILE_PATH = r"C:\Users\abhay\Analytics Vidhya\courses.json"
17
+
18
+ def load_api_keys(api_file_path):
19
+ """Loads API keys from a YAML file."""
20
+ with open(api_file_path, 'r') as f:
21
+ api_keys = yaml.safe_load(f)
22
+ return api_keys
23
+
24
+ def generate_query_embedding(query, together_api_key):
25
+ """Generates embedding for the user query."""
26
+ client = Together(api_key=together_api_key)
27
+ response = client.embeddings.create(
28
+ model="WhereIsAI/UAE-Large-V1", input=query
29
+ )
30
+ return response.data[0].embedding
31
+
32
+ def initialize_pinecone(pinecone_api_key):
33
+ """Initializes Pinecone with API key."""
34
+ return Pinecone(api_key=pinecone_api_key)
35
+
36
+ def pinecone_similarity_search(pinecone_instance, index_name, query_embedding, top_k=5):
37
+ """Performs a similarity search in Pinecone."""
38
+ try:
39
+ index = pinecone_instance.Index(index_name)
40
+ results = index.query(vector=query_embedding, top_k=top_k, include_metadata=True)
41
+ if not results.matches:
42
+ return None
43
+ return results
44
+ except Exception as e:
45
+ print(f"Error during similarity search: {e}")
46
+ return None
47
+
48
+ def create_prompt_template():
49
+ """Creates a prompt template for LLM."""
50
+ template = """You are a helpful AI course advisor. Based on the following context and query, suggest relevant courses.
51
+ For each course, explain:
52
+ 1. Why it's relevant to the query
53
+ 2. What the student will learn
54
+ 3. Who should take this course
55
+
56
+ If no relevant courses are found, suggest alternative search terms.
57
+
58
+ Context: {context}
59
+ User Query: {query}
60
+
61
+ Response: Let me help you find the perfect courses for your needs! 🎓
62
+ """
63
+ return PromptTemplate(template=template, input_variables=["context", "query"])
64
+
65
+ def initialize_llm(together_api_key):
66
+ """Initializes Together LLM."""
67
+ return TogetherLLM(
68
+ model="mistralai/Mixtral-8x7B-Instruct-v0.1",
69
+ together_api_key=together_api_key,
70
+ temperature=0.3,
71
+ max_tokens=500
72
+ )
73
+
74
+ def create_chain(llm, prompt):
75
+ """Creates a chain using the RunnableSequence approach."""
76
+ chain = (
77
+ {"context": RunnablePassthrough(), "query": RunnablePassthrough()}
78
+ | prompt
79
+ | llm
80
+ | StrOutputParser()
81
+ )
82
+ return chain
83
+
84
+ def format_course_info(metadata):
85
+ """Formats course information with emojis and styling."""
86
+ return f"""
87
+ 📚 **Course Title:** {metadata.get('title', 'No title')}
88
+
89
+ 📝 **Description:** {metadata.get('text', 'No description')}
90
+
91
+ 🔗 **Course Link:** {metadata.get('course_link', 'No link')}
92
+
93
+ 👨‍🏫 **Instructor:** {metadata.get('instructor', 'Not specified')}
94
+
95
+ ⏱️ **Duration:** {metadata.get('duration', 'Not specified')}
96
+
97
+ 📊 **Level:** {metadata.get('difficulty_level', 'Not specified')}
98
+
99
+ 💰 **Price:** {metadata.get('price', 'Not specified')}
100
+ """
101
+
102
+ def generate_llm_response(chain, query, retrieved_data):
103
+ """Generates an LLM response with formatted course information."""
104
+ try:
105
+ if not retrieved_data or not retrieved_data.matches:
106
+ return "🔍 I couldn't find any relevant courses matching your query. Please try different search terms."
107
+
108
+ context_parts = []
109
+ formatted_courses = []
110
+
111
+ for match in retrieved_data.matches:
112
+ metadata = match.metadata
113
+ if metadata:
114
+ context_parts.append(
115
+ f"Title: {metadata.get('title', 'No title')}\n"
116
+ f"Description: {metadata.get('text', 'No description')}\n"
117
+ f"Link: {metadata.get('course_link', 'No link')}"
118
+ )
119
+ formatted_courses.append(format_course_info(metadata))
120
+
121
+ if not context_parts:
122
+ return "⚠️ I found some matches but couldn't extract course information. Please try again."
123
+
124
+ context = "\n\n".join(context_parts)
125
+ llm_analysis = chain.invoke({"context": context, "query": query})
126
+
127
+ separator = "=" * 50
128
+ final_response = f"""
129
+ {llm_analysis}
130
+
131
+ 🎯 Here are the detailed course listings:
132
+ {separator}
133
+ {''.join(formatted_courses)}
134
+ """
135
+ return final_response
136
+
137
+ except Exception as e:
138
+ print(f"Error generating response: {e}")
139
+ return "❌ I encountered an error while generating the response. Please try again."
140
+
141
+ def create_gradio_interface(api_keys):
142
+ """Creates a custom Gradio interface with improved styling."""
143
+ # Initialize components
144
+ pinecone_instance = initialize_pinecone(api_keys["pinecone_api_key"])
145
+ llm = initialize_llm(api_keys["together_ai_api_key"])
146
+ prompt = create_prompt_template()
147
+ chain = create_chain(llm, prompt)
148
+
149
+ def process_query(query):
150
+ try:
151
+ query_embedding = generate_query_embedding(query, api_keys["together_ai_api_key"])
152
+ results = pinecone_similarity_search(
153
+ pinecone_instance,
154
+ api_keys["pinecone_index_name"],
155
+ query_embedding
156
+ )
157
+ response = generate_llm_response(chain, query, results)
158
+ return response
159
+ except Exception as e:
160
+ return f"❌ Error: {str(e)}"
161
+
162
+ # Custom CSS for better styling
163
+ custom_css = """
164
+ .gradio-container {
165
+ background-color: #f0f8ff;
166
+ }
167
+ .input-box {
168
+ border: 2px solid #2e86de;
169
+ border-radius: 10px;
170
+ padding: 15px;
171
+ margin: 10px 0;
172
+ }
173
+ .output-box {
174
+ background-color: #ffffff;
175
+ border: 2px solid #54a0ff;
176
+ border-radius: 10px;
177
+ padding: 20px;
178
+ margin: 10px 0;
179
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
180
+ }
181
+ .heading {
182
+ color: #2e86de;
183
+ text-align: center;
184
+ margin-bottom: 20px;
185
+ }
186
+ .submit-btn {
187
+ background-color: #2e86de !important;
188
+ color: white !important;
189
+ border-radius: 8px !important;
190
+ padding: 10px 20px !important;
191
+ font-size: 16px !important;
192
+ }
193
+ .examples {
194
+ margin-top: 20px;
195
+ padding: 15px;
196
+ background-color: #f8f9fa;
197
+ border-radius: 10px;
198
+ }
199
+ """
200
+
201
+ # Create Gradio interface with custom theme
202
+ theme = gr.themes.Soft().set(
203
+ body_background_fill="#f0f8ff",
204
+ block_background_fill="#ffffff",
205
+ block_border_width="2px",
206
+ block_border_color="#2e86de",
207
+ block_radius="10px",
208
+ button_primary_background_fill="#2e86de",
209
+ button_primary_text_color="white",
210
+ input_background_fill="#ffffff",
211
+ input_border_color="#2e86de",
212
+ input_radius="8px",
213
+ )
214
+
215
+ with gr.Blocks(theme=theme, css=custom_css) as demo:
216
+ gr.Markdown(
217
+ """
218
+ # 🎓 Course Recommendation Assistant
219
+
220
+ Welcome to your personalized course finder! Ask me about any topics you're interested in learning.
221
+ I'll help you discover the perfect courses from Analytics Vidhya's collection.
222
+
223
+ ## 🌟 Features:
224
+ - 📚 Detailed course recommendations
225
+ - 🎯 Learning path suggestions
226
+ - 📊 Course difficulty levels
227
+ - 💰 Price information
228
+ """,
229
+ elem_classes=["heading"]
230
+ )
231
+
232
+ with gr.Row():
233
+ with gr.Column():
234
+ query_input = gr.Textbox(
235
+ label="What would you like to learn? 🤔",
236
+ placeholder="e.g., 'machine learning for beginners' or 'advanced python courses'",
237
+ lines=3,
238
+ elem_classes=["input-box"]
239
+ )
240
+ submit_btn = gr.Button(
241
+ "🔍 Find Courses",
242
+ variant="primary",
243
+ elem_classes=["submit-btn"]
244
+ )
245
+
246
+ with gr.Row():
247
+ output = gr.Markdown(
248
+ label="Recommendations 📚",
249
+ elem_classes=["output-box"]
250
+ )
251
+
252
+ with gr.Row(elem_classes=["examples"]):
253
+ gr.Examples(
254
+ examples=[
255
+ ["I want to learn machine learning from scratch"],
256
+ ["Advanced deep learning courses"],
257
+ ["Data visualization tutorials"],
258
+ ["Python programming for beginners"],
259
+ ["Natural Language Processing courses"]
260
+ ],
261
+ inputs=query_input,
262
+ label="📝 Example Queries"
263
+ )
264
+
265
+ submit_btn.click(
266
+ fn=process_query,
267
+ inputs=query_input,
268
+ outputs=output
269
+ )
270
+
271
+ return demo
272
+
273
+ def main():
274
+ try:
275
+
276
+ api_keys = load_api_keys(API_FILE_PATH)
277
+
278
+
279
+ demo = create_gradio_interface(api_keys)
280
+ demo.launch(
281
+ share=True)
282
+
283
+ except Exception as e:
284
+ print(f"An error occurred during initialization: {str(e)}")
285
+
286
+ if __name__ == "__main__":
287
+ main()
courses.json ADDED
@@ -0,0 +1,470 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "title": "Frameworks for Effective Problem Solving",
4
+ "description": "18 Lessons",
5
+ "image_url": "https://import.cdn.thinkific.com/118220/zdlLMkFXQjuKiItB273o_Thumbnail%201.jpg",
6
+ "course_link": "https://courses.analyticsvidhya.com/courses/frameworks-for-effective-problem-solving"
7
+ },
8
+ {
9
+ "title": "Anyone can Build AI Agents - Free Course",
10
+ "description": "5 Lessons",
11
+ "image_url": "https://import.cdn.thinkific.com/118220/HDiuucWOTp2G0PDvjEQm_build%20your%20first%20agent%20using%20no%20code%20tools%20(1).jpg",
12
+ "course_link": "https://courses.analyticsvidhya.com/courses/your-ultimate-guide-to-becoming-an-agentic-ai-expert-by-2025"
13
+ },
14
+ {
15
+ "title": "A Comprehensive Learning Path to Become a Data Analyst in 2025",
16
+ "description": "298 Lessons",
17
+ "image_url": "https://import.cdn.thinkific.com/118220/qdmHBCw7Qtqw2Y9g0vOE_Become%20a%20GenAI%20Expert%20in%202025.%20Thumbnail.jpg",
18
+ "course_link": "https://courses.analyticsvidhya.com/courses/a-comprehensive-learning-path-to-become-a-data-analyst-in-2025"
19
+ },
20
+ {
21
+ "title": "Reimagining GenAI: Common Mistakes and Best Practices for Success",
22
+ "description": "6 Lessons",
23
+ "image_url": "https://import.cdn.thinkific.com/118220/ky8mTd5ISIypAcrVJkdO_unnamed%20(4).jpg",
24
+ "course_link": "https://courses.analyticsvidhya.com/courses/reimagining-genai-common-mistakes-and-best-practices-for-success"
25
+ },
26
+ {
27
+ "title": "Coding a ChatGPT-style Language Model from Scratch in PyTorch",
28
+ "description": "7 Lessons",
29
+ "image_url": "https://import.cdn.thinkific.com/118220/Q1tYD2LSlaLzL1XPZWgw_1Mastering%20Multilingual%20GenAI%20Open-Weights%20for%20Indic%20Languages%20copy.png",
30
+ "course_link": "https://courses.analyticsvidhya.com/courses/coding-a-chatgpt-style-language-model-from-scratch-in-pytorch"
31
+ },
32
+ {
33
+ "title": "Mastering Multilingual GenAI Open-Weights for Indic Languages",
34
+ "description": "9 Lessons",
35
+ "image_url": "https://import.cdn.thinkific.com/118220/beC0zMfQhOnHcT2FLR4g_unnamed%20(2).jpg",
36
+ "course_link": "https://courses.analyticsvidhya.com/courses/mastering-multilingual-genai-open-weights-for-indic-languages"
37
+ },
38
+ {
39
+ "title": "Learning Autonomous Driving Behaviors with LLMs & RL",
40
+ "description": "6 Lessons",
41
+ "image_url": "https://import.cdn.thinkific.com/118220/lrzfD3upSjb0iUOrJcOo_unnamed%20(1).jpg",
42
+ "course_link": "https://courses.analyticsvidhya.com/courses/learning-autonomous-driving-behaviors-with-llms-and-rl"
43
+ },
44
+ {
45
+ "title": "GenAI Applied to Quantitative Finance: For Control Implementation",
46
+ "description": "5 Lessons",
47
+ "image_url": "https://import.cdn.thinkific.com/118220/0hkgoKCKTnKKxhQGAEIp_govind_av_httpss.mj.runER3kgo8rubs_based_on_this_theme_create_b2190701-9e82-47ea-b65a-c52d6de94e07_3.png",
48
+ "course_link": "https://courses.analyticsvidhya.com/courses/genai-applied-to-quantitative-finance-for-control-implementation"
49
+ },
50
+ {
51
+ "title": "Navigating LLM Tradeoffs: Techniques for Speed, Cost, Scale & Accuracy",
52
+ "description": "6 Lessons",
53
+ "image_url": "https://import.cdn.thinkific.com/118220/SV5jeKd1Q4iFyzMlUSdw_Thumbnail.png",
54
+ "course_link": "https://courses.analyticsvidhya.com/courses/navigating-llm-tradeoffs-techniques-for-speed-cost-scale-and-accuracy"
55
+ },
56
+ {
57
+ "title": "Creating Problem-Solving Agents using GenAI for Action Composition",
58
+ "description": "6 Lessons",
59
+ "image_url": "https://import.cdn.thinkific.com/118220/ih6JsBMgSCWbl9ofgpYg_Thumbnail%20.png",
60
+ "course_link": "https://courses.analyticsvidhya.com/courses/creating-problem-solving-agents-using-genai-for-action-composition"
61
+ },
62
+ {
63
+ "title": "Improving Real World RAG Systems: Key Challenges & Practical Solutions",
64
+ "description": "12 Lessons",
65
+ "image_url": "https://import.cdn.thinkific.com/118220/70WfAJhFRsyXXdLQcWIl_281762.jpg",
66
+ "course_link": "https://courses.analyticsvidhya.com/courses/improving-real-world-rag-systems-key-challenges"
67
+ },
68
+ {
69
+ "title": "Framework to Choose the Right LLM for your Business",
70
+ "description": "6 Lessons",
71
+ "image_url": "https://import.cdn.thinkific.com/118220/A3lVcQcRRbKN9IBZANvV_cinematic-person-is-looking-customer-journey-map%201.jpg",
72
+ "course_link": "https://courses.analyticsvidhya.com/courses/choosing-the-right-LLM-for-your-business"
73
+ },
74
+ {
75
+ "title": "Building Smarter LLMs with Mamba and State Space Model",
76
+ "description": "14 Lessons",
77
+ "image_url": "https://import.cdn.thinkific.com/118220/FbdKUqgKSj2K80QgVl1z_THUMBNAIL%20(1).png",
78
+ "course_link": "https://courses.analyticsvidhya.com/courses/building-smarter-llms-with-mamba-and-state-space-model"
79
+ },
80
+ {
81
+ "title": "Generative AI - A Way of Life - Free Course",
82
+ "description": "31 Lessons",
83
+ "image_url": "https://import.cdn.thinkific.com/118220/0hkgoKCKTnKKxhQGAEIp_govind_av_httpss.mj.runER3kgo8rubs_based_on_this_theme_create_b2190701-9e82-47ea-b65a-c52d6de94e07_3.png",
84
+ "course_link": "https://courses.analyticsvidhya.com/courses/genai-a-way-of-life"
85
+ },
86
+ {
87
+ "title": "Building LLM Applications using Prompt Engineering - Free Course",
88
+ "description": "18 Lessons",
89
+ "image_url": "https://import.cdn.thinkific.com/118220/GnpgN0uiTA1VO2MpQvTA_3.png",
90
+ "course_link": "https://courses.analyticsvidhya.com/courses/building-llm-applications-using-prompt-engineering-free"
91
+ },
92
+ {
93
+ "title": "Building Your First Computer Vision Model - Free Course",
94
+ "description": "7 Lessons",
95
+ "image_url": "https://import.cdn.thinkific.com/118220/cv8WEAZPRtGcSR8A2kBY_cv%20thumbnail.png",
96
+ "course_link": "https://courses.analyticsvidhya.com/courses/building-your-first-computer-vision-model"
97
+ },
98
+ {
99
+ "title": "Bagging and Boosting ML Algorithms - Free Course",
100
+ "description": "16 Lessons",
101
+ "image_url": "https://import.cdn.thinkific.com/118220/ZPH29GMrTey5gAaobwAH_Getting%20started%20with%20Decision%20Trees.jpg",
102
+ "course_link": "https://courses.analyticsvidhya.com/courses/bagging-boosting-ML-Algorithms"
103
+ },
104
+ {
105
+ "title": "MidJourney: From Inspiration to Implementation - Free Course",
106
+ "description": "5 Lessons",
107
+ "image_url": "https://import.cdn.thinkific.com/118220/NclAzDSwRwedON784y83_QZQvFaQFTFu4cFHZ0O5A_Midjourney%20(1).png",
108
+ "course_link": "https://courses.analyticsvidhya.com/courses/midjourney_from_inspiration_to_implementation"
109
+ },
110
+ {
111
+ "title": "Understanding Linear Regression - Free Course",
112
+ "description": "10 Lessons",
113
+ "image_url": "https://import.cdn.thinkific.com/118220/vK6lGCCqSsWtESgG69K1_Foundational%20ML%20Algorithms.png",
114
+ "course_link": "https://courses.analyticsvidhya.com/courses/free-understanding-linear-regression"
115
+ },
116
+ {
117
+ "title": "The Working of Neural Networks - Free Course",
118
+ "description": "11 Lessons",
119
+ "image_url": "https://import.cdn.thinkific.com/118220/cu3qVXYTR7WEDj7eYQXS_unnamed.jpg",
120
+ "course_link": "https://courses.analyticsvidhya.com/courses/the-working-of-neural-networks"
121
+ },
122
+ {
123
+ "title": "The A to Z of Unsupervised ML - Free Course",
124
+ "description": "13 Lessons",
125
+ "image_url": "https://import.cdn.thinkific.com/118220/a8FaIfN8SyfgOEhgzcHx_Getting_Started_with_Neural_Networks_307d8d11-d90e-45eb-8885-7d8f59fadc48.png",
126
+ "course_link": "https://courses.analyticsvidhya.com/courses/free-unsupervised-ml-guide"
127
+ },
128
+ {
129
+ "title": "Building Your first RAG System using LlamaIndex - Free Course",
130
+ "description": "12 Lessons",
131
+ "image_url": "https://import.cdn.thinkific.com/118220/HSr06pXxRTeF2Lpp6VQl_DALL%C2%B7E%202024-07-03%2011.42.42%20-%20A%20visually%20striking%20representation%20of%20a%20Retrieval-Augmented%20Generation%20(RAG)%20system%20using%20LlamaIndex.%20The%20image%20should%20have%20a%20dark%20background%20with%20int.png",
132
+ "course_link": "https://courses.analyticsvidhya.com/courses/building-first-rag-systems-using-llamaindex"
133
+ },
134
+ {
135
+ "title": "Data Preprocessing on a Real-World Problem Statement - Free Course",
136
+ "description": "13 Lessons",
137
+ "image_url": "https://import.cdn.thinkific.com/118220/2BmYWOASeye7uIgp3mHr_Building%20your%20first%20ML%20model.png",
138
+ "course_link": "https://courses.analyticsvidhya.com/courses/data-preprocessing"
139
+ },
140
+ {
141
+ "title": "Exploring Stability.AI - Free Course",
142
+ "description": "7 Lessons",
143
+ "image_url": "https://import.cdn.thinkific.com/118220/imiRzsUqTwuQxv4wfyUb_mastering-stable-diffusion-thumbnail_2.png",
144
+ "course_link": "https://courses.analyticsvidhya.com/courses/exploring-stability-ai"
145
+ },
146
+ {
147
+ "title": "Building a Text Classification Model with Natural Language Processing - Free Course",
148
+ "description": "16 Lessons",
149
+ "image_url": "https://import.cdn.thinkific.com/118220/YfA6OJ6ATeiwbbvvzb5h_NLP%20Banner.png",
150
+ "course_link": "https://courses.analyticsvidhya.com/courses/free-building-textclassification-natural-language-processing"
151
+ },
152
+ {
153
+ "title": "Getting Started with Large Language Models",
154
+ "description": "18 Lessons",
155
+ "image_url": "https://import.cdn.thinkific.com/118220/TwSmk34ARlGMcQu4M8Co_A_Comprehensive_Learning_Path_to_Become_a_Data_Sc_265db306-1f93-496d-827e-0f1e534c9cf1.png",
156
+ "course_link": "https://courses.analyticsvidhya.com/courses/getting-started-with-llms"
157
+ },
158
+ {
159
+ "title": "Introduction to Generative AI",
160
+ "description": "9 Lessons",
161
+ "image_url": "https://import.cdn.thinkific.com/118220/CNjAWH6TUaIQt8N5FX9Y_thumbnail%201.png",
162
+ "course_link": "https://courses.analyticsvidhya.com/courses/introduction-to-generative-ai"
163
+ },
164
+ {
165
+ "title": "Exploring Natural Language Processing (NLP) using Deep Learning",
166
+ "description": "79 Lessons",
167
+ "image_url": "https://import.cdn.thinkific.com/118220/vl3JHf3eS0Wp9XPLeDaL_8.png",
168
+ "course_link": "https://courses.analyticsvidhya.com/courses/exploring-natural-language-processing-nlp-using-deep-learning"
169
+ },
170
+ {
171
+ "title": "Getting Started with Deep Learning",
172
+ "description": "299 Lessons",
173
+ "image_url": "https://import.cdn.thinkific.com/118220/KybSy5ROKQAC4fyxyFlQ_6_.png",
174
+ "course_link": "https://courses.analyticsvidhya.com/courses/getting-started-with-deep-learning"
175
+ },
176
+ {
177
+ "title": "Nano Course: Dreambooth-Stable Diffusion for Custom Images",
178
+ "description": "13 Lessons",
179
+ "image_url": "https://import.cdn.thinkific.com/118220/sU6NzHaSiCPghfiOpQ52_Introduction_to_Natural_Language_Processing_b92e8456-3145-489b-97e7-51925a655b2c.png",
180
+ "course_link": "https://courses.analyticsvidhya.com/courses/nano-course-dreambooth-stable-diffusion-for-custom-images"
181
+ },
182
+ {
183
+ "title": "A Comprehensive Learning Path for Deep Learning in 2023",
184
+ "description": "72 Lessons",
185
+ "image_url": "https://files.cdn.thinkific.com/courses/course_card_image_000/580/9901576591074.original.jpg",
186
+ "course_link": "https://courses.analyticsvidhya.com/courses/a-comprehensive-learning-path-for-deep-learning-in-2023"
187
+ },
188
+ {
189
+ "title": "A Comprehensive Learning Path to Become a Data Scientist in 2024",
190
+ "description": "389 Lessons",
191
+ "image_url": "https://import.cdn.thinkific.com/118220/1b0s4lDiQluveqaLqKj8_A_Comprehensive_Learning_Path_to_Become_a_Data_Sc_6e902c6d-46bf-4b8b-91cc-24329e68086c.png",
192
+ "course_link": "https://courses.analyticsvidhya.com/courses/a-comprehensive-learning-path-to-become-a-data-scientist-in-twenty-twenty-four"
193
+ },
194
+ {
195
+ "title": "Nano Course: Building Large Language Models for Code",
196
+ "description": "10 Lessons",
197
+ "image_url": "https://import.cdn.thinkific.com/118220/OelAeGXrRuGrnkcJSdAO_OG.png",
198
+ "course_link": "https://courses.analyticsvidhya.com/courses/building-large-language-models-for-code"
199
+ },
200
+ {
201
+ "title": "Nano Course: Cutting Edge LLM Tricks",
202
+ "description": "12 Lessons",
203
+ "image_url": "https://import.cdn.thinkific.com/118220/OelAeGXrRuGrnkcJSdAO_OG.png",
204
+ "course_link": "https://courses.analyticsvidhya.com/courses/cutting-edge-llm-tricks"
205
+ },
206
+ {
207
+ "title": "Certified AI & ML BlackBelt+ Program",
208
+ "description": "No Description",
209
+ "image_url": "https://files.cdn.thinkific.com/bundles/bundle_card_image_000/048/808/1719037298.original.png",
210
+ "course_link": "https://courses.analyticsvidhya.com/bundles/certified-ai-ml-blackbelt-plus"
211
+ },
212
+ {
213
+ "title": "Machine Learning Summer Training",
214
+ "description": "263 Lessons",
215
+ "image_url": "https://import.cdn.thinkific.com/118220/courses/1903742/zJ10PGDvQPKiGRGM73Dn_icon%282%29%20%281%29.jpg",
216
+ "course_link": "https://courses.analyticsvidhya.com/courses/machine-learning-summer-training"
217
+ },
218
+ {
219
+ "title": "AI Ethics by Fractal",
220
+ "description": "5 Lessons",
221
+ "image_url": "https://import.cdn.thinkific.com/118220/courses/1720521/9MuNm0LRmeWOiy5VjCDB_ai.png",
222
+ "course_link": "https://courses.analyticsvidhya.com/courses/ai-ethics-fractal"
223
+ },
224
+ {
225
+ "title": "A Comprehensive Learning Path to Become a Data Engineer in 2022",
226
+ "description": "204 Lessons",
227
+ "image_url": "https://import.cdn.thinkific.com/118220/courses/1667459/Rqbh8QTKShaGKJ6vNiRx_overview%20of%20data%20engineering.jpg",
228
+ "course_link": "https://courses.analyticsvidhya.com/courses/a-comprehensive-learning-path-to-become-a-data-engineer-in-2022"
229
+ },
230
+ {
231
+ "title": "Certified Business Analytics Program",
232
+ "description": "No Description",
233
+ "image_url": "https://files.cdn.thinkific.com/bundles/bundle_card_image_000/048/438/1719206987.original.png",
234
+ "course_link": "https://courses.analyticsvidhya.com/bundles/certified-business-analytics-program"
235
+ },
236
+ {
237
+ "title": "Certified Machine Learning Master's Program (MLMP)",
238
+ "description": "No Description",
239
+ "image_url": "https://files.cdn.thinkific.com/bundles/bundle_card_image_000/046/940/1719206858.original.png",
240
+ "course_link": "https://courses.analyticsvidhya.com/bundles/certified-machine-learning-master-s-program-mlmp"
241
+ },
242
+ {
243
+ "title": "Certified Natural Language Processing Master\u2019s Program",
244
+ "description": "No Description",
245
+ "image_url": "https://import.cdn.thinkific.com/118220/moBOBv3RMCKDgEoIi3DK_nlp%20master_thumb.jpg",
246
+ "course_link": "https://courses.analyticsvidhya.com/bundles/certified-natural-language-processing-master-s-program"
247
+ },
248
+ {
249
+ "title": "Certified Computer Vision Master's Program",
250
+ "description": "No Description",
251
+ "image_url": "https://import.cdn.thinkific.com/118220/BY3BuXPFRuaKZuKdYB5T_thumb_.jpg",
252
+ "course_link": "https://courses.analyticsvidhya.com/bundles/certified-computer-vision-masters-program"
253
+ },
254
+ {
255
+ "title": "Applied Machine Learning - Beginner to Professional",
256
+ "description": "612 Lessons",
257
+ "image_url": "https://files.cdn.thinkific.com/courses/course_card_image_000/739/8911589353707.original.jpg",
258
+ "course_link": "https://courses.analyticsvidhya.com/courses/applied-machine-learning-beginner-to-professional"
259
+ },
260
+ {
261
+ "title": "Ace Data Science Interviews",
262
+ "description": "59 Lessons",
263
+ "image_url": "https://import.cdn.thinkific.com/118220/eZzXQDJSgyLlxFiQ5rbu_data_science_interview.jpg",
264
+ "course_link": "https://courses.analyticsvidhya.com/courses/ace-data-science-interviews"
265
+ },
266
+ {
267
+ "title": "Writing Powerful Data Science Articles",
268
+ "description": "6 Lessons",
269
+ "image_url": "https://import.cdn.thinkific.com/118220/courses/1292824/YfJD5SeRLaXRxYgVb2uw_icon.png",
270
+ "course_link": "https://courses.analyticsvidhya.com/courses/writing-powerful-data-science-articles"
271
+ },
272
+ {
273
+ "title": "Machine Learning Certification Course for Beginners",
274
+ "description": "261 Lessons",
275
+ "image_url": "https://import.cdn.thinkific.com/118220/NjFxaJVSFeAfMSHYoG9Q_Machine_Learning_for_Beginners_b896980a-b1d1-41bc-9bab-d8d3176daaf8.png",
276
+ "course_link": "https://courses.analyticsvidhya.com/courses/Machine-Learning-Certification-Course-for-Beginners"
277
+ },
278
+ {
279
+ "title": "Data Science Career Conclave",
280
+ "description": "6 Lessons",
281
+ "image_url": "https://import.cdn.thinkific.com/118220/courses/1230486/udv57o17QrG3uuBO8BwD_1200x628-icon.png",
282
+ "course_link": "https://courses.analyticsvidhya.com/courses/data-science-career-conclave"
283
+ },
284
+ {
285
+ "title": "Top Data Science Projects for Analysts and Data Scientists",
286
+ "description": "36 Lessons",
287
+ "image_url": "https://import.cdn.thinkific.com/118220/oNPtWVT9CbWwip5Ogang_project_thumb.jpg",
288
+ "course_link": "https://courses.analyticsvidhya.com/courses/top-data-science-projects-for-analysts-and-data-scientists"
289
+ },
290
+ {
291
+ "title": "Getting Started with Git and GitHub for Data Science Professionals",
292
+ "description": "20 Lessons",
293
+ "image_url": "https://import.cdn.thinkific.com/118220/pbMFVOw2RPi9fFXSOuGP_github_thumb.jpg",
294
+ "course_link": "https://courses.analyticsvidhya.com/courses/getting-started-with-git-and-github-for-data-science-professionals"
295
+ },
296
+ {
297
+ "title": "Machine Learning Starter Program",
298
+ "description": "No Description",
299
+ "image_url": "https://import.cdn.thinkific.com/118220/OTJAEtMGQWaxxIWD0pWv_MLSP%20thumb.jpg",
300
+ "course_link": "https://courses.analyticsvidhya.com/bundles/machine-learning-starter-program"
301
+ },
302
+ {
303
+ "title": "Data Science Hacks, Tips and Tricks",
304
+ "description": "37 Lessons",
305
+ "image_url": "https://import.cdn.thinkific.com/118220/qaomVKyQPaj9MCRxO9dg_course%20thumb%20image.jpg",
306
+ "course_link": "https://courses.analyticsvidhya.com/courses/data-science-hacks-tips-and-tricks"
307
+ },
308
+ {
309
+ "title": "Introduction to Business Analytics",
310
+ "description": "33 Lessons",
311
+ "image_url": "https://import.cdn.thinkific.com/118220/uQspaf6ESc6KPX6jkVrx_Introduction_to_Business_Analytics_fcacd85c-25ff-44bf-a74d-ee3aa66e51d4.png",
312
+ "course_link": "https://courses.analyticsvidhya.com/courses/introduction-to-analytics"
313
+ },
314
+ {
315
+ "title": "Introduction to PyTorch for Deep Learning",
316
+ "description": "28 Lessons",
317
+ "image_url": "https://import.cdn.thinkific.com/118220/3Ec7NO7MTkqaEImQio94_pytorch_thumb.jpg",
318
+ "course_link": "https://courses.analyticsvidhya.com/courses/introduction-to-pytorch-for-deeplearning"
319
+ },
320
+ {
321
+ "title": "Introductory Data Science for Business Managers",
322
+ "description": "No Description",
323
+ "image_url": "https://import.cdn.thinkific.com/118220/oF8KoXuyQ7KrHIRMmTt5_Business_Manager.jpg",
324
+ "course_link": "https://courses.analyticsvidhya.com/bundles/introductory-data-science-for-business-managers"
325
+ },
326
+ {
327
+ "title": "Introduction to Natural Language Processing",
328
+ "description": "21 Lessons",
329
+ "image_url": "https://import.cdn.thinkific.com/118220/X8bM7n4REC8ykgf53oSj_10.Introduction%20to%20AI%20_%20ML.png",
330
+ "course_link": "https://courses.analyticsvidhya.com/courses/Intro-to-NLP"
331
+ },
332
+ {
333
+ "title": "Getting started with Decision Trees",
334
+ "description": "20 Lessons",
335
+ "image_url": "https://import.cdn.thinkific.com/118220/Tgfv1fveTpWrv3ZFTt6r_Decision_Trees_ca3c729e-525b-4c8c-9f48-dec4bbb4faf3.png",
336
+ "course_link": "https://courses.analyticsvidhya.com/courses/getting-started-with-decision-trees"
337
+ },
338
+ {
339
+ "title": "Introduction to Python",
340
+ "description": "69 Lessons",
341
+ "image_url": "https://import.cdn.thinkific.com/118220/QAUsjF0qSxCI7fsIrzhn_Algorithm_in_Python_and_R_1b947457-056e-4bfb-9a6f-ce614ebfe3c4.png",
342
+ "course_link": "https://courses.analyticsvidhya.com/courses/introduction-to-data-science"
343
+ },
344
+ {
345
+ "title": "Loan Prediction Practice Problem (Using Python)",
346
+ "description": "16 Lessons",
347
+ "image_url": "https://import.cdn.thinkific.com/118220/pcauZ3ZqSWqrYXlYTd0w_Loan_Prediction_Practice_Problem_8dbf2aea-f3c8-42d4-bd27-87e738de5aac.png",
348
+ "course_link": "https://courses.analyticsvidhya.com/courses/loan-prediction-practice-problem-using-python"
349
+ },
350
+ {
351
+ "title": "Big Mart Sales Prediction Using R",
352
+ "description": "19 Lessons",
353
+ "image_url": "https://import.cdn.thinkific.com/118220/t1hnCAcdT22pr7EEWQpW_Sales%20Prediction_thumb.jpg",
354
+ "course_link": "https://courses.analyticsvidhya.com/courses/big-mart-sales-prediction-using-r"
355
+ },
356
+ {
357
+ "title": "Twitter Sentiment Analysis",
358
+ "description": "18 Lessons",
359
+ "image_url": "https://import.cdn.thinkific.com/118220/nwZ67Ta2R0SO6uI4mWBe_Twitter%20Sentiment%20Analysis.jpg",
360
+ "course_link": "https://courses.analyticsvidhya.com/courses/twitter-sentiment-analysis"
361
+ },
362
+ {
363
+ "title": "Pandas for Data Analysis in Python",
364
+ "description": "27 Lessons",
365
+ "image_url": "https://import.cdn.thinkific.com/118220/SPL9Cu7sQ5uihQ2mGYtO_Pandas_for_Data_Analysis_in_Python_7760df6c-f648-46d8-93f3-ba4e49d89a22.png",
366
+ "course_link": "https://courses.analyticsvidhya.com/courses/pandas-for-data-analysis-in-python"
367
+ },
368
+ {
369
+ "title": "Support Vector Machine (SVM) in Python and R",
370
+ "description": "13 Lessons",
371
+ "image_url": "https://import.cdn.thinkific.com/118220/PhPoLyt7QKOucBS6VLf2_Support%20Vector%20Machine_thumb.jpg",
372
+ "course_link": "https://courses.analyticsvidhya.com/courses/support-vector-machine-svm-in-python-and-r"
373
+ },
374
+ {
375
+ "title": "Evaluation Metrics for Machine Learning Models",
376
+ "description": "25 Lessons",
377
+ "image_url": "https://import.cdn.thinkific.com/118220/Qb1PlcDoTEeoR1ZOOvUy_evaluation%20metrics_thumb.jpg",
378
+ "course_link": "https://courses.analyticsvidhya.com/courses/evaluation-metrics-for-machine-learning-models"
379
+ },
380
+ {
381
+ "title": "Fundamentals of Regression Analysis",
382
+ "description": "24 Lessons",
383
+ "image_url": "https://import.cdn.thinkific.com/118220/C5HN5LVDQsyS1hRojIyT_courses_thumb.jpg",
384
+ "course_link": "https://courses.analyticsvidhya.com/courses/Fundamentals-of-Regression-Analysis"
385
+ },
386
+ {
387
+ "title": "Getting Started with scikit-learn (sklearn) for Machine Learning",
388
+ "description": "27 Lessons",
389
+ "image_url": "https://import.cdn.thinkific.com/118220/d8R1MoSmisGRZk4UJWQF_thumb_.jpg",
390
+ "course_link": "https://courses.analyticsvidhya.com/courses/get-started-with-scikit-learn-sklearn"
391
+ },
392
+ {
393
+ "title": "Convolutional Neural Networks (CNN) from Scratch",
394
+ "description": "17 Lessons",
395
+ "image_url": "https://import.cdn.thinkific.com/118220/4yxTr5xuQy6snBYBcHP8_Convolutional%20Neural%20Networks_thumb.jpg",
396
+ "course_link": "https://courses.analyticsvidhya.com/courses/convolutional-neural-networks-cnn-from-scratch"
397
+ },
398
+ {
399
+ "title": "Dimensionality Reduction for Machine Learning",
400
+ "description": "23 Lessons",
401
+ "image_url": "https://import.cdn.thinkific.com/118220/Um1x4Xh7RIGzMIQuwCeM_course_thumb%20.jpg",
402
+ "course_link": "https://courses.analyticsvidhya.com/courses/dimensionality-reduction-for-machine-learning"
403
+ },
404
+ {
405
+ "title": "K-Nearest Neighbors (KNN) Algorithm in Python and R",
406
+ "description": "10 Lessons",
407
+ "image_url": "https://import.cdn.thinkific.com/118220/7FpGUA1gQLWbDB5oVsCz_thumb_.jpg",
408
+ "course_link": "https://courses.analyticsvidhya.com/courses/K-Nearest-Neighbors-KNN-Algorithm"
409
+ },
410
+ {
411
+ "title": "Ensemble Learning and Ensemble Learning Techniques",
412
+ "description": "37 Lessons",
413
+ "image_url": "https://import.cdn.thinkific.com/118220/doHSugITVCfoBUVdlxeH_Ensemble%20Learning-thumb.jpg",
414
+ "course_link": "https://courses.analyticsvidhya.com/courses/ensemble-learning-and-ensemble-learning-techniques"
415
+ },
416
+ {
417
+ "title": "Linear Programming for Data Science Professionals",
418
+ "description": "20 Lessons",
419
+ "image_url": "https://import.cdn.thinkific.com/118220/TMBNBD4R5a1YdlMHJada_thumb.jpg",
420
+ "course_link": "https://courses.analyticsvidhya.com/courses/linear-programming"
421
+ },
422
+ {
423
+ "title": "Naive Bayes from Scratch",
424
+ "description": "19 Lessons",
425
+ "image_url": "https://import.cdn.thinkific.com/118220/tdU7ioeOQG4ZuHzhoJrQ_thumb_.jpg",
426
+ "course_link": "https://courses.analyticsvidhya.com/courses/naive-bayes"
427
+ },
428
+ {
429
+ "title": "Learn Swift for Data Science",
430
+ "description": "21 Lessons",
431
+ "image_url": "https://import.cdn.thinkific.com/118220/QT5BeWvTG2ITfNiyiCZQ_thumb.jpg",
432
+ "course_link": "https://courses.analyticsvidhya.com/courses/learn-swift-for-data-science"
433
+ },
434
+ {
435
+ "title": "Introduction to Web Scraping using Python",
436
+ "description": "13 Lessons",
437
+ "image_url": "https://import.cdn.thinkific.com/118220/AEt5RjqFTCeJJ8oIBn7s_thumb.jpg",
438
+ "course_link": "https://courses.analyticsvidhya.com/courses/introduction-to-web-scraping"
439
+ },
440
+ {
441
+ "title": "Tableau for Beginners",
442
+ "description": "17 Lessons",
443
+ "image_url": "https://import.cdn.thinkific.com/118220/UtXF4erQmuUVLtZz8TMA_tablu_thumb.jpg",
444
+ "course_link": "https://courses.analyticsvidhya.com/courses/tableau-for-beginners"
445
+ },
446
+ {
447
+ "title": "Getting Started with Neural Networks",
448
+ "description": "45 Lessons",
449
+ "image_url": "https://import.cdn.thinkific.com/118220/hujFPpK4S261x92WyEyc_natural%20Network.jpg",
450
+ "course_link": "https://courses.analyticsvidhya.com/courses/getting-started-with-neural-networks"
451
+ },
452
+ {
453
+ "title": "Introduction to AI & ML",
454
+ "description": "17 Lessons",
455
+ "image_url": "https://import.cdn.thinkific.com/118220/rlT6Q4O0SEafxqg4WmzL_Introduction_to_AI__ML_88145141-2c69-4ae8-9681-5d7201a38288%20(1).png",
456
+ "course_link": "https://courses.analyticsvidhya.com/courses/introduction-to-ai-ml"
457
+ },
458
+ {
459
+ "title": "Winning Data Science Hackathons - Learn from Elite Data Scientists",
460
+ "description": "7 Lessons",
461
+ "image_url": "https://import.cdn.thinkific.com/118220/7exjvWuRSNesvaXPPxHO_data-science.jpg",
462
+ "course_link": "https://courses.analyticsvidhya.com/courses/winning-data-science-hackathons-learn-from-elite-data-scientists"
463
+ },
464
+ {
465
+ "title": "Hypothesis Testing for Data Science and Analytics",
466
+ "description": "19 Lessons",
467
+ "image_url": "https://import.cdn.thinkific.com/118220/iO9QE66XTOm17Mz0fxzs_thumb.jpg",
468
+ "course_link": "https://courses.analyticsvidhya.com/courses/hypothesis-testing-for-data-science-and-analytics"
469
+ }
470
+ ]
create_embeddings_together ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from pinecone import Pinecone, ServerlessSpec
3
+ import os
4
+ from dotenv import load_dotenv
5
+ import yaml
6
+ from together import Together
7
+
8
+
9
+
10
+ load_dotenv()
11
+
12
+ # Define file paths as constants
13
+ API_FILE_PATH = r"C:\Users\abhay\Analytics Vidhya\API.yml"
14
+ COURSES_FILE_PATH = r"C:\Users\abhay\Analytics Vidhya\courses.json"
15
+
16
+ def load_api_keys(api_file_path):
17
+ """Loads API keys from a YAML file."""
18
+ with open(api_file_path, 'r') as f:
19
+ api_keys = yaml.safe_load(f)
20
+ return api_keys
21
+
22
+
23
+ def load_course_data(json_file_path):
24
+ """Loads course data from a JSON file."""
25
+ with open(json_file_path, 'r') as f:
26
+ course_data = json.load(f)
27
+ return course_data
28
+
29
+
30
+ def prepare_for_embedding(course_data):
31
+ """Combines relevant course fields for embedding."""
32
+ prepared_data = []
33
+ for i, course in enumerate(course_data):
34
+ combined_text = f"Title: {course.get('title', '')}, Description: {course.get('description', '')}"
35
+ prepared_data.append(
36
+ {
37
+ "course_id": i,
38
+ "text": combined_text,
39
+ "course_link": course.get("course_link"),
40
+ "image_url": course.get("image_url"),
41
+ "title": course.get("title"),
42
+ }
43
+ )
44
+ return prepared_data
45
+
46
+ # --- Generate Embeddings using Together AI Model ---
47
+ def generate_embeddings(texts, together_api_key):
48
+ """Generates embeddings using Together AI model directly."""
49
+ client = Together(api_key=together_api_key)
50
+ embeddings = []
51
+ for text in texts:
52
+ response = client.embeddings.create(
53
+ model="WhereIsAI/UAE-Large-V1", input=text
54
+ )
55
+ embeddings.append(response.data[0].embedding)
56
+ return embeddings
57
+
58
+ # --- Initialize Pinecone ---
59
+ def initialize_pinecone(pinecone_api_key, pinecone_env):
60
+ """Initializes Pinecone with API key and environment."""
61
+ pc = Pinecone(api_key=pinecone_api_key)
62
+ return pc
63
+
64
+ # --- Upsert Embeddings into Pinecone ---
65
+ def upsert_to_pinecone(pinecone_instance, index_name, prepared_data, embeddings):
66
+ """Upserts vectors into a Pinecone index."""
67
+ index = pinecone_instance.Index(index_name)
68
+ vectors_to_upsert = []
69
+ for i, item in enumerate(prepared_data):
70
+ vector = embeddings[i]
71
+ metadata = {
72
+ "course_id": item["course_id"],
73
+ "text": item["text"],
74
+ "course_link": item["course_link"],
75
+ "image_url": item["image_url"],
76
+ "title": item["title"],
77
+ }
78
+ vectors_to_upsert.append((str(item["course_id"]), vector, metadata))
79
+ index.upsert(vectors=vectors_to_upsert)
80
+
81
+
82
+ # --- Main Function ---
83
+ def main():
84
+ try:
85
+
86
+ api_keys = load_api_keys(API_FILE_PATH)
87
+ together_api_key = api_keys["together_ai_api_key"]
88
+ pinecone_api_key = api_keys["pinecone_api_key"]
89
+ pinecone_env = api_keys["pinecone_env"]
90
+
91
+
92
+ course_data = load_course_data(COURSES_FILE_PATH)
93
+
94
+
95
+ prepared_data = prepare_for_embedding(course_data)
96
+ texts_for_embedding = [item["text"] for item in prepared_data]
97
+
98
+
99
+ print("Generating embeddings...")
100
+ embeddings = generate_embeddings(texts_for_embedding, together_api_key)
101
+
102
+
103
+ print("Initializing Pinecone...")
104
+ pinecone_instance = initialize_pinecone(pinecone_api_key, pinecone_env)
105
+
106
+
107
+ index_name = os.getenv("PINECONE_INDEX_NAME") or api_keys.get("pinecone_index_name")
108
+ if not index_name:
109
+ raise ValueError("Pinecone index name not found in environment variables or API.yml")
110
+
111
+
112
+ if index_name not in pinecone_instance.list_indexes().names():
113
+ pinecone_instance.create_index(
114
+ name=index_name,
115
+ dimension=1024, # Dimension for UAE-Large-V1
116
+ metric='cosine'
117
+ )
118
+
119
+ # Upsert embeddings into Pinecone
120
+ print("Upserting embeddings to Pinecone...")
121
+ upsert_to_pinecone(pinecone_instance, index_name, prepared_data, embeddings)
122
+
123
+ print("Embeddings generated and upserted to Pinecone successfully!")
124
+
125
+ except Exception as e:
126
+ print(f"An error occurred: {str(e)}")
127
+
128
+ if __name__ == "__main__":
129
+ main()
llm_retrieval_conversation_rerank.py ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+ from dotenv import load_dotenv
4
+ import yaml
5
+ from together import Together
6
+ from langchain.llms.together import Together as TogetherLLM
7
+ from langchain.prompts import PromptTemplate
8
+ from langchain.schema.runnable import RunnablePassthrough
9
+ from langchain.schema.output_parser import StrOutputParser
10
+ from pinecone import Pinecone
11
+ from typing import List, Dict
12
+ import cohere
13
+ load_dotenv()
14
+
15
+
16
+ API_FILE_PATH = r"C:\Users\abhay\Analytics Vidhya\API.yml"
17
+ COURSES_FILE_PATH = r"C:\Users\abhay\Analytics Vidhya\courses.json"
18
+
19
+ # Global list to store conversation history
20
+ conversation_history: List[Dict[str, str]] = []
21
+
22
+ def load_api_keys(api_file_path):
23
+ """Loads API keys from a YAML file."""
24
+ with open(api_file_path, 'r') as f:
25
+ api_keys = yaml.safe_load(f)
26
+ return api_keys
27
+
28
+ def generate_query_embedding(query, together_api_key):
29
+ """Generates embedding for the user query."""
30
+ client = Together(api_key=together_api_key)
31
+ response = client.embeddings.create(
32
+ model="WhereIsAI/UAE-Large-V1", input=query
33
+ )
34
+ return response.data[0].embedding
35
+
36
+ def initialize_pinecone(pinecone_api_key):
37
+ """Initializes Pinecone with API key."""
38
+ return Pinecone(api_key=pinecone_api_key)
39
+
40
+ def pinecone_similarity_search(pinecone_instance, index_name, query_embedding, top_k=10):
41
+ """Performs a similarity search in Pinecone and increase top k for reranking."""
42
+ try:
43
+ index = pinecone_instance.Index(index_name)
44
+ results = index.query(vector=query_embedding, top_k=top_k, include_metadata=True)
45
+ if not results.matches:
46
+ return None
47
+ return results
48
+ except Exception as e:
49
+ print(f"Error during similarity search: {e}")
50
+ return None
51
+
52
+ def create_prompt_template():
53
+ """Creates a prompt template for LLM."""
54
+ template = """You are a helpful AI assistant that provides information on courses.
55
+ Based on the following context, conversation history, and new user query,
56
+ suggest relevant courses and explain why they might be useful, or respond accordingly if the user query is unrelated.
57
+ If no relevant courses are found, please indicate that.
58
+
59
+ Conversation History:
60
+ {conversation_history}
61
+
62
+ Context: {context}
63
+ User Query: {query}
64
+
65
+ Response: Let me help you find relevant courses based on your query.
66
+ """
67
+ return PromptTemplate(template=template, input_variables=["context", "query", "conversation_history"])
68
+
69
+ def initialize_llm(together_api_key):
70
+ """Initializes Together LLM."""
71
+ return TogetherLLM(
72
+ model="mistralai/Mixtral-8x7B-Instruct-v0.1",
73
+ together_api_key=together_api_key,
74
+ temperature=0,
75
+ max_tokens=250
76
+ )
77
+
78
+ def create_chain(llm, prompt):
79
+ """Creates a chain using the new RunnableSequence approach."""
80
+ chain = (
81
+ {"context": RunnablePassthrough(), "query": RunnablePassthrough(), "conversation_history": RunnablePassthrough()}
82
+ | prompt
83
+ | llm
84
+ | StrOutputParser()
85
+ )
86
+ return chain
87
+
88
+
89
+ def initialize_cohere_client(cohere_api_key):
90
+ """Initializes the Cohere client."""
91
+ return cohere.ClientV2(api_key=cohere_api_key)
92
+
93
+
94
+ def rerank_results(cohere_client, query, documents, top_n=3):
95
+ """Reranks documents using Cohere."""
96
+ try:
97
+ results = cohere_client.rerank(
98
+ query=query,
99
+ documents=documents,
100
+ top_n=top_n,
101
+ model="rerank-english-v3.0",
102
+ )
103
+ return results
104
+ except Exception as e:
105
+ print(f"Error reranking results: {e}")
106
+ return None
107
+
108
+ def generate_llm_response(chain, query, retrieved_data, history, cohere_client):
109
+ """Generates an LLM response based on context and conversation history."""
110
+ try:
111
+ if not retrieved_data or not retrieved_data.matches:
112
+ return "I couldn't find any relevant courses matching your query. Please try a different search term."
113
+
114
+ # Prepare documents for reranking
115
+ documents = []
116
+ for match in retrieved_data.matches:
117
+ metadata = match.metadata
118
+ if metadata:
119
+ documents.append(
120
+ { "text" :f"Title: {metadata.get('title', 'No title')}\nDescription: {metadata.get('text', 'No description')}\nLink: {metadata.get('course_link', 'No link')}"
121
+ }
122
+ )
123
+
124
+ if not documents:
125
+ return "I found some matches but couldn't extract course information. Please try again."
126
+
127
+ # Rerank the documents
128
+ reranked_results = rerank_results(cohere_client, query, documents)
129
+
130
+ if not reranked_results:
131
+ return "I couldn't rerank the results, please try again."
132
+
133
+ # Prepare context from reranked results
134
+ context_parts = []
135
+ for result in reranked_results.results:
136
+ context_parts.append(documents[result.index]["text"])
137
+
138
+ context = "\n\n".join(context_parts)
139
+
140
+ # Format conversation history
141
+ formatted_history = "\n".join(f"User: {item['user']}\nAssistant: {item['assistant']}" for item in history) if history else "No previous conversation."
142
+
143
+ response = chain.invoke({"context": context, "query": query, "conversation_history":formatted_history})
144
+ return response
145
+
146
+ except Exception as e:
147
+ print(f"Error generating response: {e}")
148
+ return "I encountered an error while generating the response. Please try again."
149
+
150
+
151
+ def check_context_similarity(query_embedding, previous_query_embedding, threshold=0.7):
152
+ """Checks if the new query is related to the previous one."""
153
+ if not previous_query_embedding:
154
+ return False # First query, no previous embedding to compare
155
+
156
+ from numpy import dot
157
+ from numpy.linalg import norm
158
+
159
+ cos_sim = dot(query_embedding, previous_query_embedding) / (norm(query_embedding) * norm(previous_query_embedding))
160
+ return cos_sim > threshold
161
+
162
+ def main():
163
+ global conversation_history
164
+ previous_query_embedding = None
165
+
166
+ try:
167
+
168
+ api_keys = load_api_keys(API_FILE_PATH)
169
+ together_api_key = api_keys["together_ai_api_key"]
170
+ pinecone_api_key = api_keys["pinecone_api_key"]
171
+ index_name = api_keys["pinecone_index_name"]
172
+ cohere_api_key = api_keys["cohere_api_key"]
173
+ print("Initializing services...")
174
+
175
+ # Initialize Pinecone
176
+ pinecone_instance = initialize_pinecone(pinecone_api_key)
177
+
178
+ # Initialize Together LLM
179
+ llm = initialize_llm(together_api_key)
180
+
181
+ # Initialize Cohere client
182
+ cohere_client = initialize_cohere_client(cohere_api_key)
183
+
184
+
185
+
186
+ prompt = create_prompt_template()
187
+
188
+ # Create chain
189
+ chain = create_chain(llm, prompt)
190
+
191
+ print("Ready to process queries!")
192
+
193
+ while True:
194
+
195
+ user_query = input("\nEnter your query (or 'quit' to exit): ").strip()
196
+
197
+ if user_query.lower() == 'quit':
198
+ break
199
+
200
+ if not user_query:
201
+ print("Please enter a valid query.")
202
+ continue
203
+
204
+ try:
205
+ print("Generating query embedding...")
206
+ query_embedding = generate_query_embedding(user_query, together_api_key)
207
+
208
+ # Check context similarity
209
+ if previous_query_embedding and check_context_similarity(query_embedding, previous_query_embedding):
210
+ print("Continuing the previous conversation...")
211
+ else:
212
+ print("Starting a new conversation...")
213
+ conversation_history = [] # Clear history for a new conversation
214
+
215
+ print("Searching for relevant courses...")
216
+ pinecone_results = pinecone_similarity_search(
217
+ pinecone_instance, index_name, query_embedding
218
+ )
219
+
220
+ print("Generating response...")
221
+ llm_response = generate_llm_response(chain, user_query, pinecone_results, conversation_history, cohere_client)
222
+
223
+ print("\nResponse:")
224
+ print(llm_response)
225
+ print("\n" + "="*50)
226
+
227
+ # Update conversation history
228
+ conversation_history.append({"user": user_query, "assistant": llm_response})
229
+ previous_query_embedding = query_embedding # Save for next turn
230
+
231
+ except Exception as e:
232
+ print(f"Error processing query: {e}")
233
+ print("Please try again with a different query.")
234
+
235
+ except Exception as e:
236
+ print(f"An error occurred during initialization: {str(e)}")
237
+
238
+ if __name__ == "__main__":
239
+ main()
requriments.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ together
2
+ pinecone-client
3
+ pyyaml
4
+ python-dotenv
5
+ langchain
6
+ numpy
7
+ cohere
8
+ gradio
scrape_data.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ from bs4 import BeautifulSoup
3
+ import json
4
+ import os
5
+
6
+
7
+ BASE_URL = "https://courses.analyticsvidhya.com/collections/courses?page="
8
+
9
+
10
+ OUTPUT_FILE = os.path.join(os.path.dirname(__file__), "../data/courses.json")
11
+
12
+ def scrape_courses():
13
+ courses = []
14
+
15
+
16
+ for page in range(1, 10):
17
+
18
+ URL = f"{BASE_URL}{page}"
19
+ print(f"Scraping URL: {URL}")
20
+
21
+
22
+ response = requests.get(URL)
23
+ print(f"Response status: {response.status_code}")
24
+
25
+ # Check if request was successful
26
+ if response.status_code != 200:
27
+ print(f"Failed to fetch the webpage. Status code: {response.status_code}")
28
+ continue
29
+
30
+
31
+ soup = BeautifulSoup(response.content, "html.parser")
32
+
33
+ # Locate course containers
34
+ course_items = soup.find_all("li", class_="products__list-item")
35
+ print(f"Found {len(course_items)} course containers on page {page}.")
36
+
37
+ # Loop through each course container to extract details
38
+ for item in course_items:
39
+ # Extract course link
40
+ link_tag = item.find("a", class_="course-card")
41
+ course_link = link_tag.get("href", "#") if link_tag else "#"
42
+ if not course_link.startswith("http"):
43
+ course_link = f"https://courses.analyticsvidhya.com{course_link}"
44
+
45
+ # Extract course title
46
+ title_tag = link_tag.find("h3") if link_tag else None
47
+ title = title_tag.text.strip() if title_tag else "No Title"
48
+
49
+ # Extract course image
50
+ image_tag = link_tag.find("img", class_="course-card__img") if link_tag else None
51
+ image_url = image_tag.get("src", "No Image URL") if image_tag else "No Image URL"
52
+
53
+ # Extract course description
54
+ lesson_tag = link_tag.find("span", class_="course-card__lesson-count") if link_tag else None
55
+ description = lesson_tag.text.strip() if lesson_tag else "No Description"
56
+
57
+ # Add the extracted details to the list
58
+ courses.append({
59
+ "title": title,
60
+ "description": description,
61
+ "image_url": image_url,
62
+ "course_link": course_link,
63
+ })
64
+
65
+ # Debugging: Print the first few courses
66
+ print(f"Scraped {len(courses)} courses.")
67
+ for course in courses[:3]:
68
+ print(course)
69
+
70
+ # Ensure the directory for the output file exists
71
+ os.makedirs(os.path.dirname(OUTPUT_FILE), exist_ok=True)
72
+
73
+ # Save the course data to a JSON file
74
+ with open(OUTPUT_FILE, "w") as f:
75
+ json.dump(courses, f, indent=4)
76
+
77
+ print(f"Data saved to {os.path.abspath(OUTPUT_FILE)}")
78
+
79
+ if __name__ == "__main__":
80
+ scrape_courses()