1MR commited on
Commit
81c4a7f
·
verified ·
1 Parent(s): 5786cf4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -91,19 +91,17 @@ async def predict_image_and_nutrition(file: UploadFile = File(...)):
91
  # Initialize the InferenceClient with your token
92
  llm_client = InferenceClient(
93
  model=repo_id,
94
- token=api_token[:-2], # Pass the token here
95
  timeout=120,
96
  )
97
-
98
  # Function to call the LLM
99
  def call_llm(inference_client: InferenceClient, prompt: str):
100
- response = inference_client.post(
101
- json={
102
- "inputs": prompt,
103
- "parameters": {"max_new_tokens": 500}
104
- },
105
  )
106
- return json.loads(response.decode())[0]["generated_text"]
107
 
108
  # Use the prediction to generate nutrition information
109
  # prompt = f"Nutrition information (Calories, Protein, Carbohydrates, Dietary Fiber, Sugars, Fat, Sodium, Potassium, Vitamin C, Vitamin B6, Folate, Niacin, Pantothenic acid) for {prediction} in formatted list"
 
91
  # Initialize the InferenceClient with your token
92
  llm_client = InferenceClient(
93
  model=repo_id,
94
+ token=api_token,
95
  timeout=120,
96
  )
 
97
  # Function to call the LLM
98
  def call_llm(inference_client: InferenceClient, prompt: str):
99
+ response = inference_client.text_generation(
100
+ prompt=prompt,
101
+ max_new_tokens=500,
102
+ temperature=0.7, # optional
 
103
  )
104
+ return response
105
 
106
  # Use the prediction to generate nutrition information
107
  # prompt = f"Nutrition information (Calories, Protein, Carbohydrates, Dietary Fiber, Sugars, Fat, Sodium, Potassium, Vitamin C, Vitamin B6, Folate, Niacin, Pantothenic acid) for {prediction} in formatted list"