Rakshitjan commited on
Commit
527ea75
·
verified ·
1 Parent(s): 0fde882

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile +15 -0
  2. main.py +114 -0
  3. requirements.txt +0 -0
Dockerfile ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
+
4
+ FROM python:3.9
5
+
6
+ WORKDIR /code
7
+
8
+ COPY ./requirements.txt /code/requirements.txt
9
+
10
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
11
+
12
+ COPY . .
13
+
14
+ CMD uvicorn main:app --port=8000 --host=0.0.0.0
15
+
main.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, HTTPException
2
+ from pydantic import BaseModel
3
+ import os
4
+ from groq import Groq
5
+ from dotenv import load_dotenv
6
+ from fastapi.middleware.cors import CORSMiddleware
7
+
8
+ app = FastAPI()
9
+ app.add_middleware(
10
+ CORSMiddleware,
11
+ allow_origins=["*"], # You can specify domains instead of "*" to restrict access
12
+ allow_credentials=True,
13
+ allow_methods=["*"], # Allows all HTTP methods (POST, GET, OPTIONS, etc.)
14
+ allow_headers=["*"], # Allows all headers
15
+ )
16
+ # Pydantic model for request
17
+ class LogsInput(BaseModel):
18
+ panicButtonLogs: str
19
+ journalLogs: str
20
+ testScoreLogs: str
21
+ socaOutput:str
22
+
23
+
24
+ # FastAPI route
25
+ @app.post("/analyze")
26
+ async def analyze_scores(input_data: LogsInput):
27
+ # Groq API call
28
+ api_key = os.getenv('GROQ_API_KEY')
29
+ if not api_key:
30
+ raise HTTPException(status_code=500, detail="Groq API key not found")
31
+
32
+ client = Groq(api_key=api_key)
33
+ sys_prompt = f"""
34
+ You are an advanced JEE expert which is known about the app usage of an user through logs of the app.
35
+ You will be given an SOCA (Strength, Oppurtunities, Challenges and Action Plan) output of the user that was previously generated based on academic and cognitive profile of the user.
36
+ The latest SOCA output of the user on the app is : {input_data.socaOutput}.
37
+ Now what you have to do is based on the app usage which will be given to you in the form of logs you have to generate another SOCA output for the user based on the last SOCA and app logs of the features I am giving you.
38
+ Make sure that we keep the structure same but add up nuances from the app usage logs also.
39
+
40
+ Feature 1 : Panic Button feature
41
+ -This feature is made on the app when a user panics about anything . The panic can be academic or non academic and when the user click on any panic button he/she journals their thoughts during that panic and hence we understand that this is the issue that the student is facing.
42
+ -The panic button feature logs of the student are {input_data.panicButtonLogs}.
43
+
44
+ Feature 2 : Daily Journal Feature
45
+ -This Feature is basically made for daily use of the user everyday the user comes to feature and enters about the 4 questions that we ask on the faeture.
46
+ - 1st Question : What went well today : Here the user tells us about what was best according to him today on study basis.
47
+ - 2nd Question : What could have went well today : Here the user tells us about what could have been better today for him on study basis.
48
+ - 3rd Question : Are you satisfied with your productivity : Here the user has three options : Yes, No and Maybe.
49
+ - 4th Question : Rate your productivity for today : Here the user rates his/her productivity out of 10
50
+
51
+ - The Daily Journal Logs of the user are : {input_data.journalLogs}.
52
+
53
+
54
+ Feature 3 : Tests Feature
55
+ - This is our in house test feature where the user can go and select the chapter and generate a dyanamic test of that chapter in real time with always newwer questions.
56
+ - The student gets 10 questions which are based on +4 marks for a right answer and -1 mark for a wrong answer.
57
+ - The overall marks of the user are out of 40.
58
+
59
+ - The test feature logs of the user are : {input_data.testScoreLogs}.
60
+
61
+ Output Structure:
62
+ SCO Analysis:
63
+ Strengths:
64
+ - List the student's strengths based on their strength skills
65
+ - Let the student now how they can use these strengths in their JEE preparation and exam to improve their score.
66
+ - Also tell them how do they improve their score more.
67
+ - Also tell them using the logs of the app usage of the user what are their strengths.
68
+ Opportunities:
69
+ - List the student's strengths based on their oppurtunities skills
70
+ - Suggest opportunities for improvement by leveraging the student's strengths and addressing their challenges.
71
+ - Recommend ways to enhance their score in the oppurtunities skills.
72
+ - Also tell them if they improve in these skills what opportunities they have in improving their scores.
73
+ - Also tell them using the logs of the app usage of the user what are their Oppurtunities.
74
+ Challenges:
75
+ - List the student's strengths based on their challenges skills
76
+ - Guide the student that these skills are basically the core area where they are lacking
77
+ - Tell them that if they continue not focusing upon them they might get far away from their JEE goal.
78
+ - - Also tell them using the logs of the app usage of the user what are their Challenges.
79
+ Action Plan:
80
+ - Provide a detailed plan to the student to improve in the challenges skills.
81
+ - Recommend targeted strategies, resources, and techniques to improve their challenges skills.
82
+ - Let them know if they improve these areas how it can help boost their scores and make their preparation more effective.
83
+ - Incorporate time management, revision, and test-taking strategies specific to JEE Mains and the identified subjects/topics/subtopics.
84
+
85
+ Things that LLM need to make sure:
86
+ 1) Your analysis and action plan should be comprehensive, consistent, and tailored to the individual student's responses while leveraging your knowledge of the JEE Mains exam context, the mapping of subjects/topics to general cognitive traits and skills, and the ability to identify overarching trends across related subjects/topics.
87
+ 2) Make sure you give the output that extracts the student.
88
+ 3) Make sure you give out output in bullet points.
89
+ 4) While entering a new line in the output use "\n" new line character.
90
+ 5) Make the output very much JEE (Joint Entrance Examination) based and give everything with context to Physics , Chemistry and Maths JEE syllabus.
91
+ 6) Use Italics, Bold and underline appropriately to improve the output more.
92
+ 7) Bold text where you are taking chapter names from Physics , Chemsitry and Maths only which are in syllabus of Joint Entrance Examination.
93
+ 8) Dont use "+" or any other special symbol whenever you want to break a line use "\n" to do it in the output.
94
+ 9) Make Sure that if you do not recieve logs for any feature , motivate the user to use that feature in action plan.
95
+ """
96
+
97
+
98
+ try:
99
+ chat_completion = client.chat.completions.create(
100
+ messages=[
101
+ {"role": "system", "content": sys_prompt},
102
+ {"role": "user", "content": f"Generate the SOCA analysis based on the Last SOCA Output and lOGS. MAKE SURE WE STRICTLY FOLLOW THE STRUCTURE."},
103
+ ],
104
+ model="llama3-70b-8192",
105
+ )
106
+ analysis = chat_completion.choices[0].message.content
107
+ except Exception as e:
108
+ raise HTTPException(status_code=500, detail=f"Error calling Groq API: {str(e)}")
109
+
110
+ return {"analysis": analysis}
111
+
112
+ if __name__ == "__main__":
113
+ import uvicorn
114
+ uvicorn.run(app, host="0.0.0.0", port=8000)
requirements.txt ADDED
Binary file (670 Bytes). View file