Skip to content

Commit

Permalink
shiii idk features
Browse files Browse the repository at this point in the history
  • Loading branch information
skitsbi committed Jul 31, 2023
1 parent c1cd5db commit 2366415
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public String generateMeal(String mealType) throws JsonMappingException, JsonPro
int prevBestOfN = openaiApiService.getBestofN();
Boolean success = false;
openaiApiService.setBestofN(prevBestOfN + 1);
while(!success&& i < 2)
while(!success&& i < 4)
{
mealJson =
objectMapper.readTree(openaiApiService.fetchMealResponse(mealType));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand All @@ -11,9 +12,11 @@
@Service
public class OpenaiPromptBuilder {

@Autowired
private SettingsService settingsService;
public String buildPrompt(String Type) throws JsonProcessingException {
String prompt = "";
String preferenceString ="";
String preferenceString =settingsService.ALL_SETTINGS;
prompt += buildContext(Type, preferenceString);
prompt += buildGoal();
prompt += buildFormat();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,46 @@ public class SettingsService {
@Autowired
private SettingsRepository SettingsRepository;

public String ALL_SETTINGS;

public SettingsModel getSettings(String token){
String email = jwtService.extractUserEmail(token);
return SettingsRepository.getSettings(email);
SettingsModel settingsModel = SettingsRepository.getSettings(email);
ALL_SETTINGS = makeString(settingsModel);
return settingsModel;
}

public void updateSettings(SettingsModel request, String token){
this.makeString(request);
String email = jwtService.extractUserEmail(token);
SettingsRepository.updateSettings(request, email);
ALL_SETTINGS = makeString(request);
}

public void makeString(SettingsModel request){
public String makeString(SettingsModel request){


String ALL_SETTINGS = "The goal: " + request.getGoal() +". The budget range is: "+ request.getBudgetRange() +". The average daily calorie goal is: "+ request.getCalorieAmount() +". The average cooking time per meal is : "+ request.getCookingTime() + ". The grocery shopping interval is: "+request.getShoppingInterval() +". The user's BMI is: "+ request.getUserBMI() +". The user eats like "+ request.getFoodPreferences() +". The user's allergens: "+ request.getAllergies() +". The macro ratio for the user is "+ request.getMacroRatio() ;
String s ="";// + "The goal: " + request.getGoal().toString()
// +". The budget range is: "+ request.getBudgetRange().toString()
// +". The average daily calorie goal is: "+ request.getCalorieAmount()
// +". The average cooking time per meal is : "+ request.getCookingTime().toString()
// + ". The grocery shopping interval is: "+request.getShoppingInterval().toString()
// +". The user's BMI is: "+ request.getUserBMI()
// + ". The user eats like "+ request.getFoodPreferences().toString()
// +". The user's allergens: "+ request.getAllergies().toString()
// +". The macro ratio for the user is "+ request.getMacroRatio().toString()
//;
if(request.isFoodPreferenceSet())
{
s += ". The user prefers "+ request.getFoodPreferences().toString() ;
}
if(request.isAllergiesSet())
{}else {
s += ". The user is allergic to "+ request.getAllergies().toString() ;
}

System.out.println("okokokkokokkookokok");
System.out.println(ALL_SETTINGS);
System.out.println(s);

return s;

}

Expand Down

0 comments on commit 2366415

Please sign in to comment.