Rakshitjan commited on
Commit
6fe69e0
·
verified ·
1 Parent(s): 3b9971b

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +96 -36
main.py CHANGED
@@ -1,37 +1,97 @@
1
- from fastapi import FastAPI
2
- from groq import Groq
3
-
4
- app = FastAPI()
5
-
6
- client = Groq(
7
- api_key="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",
8
- )
9
-
10
- @app.post("/chat")
11
- async def chat(query: str):
12
- chat_completion = client.chat.completions.create(
13
- messages=[
14
- {
15
- "role": "system",
16
- "content": """Generate me 10 MCQ type questions on the topic asked by the user of Joint Entrance Examination level and also explain the solution of each problem step-wise. And also give a hardness rating out of 100 , The questions should have difficulty matching with the level of JEE mains and advanced.
17
- Give me questions which are of very high difficulty level.
18
-
19
- Structure of output :
20
- Question : "<Question String>"
21
- Options : "<option 1, option 2, option 3, option 4>"
22
- Answer : "<answer String>"
23
- Hardness rating : "<hardness number>"
24
- Solution : "<solution String>"
25
-
26
- Make sure you provide VERY VERY Advanced level questions which cover the given topic properly , also the solutions or Hints has to be really relevant and explainatory.
27
- """
28
- },
29
- {
30
- "role": "user",
31
- "content": query,
32
- }
33
- ],
34
- model="llama3-70b-8192",
35
- )
36
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  return {"response": chat_completion.choices[0].message.content}
 
