Spaces:
Build error
Build error
Update app.py
Browse files
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
|
| 95 |
timeout=120,
|
| 96 |
)
|
| 97 |
-
|
| 98 |
# Function to call the LLM
|
| 99 |
def call_llm(inference_client: InferenceClient, prompt: str):
|
| 100 |
-
response = inference_client.
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
},
|
| 105 |
)
|
| 106 |
-
return
|
| 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"
|