ishworrsubedii commited on
Commit
0cd4e64
·
1 Parent(s): 1b75dcb

add: use case 1 and streamlit ui for it

Browse files
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ .idea
2
+ __pycache__
3
+ *.pyc
4
+ experience
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ from src.pipeline.main import LearnableAI
4
+ import streamlit as st
5
+ from src.pipeline.main import LearnableAI
6
+
7
+
8
+ def main():
9
+ st.title("LearnableAI Interface")
10
+
11
+ learnable_ai = LearnableAI()
12
+
13
+ words = st.text_input("Enter your words:", "")
14
+ interest = st.text_input("Enter your interest:", "")
15
+ difficulty = st.selectbox(
16
+ "Select difficulty level:",
17
+ ("very simple", "simple", "hard", "very hard")
18
+ )
19
+
20
+ if st.button("Process with LearnableAI"):
21
+ if words and interest: # Only show warning if fields are empty
22
+ try:
23
+ result = learnable_ai.word_to_sentence(
24
+ words=list(words),
25
+ interest=interest,
26
+ difficulties=difficulty
27
+ )
28
+
29
+ st.write("### Results")
30
+ st.write(result)
31
+
32
+ except Exception as e:
33
+ st.error(f"An error occurred: {str(e)}")
34
+ else:
35
+ st.warning("Please fill in both words and interest fields!")
36
+
37
+
38
+ if __name__ == "__main__":
39
+ main()
src/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ """
2
+ project @ LearnableAI
3
+ created @ 2025-01-16
4
+ author @ github.com/ishworrsubedii
5
+ """
src/pipeline/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ """
2
+ project @ LearnableAI
3
+ created @ 2025-01-17
4
+ author @ github.com/ishworrsubedii
5
+ """
src/pipeline/main.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ project @ LearnableAI
3
+ created @ 2025-01-17
4
+ author @ github.com/ishworrsubedii
5
+ """
6
+ import os
7
+
8
+ from groq import Groq
9
+
10
+ from src.services.use_case_one.word_to_sentence import UseCaseOne
11
+
12
+
13
+ class LearnableAI:
14
+ def __init__(self):
15
+ self.groq_client = Groq(api_key=os.getenv('GROQ_API_KEY'))
16
+ self.use_case_one = UseCaseOne(client=self.groq_client)
17
+
18
+ def word_to_sentence(self, interest: str, difficulties: str, words: list):
19
+ return self.use_case_one.generate_educational_content(interest, difficulties, words)
src/services/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ """
2
+ project @ LearnableAI
3
+ created @ 2025-01-17
4
+ author @ github.com/ishworrsubedii
5
+ """
src/services/use_case_one/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ """
2
+ project @ LearnableAI
3
+ created @ 2025-01-17
4
+ author @ github.com/ishworrsubedii
5
+ """
src/services/use_case_one/word_to_sentence.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ project @ LearnableAI
3
+ created @ 2025-01-16
4
+ author @ github.com/ishworrsubedii
5
+ """
6
+ import json
7
+ from typing import List, Dict
8
+
9
+
10
+ class UseCaseOne:
11
+ def __init__(self, client):
12
+ self.client = client
13
+
14
+ def generate_educational_content(self, interest: str, difficulties: str, words: List[str]) -> Dict:
15
+ prompt = f"""
16
+ As an educational content specialist for children with ADHD, create engaging learning material that adapts to different difficulty levels.
17
+
18
+ Interest area: {interest}
19
+ Difficulty level: {difficulties} (simple/hard)
20
+ Words to use: {', '.join(words)}
21
+
22
+ Please provide the following in a JSON format:
23
+ {{
24
+ "sentences": {{
25
+ "{difficulties}": [
26
+ "Three very simple sentences using the provided words, focused on basic understanding",
27
+ "Each sentence should be short and use straightforward language",
28
+ "Connect each sentence to the interest area"
29
+ ],
30
+ }},
31
+ "learning_objectives": [
32
+ "Three clear objectives that match the chosen difficulty level",
33
+ "Focus on word usage and comprehension",
34
+ "Include measurable outcomes"
35
+ ],
36
+ "activities": [
37
+ "Two interactive activities that maintain attention",
38
+ "Activities should match the difficulty level",
39
+ "Include clear instructions"
40
+ ]
41
+ }}
42
+
43
+ Ensure all content is:
44
+ - Clear and direct
45
+ - Highly visual and descriptive
46
+ - Strongly connected to the interest area
47
+ - Appropriate for the chosen difficulty level
48
+ - ADHD-friendly (engaging, focused, and interactive)
49
+ - Uses concrete examples and real-world connections
50
+
51
+ For simple difficulty:
52
+ - Use basic sentence structures
53
+ - Limit to 5-7 words per sentence
54
+ - Focus on direct cause and effect
55
+ - Use familiar contexts
56
+
57
+ For hard difficulty:
58
+ - Use compound sentences
59
+ - Include 8-12 words per sentence
60
+ - Add descriptive details
61
+ - Introduce new contexts within the interest area
62
+
63
+ Return ONLY a valid JSON object with the structure shown above. Do not include any additional text or explanations.
64
+ """
65
+
66
+ try:
67
+ completion = self.client.chat.completions.create(
68
+ messages=[{
69
+ "role": "system",
70
+ "content": "You are an expert in creating educational content for children with ADHD."
71
+ },
72
+ {
73
+ "role": "user",
74
+ "content": prompt
75
+ }],
76
+ model="mixtral-8x7b-32768",
77
+ temperature=1.0, # if increase temperature, it will generate more creative content
78
+ max_tokens=1000,
79
+ top_p=1,
80
+ stream=False
81
+ )
82
+ print(completion.choices[0].message.content)
83
+
84
+ content = json.loads(completion.choices[0].message.content)
85
+ return content
86
+
87
+ except Exception as e:
88
+ return {
89
+ "error": f"Error generating content: {str(e)}",
90
+ "status": "failed"
91
+ }
92
+
93
+ def format_response(self, content: Dict) -> Dict:
94
+ return {
95
+ "educational_content": {
96
+ "sentences": content.get("sentences", []),
97
+ "image_prompts": content.get("image_prompts", []),
98
+ "learning_objectives": content.get("learning_objectives", []),
99
+ "difficulty_level": content.get("difficulty_level", ""),
100
+ "activities": content.get("attention_maintaining_activities", [])
101
+ },
102
+ "metadata": {
103
+ "status": "success",
104
+ "model": "mixtral-8x7b-32768",
105
+ "version": "1.0"
106
+ }
107
+ }
src/services/use_case_three/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ """
2
+ project @ LearnableAI
3
+ created @ 2025-01-17
4
+ author @ github.com/ishworrsubedii
5
+ """
src/services/use_case_two/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ """
2
+ project @ LearnableAI
3
+ created @ 2025-01-17
4
+ author @ github.com/ishworrsubedii
5
+ """