1
+ from fastapi import FastAPI
2
+ from groq import Groq
3
+
4
+ app = FastAPI()
5
+
6
+ client = Groq(
7
+ api_key="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",
8
+ )
9
+
10
+ @app.post("/chat")
11
+ async def chat(query: str):
12
+ chat_completion = client.chat.completions.create(
13
+ messages=[
14
+ {
15
+ "role": "system",
16
+ "content": """Generate me 10 MCQ type questions on the topic asked by the user of Joint Entrance Examination level and also explain the solution of each problem step-wise. And also give a hardness rating out of 100 , The questions should have difficulty matching with the level of JEE mains and advanced.
17
+ Give me questions which are of very high difficulty level.
18
+ Make sure you provide VERY VERY Advanced level questions which cover the given topic properly , also the solutions or Hints has to be really relevant and explainatory.
19
+ Expected output format:
20
+ {"response":"Here are 10 MCQ type questions on the topic of Equilibrium at the level of Joint
21
+ Entrance Examination (JEE):\n\n**Question 1:**\nQuestion: A container having a fixed volume
22
+ of 1 liter is filled with 1 mole of a gas. The temperature of the system is increased from 27°C to
23
+ 127°C. The entropy change of the system is (R = 8.314 J/mol-K)\nOptions: 23.4 J/mol-K, 46.8
24
+ J/mol-K, 29.3 J/mol-K, 58.6 J/mol-K\nAnswer: 23.4 J/mol-K\nHardness rating: 80\nSolution: The
25
+ entropy change of an ideal gas can be calculated using the formula ΔS = nR ln(V2/V1) + nCp
26
+ ln(T2/T1). Since the volume is constant, the first term is zero. Plugging in the values, we get ΔS =
27
+ 1 Ô 8.314 Ô ln(400/300) = 23.4 J/mol-K.\n\n**Question 2:**\nQuestion: A gas phase reaction A
28
+ └ B is in equilibrium at a certain temperature. If the initial concentration of A is 2M and the
29
+ equilibrium concentration of A is 1.5M, what is the equilibrium constant (Kc) of the
30
+ reaction?\nOptions: 0.25, 1/3, 0.5, 1/4\nAnswer: 0.5\nHardness rating: 70\nSolution: Let the
31
+ initial concentration of A be a, and the equilibrium concentrations of A and B be a-x and x
32
+ respectively. Then, Kc = [B]/[A] = x/(a-x). Plugging in the values, we get Kc = (0.5)/(1.5) =
33
+ 0.5.\n\n**Question 3:**\nQuestion: A 1L container is divided into two compartments of equal
34
+ volume by a piston. One compartment contains 1 mole of an ideal gas at 300K, and the other
35
+ compartment is evacuated. If the piston is removed and the system is allowed to reach
36
+ equilibrium, what is the final temperature of the system? (R = 8.314 J/mol-K)\nOptions: 225 K,
37
+ 300 K, 450 K, 600 K\nAnswer: 300 K\nHardness rating: 90\nSolution: Since the system is
38
+ isolated, the total internal energy remains constant. The initial energy of the system is (3/2)nRT =
39
+ (3/2) Ô 1 Ô 8.314 Ô 300 = 3741 J. After the piston is removed, the gas expands to double its
40
+ volume, and the final temperature can be calculated using the formula U = (3/2)nRT. Plugging in
41
+ the values, we get T = 300 K.\n\n**Question 4:**\nQuestion: The equilibrium constant (Kp) for
42
+ the reaction CO(g) + Cl2(g) └ COCl2(g) is 3.4 Ô 10^3 at 700K. If the initial pressures of CO and
43
+ Cl2 are 0.1 atm and 0.2 atm respectively, what is the equilibrium pressure of COCl2?\nOptions:
44
+ 0.68 atm, 1.36 atm, 2.04 atm, 3.4 atm\nAnswer: 0.68 atm\nHardness rating: 85\nSolution: Let
45
+ the initial pressures of CO, Cl2, and COCl2 be p, 2p, and 0 respectively. At equilibrium, the
46
+ pressures are p-x, 2p-x, and x respectively. The equilibrium constant can be expressed as Kp =
47
+ x/(p-x)(2p-x). Plugging in the values, we get x = 0.68 atm.\n\n**Question 5:**\nQuestion: The
48
+ standard Gibbs free energy change (ΔG°) for a reaction is -20 kJ/mol at 298K. What is the
49
+ equilibrium constant (K) for the reaction?\nOptions: 10^3, 10^4, 10^5, 10^6\nAnswer:
50
+ 10^4\nHardness rating: 75\nSolution: The equilibrium constant can be calculated using the
51
+ formula ΔG° = -RT lnK. Plugging in the values, we get lnK = 20/(-8.314 Ô 298) = 8.14. Therefore,
52
+ K = 10^4.\n\n**Question 6:**\nQuestion: A reaction A + B └ C + D has an equilibrium constant
53
+ (Kc) of 4 at a certain temperature. If the initial concentrations of A, B, and C are 2M, 3M, and 1M
54
+ respectively, what is the equilibrium concentration of D?\nOptions: 1M, 2M, 3M, 4M\nAnswer:
55
+ 2M\nHardness rating: 80\nSolution: Let the equilibrium concentrations of A, B, C, and D be a-x,
56
+ b-x, c+x, and x respectively. The equilibrium constant can be expressed as Kc = (c+x)(x)/(a-x)(bx) = 4. Plugging in the values, we get x = 2M.\n\n**Question 7:**\nQuestion: The equilibrium
57
+ constant (Kp) for the reaction H2(g) + I2(g) └ 2HI(g) is 50 at a certain temperature. If the initial
58
+ pressures of H2 and I2 are 1 atm and 2 atm respectively, what is the degree of dissociation of HI
59
+ at equilibrium?\nOptions: 0.4, 0.6, 0.8, 0.9\nAnswer: 0.8\nHardness rating: 90\nSolution: Let
60
+ the initial pressures of H2, I2, and HI be p, 2p, and 0 respectively. At equilibrium, the pressures
61
+ are p-x, 2p-x, and 2x respectively. The equilibrium constant can be expressed as Kp = (2x)^2/(px)(2p-x) = 50. Plugging in the values, we get x = 0.8p. Therefore, the degree of dissociation is
62
+ 0.8.\n\n**Question 8:**\nQuestion: A reaction A └ B is in equilibrium at a certain
63
+ temperature. If the entropy of A and B are 200 J/mol-K and 250 J/mol-K respectively, what is the
64
+ equilibrium constant (K) of the reaction?\nOptions: 2, 4, 6, 8\nAnswer: 4\nHardness rating:
65
+ 80\nSolution: The equilibrium constant can be calculated using the formula ΔG° = -RT lnK =
66
+ ΔH° - TΔS°. Since the reaction is at equilibrium, ΔG° = 0. Plugging in the values, we get
67
+ ΔH° = TΔS°. Therefore, K = exp(ΔS°/R) = 4.\n\n**Question 9:**\nQuestion: The equilibrium
68
+ constant (Kc) for the reaction A + 2B └ C is 10 at a certain temperature. If the initial
69
+ concentrations of A and B are 1M and 2M respectively, what is the equilibrium concentration of
70
+ C?\nOptions: 1M, 2M, 4M, 6M\nAnswer: 2M\nHardness rating: 85\nSolution: Let the equilibrium
71
+ concentrations of A, B, and C be a-x, b-2x, and x respectively. The equilibrium constant can be
72
+ expressed as Kc = x/(a-x)(b-2x)^2 = 10. Plugging in the values, we get x = 2M.\n\n**Question
73
+ 10:**\nQuestion: A 2L container is divided into two compartments of equal volume by a piston.
74
+ One compartment contains 1 mole of an ideal gas at 300K, and the other compartment is
75
+ evacuated. If the piston is removed and the system is allowed to reach equilibrium, what is the
76
+ final entropy of the system? (R = 8.314 J/mol-K)\nOptions: 23.4 J/mol-K, 46.8 J/mol-K, 58.6
77
+ J/mol-K, 69.4 J/mol-K\nAnswer: 46.8 J/mol-K\nHardness rating: 95\nSolution: Since the system
78
+ is isolated, the total internal energy remains constant. The initial energy of the system is
79
+ (3/2)nRT = (3/2) Ô 1 Ô 8.314 Ô 300 = 3741 J. After the piston is removed, the gas expands to
80
+ double its volume, and the final entropy can be calculated using the formula ΔS = nR ln(V2/V1)
81
+ + nCp ln(T2/T1). Since the temperature remains constant, the second term is zero. Plugging in
82
+ the values, we get ΔS = 1 Ô 8.314 Ô ln(2) = 5.763 J/mol-K. Therefore, the final entropy is 23.4 +
83
+ 5.763 = 46.8 J/mol-K."}
84
+
85
+ VERY IMPORATANT : MAKE SURE YOU STRICTLT FOLLOW THE OUTPUT FORMAT .
86
+
87
+ """
88
+ },
89
+ {
90
+ "role": "user",
91
+ "content": query,
92
+ }
93
+ ],
94
+ model="llama3-70b-8192",
95
+ )
96
+
97
  return {"response": chat_completion.choices[0].message.content}