now makes basic recommendations
Browse files- app.py +1 -1
- plan/recommend.py +9 -7
app.py
CHANGED
@@ -29,7 +29,7 @@ def train_products():
|
|
29 |
@app.route("/plan/recommend", methods=['GET','POST'])
|
30 |
def recommend_plan_steps():
|
31 |
from plan.recommend import recommend
|
32 |
-
return recommend();
|
33 |
|
34 |
#from plan.recommend import recommend
|
35 |
#recommend();
|
|
|
29 |
@app.route("/plan/recommend", methods=['GET','POST'])
|
30 |
def recommend_plan_steps():
|
31 |
from plan.recommend import recommend
|
32 |
+
return recommend(request.values);
|
33 |
|
34 |
#from plan.recommend import recommend
|
35 |
#recommend();
|
plan/recommend.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
def recommend():
|
2 |
|
3 |
from typing import Optional, List
|
4 |
|
@@ -8,7 +8,7 @@ def recommend():
|
|
8 |
"""Information about a suggested goal."""
|
9 |
|
10 |
goal: Optional[str] = Field(default=None, description="a SMART target for the user")
|
11 |
-
timeframe: Optional[str] = Field(default=None, description="whether the goal is
|
12 |
|
13 |
class GoalList(BaseModel):
|
14 |
"""A list of goals the user should accomplish to achieve an ambition."""
|
@@ -34,7 +34,7 @@ def recommend():
|
|
34 |
You should provide a list of six things that they could do to help them to achieve that ambition.
|
35 |
These should take the form of SMART targets.
|
36 |
|
37 |
-
You should recommend three
|
38 |
They should be achievable before they graduate.
|
39 |
You should not recommend that they graduate with a degree other than the one they are doing
|
40 |
But you can suggest follow on courses, such as Masters degrees or professional qualifications.
|
@@ -50,9 +50,11 @@ def recommend():
|
|
50 |
|
51 |
runnable = prompt | llm.with_structured_output(schema=GoalList)
|
52 |
|
53 |
-
|
54 |
-
response = runnable.invoke({"text":
|
|
|
|
|
55 |
|
56 |
-
print(response);
|
57 |
|
58 |
-
return
|
|
|
1 |
+
def recommend(payload):
|
2 |
|
3 |
from typing import Optional, List
|
4 |
|
|
|
8 |
"""Information about a suggested goal."""
|
9 |
|
10 |
goal: Optional[str] = Field(default=None, description="a SMART target for the user")
|
11 |
+
timeframe: Optional[str] = Field(default=None, description="whether the goal is now, soon, or during")
|
12 |
|
13 |
class GoalList(BaseModel):
|
14 |
"""A list of goals the user should accomplish to achieve an ambition."""
|
|
|
34 |
You should provide a list of six things that they could do to help them to achieve that ambition.
|
35 |
These should take the form of SMART targets.
|
36 |
|
37 |
+
You should recommend three targets to do now, two to do soon and one to do during their time at university
|
38 |
They should be achievable before they graduate.
|
39 |
You should not recommend that they graduate with a degree other than the one they are doing
|
40 |
But you can suggest follow on courses, such as Masters degrees or professional qualifications.
|
|
|
50 |
|
51 |
runnable = prompt | llm.with_structured_output(schema=GoalList)
|
52 |
|
53 |
+
input = payload.get("input") or ""
|
54 |
+
response = runnable.invoke({"text": input})
|
55 |
+
|
56 |
+
print(input)
|
57 |
|
58 |
+
print(response.dict()['response']);
|
59 |
|
60 |
+
return response.dict()['response'];
|