Spaces:
Runtime error
Runtime error
updated llm loading method
Browse files- crew.py +31 -15
- requirements.txt +2 -1
crew.py
CHANGED
|
@@ -326,21 +326,37 @@ def explain_dementia_risk_lifestyle(docID: str) -> str:
|
|
| 326 |
return f"SHAP explanation failed: {str(e)}"
|
| 327 |
|
| 328 |
|
| 329 |
-
# Load LLM from huggingface repos
|
| 330 |
-
client = InferenceClient(token=os.getenv("HF_TOKEN"))
|
| 331 |
-
def llm_invoke(prompt: str) -> str:
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
llm = type("SimpleLLM", (), {"invoke": llm_invoke})()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
|
| 345 |
# Define agents for Alzheimer's detection system
|
| 346 |
risk_calculator_audio = Agent(
|
|
|
|
| 326 |
return f"SHAP explanation failed: {str(e)}"
|
| 327 |
|
| 328 |
|
| 329 |
+
# # Load LLM from huggingface repos
|
| 330 |
+
# client = InferenceClient(token=os.getenv("HF_TOKEN"))
|
| 331 |
+
# def llm_invoke(prompt: str) -> str:
|
| 332 |
+
# try:
|
| 333 |
+
# response = client.chat.completions.create(
|
| 334 |
+
# model="meta-llama/Meta-Llama-3.1-8B-Instruct",
|
| 335 |
+
# messages=[{"role": "user", "content": prompt}],
|
| 336 |
+
# max_tokens=512,
|
| 337 |
+
# temperature=0.7
|
| 338 |
+
# )
|
| 339 |
+
# return response.choices[0].message.content.strip()
|
| 340 |
+
# except Exception as e:
|
| 341 |
+
# return f"[LLM ERROR] {str(e)}"
|
| 342 |
+
|
| 343 |
+
# llm = type("SimpleLLM", (), {"invoke": llm_invoke})()
|
| 344 |
+
|
| 345 |
+
# Get token from environment variable
|
| 346 |
+
hf_token = os.getenv("HF_TOKEN")
|
| 347 |
+
if not hf_token:
|
| 348 |
+
raise ValueError("HF_TOKEN environment variable not set")
|
| 349 |
+
|
| 350 |
+
# Initialize the LLM using LangChain wrapper
|
| 351 |
+
llm = HuggingFaceEndpoint(
|
| 352 |
+
repo_id="meta-llama/Meta-Llama-3.1-8B-Instruct",
|
| 353 |
+
huggingfacehub_api_token=hf_token,
|
| 354 |
+
task="text-generation",
|
| 355 |
+
max_new_tokens=512,
|
| 356 |
+
temperature=0.7,
|
| 357 |
+
top_p=0.95,
|
| 358 |
+
do_sample=True,
|
| 359 |
+
)
|
| 360 |
|
| 361 |
# Define agents for Alzheimer's detection system
|
| 362 |
risk_calculator_audio = Agent(
|
requirements.txt
CHANGED
|
@@ -13,4 +13,5 @@ openai-whisper
|
|
| 13 |
en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.1/en_core_web_sm-3.7.1-py3-none-any.whl
|
| 14 |
shap
|
| 15 |
xgboost==3.0.5
|
| 16 |
-
huggingface_hub
|
|
|
|
|
|
| 13 |
en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.1/en_core_web_sm-3.7.1-py3-none-any.whl
|
| 14 |
shap
|
| 15 |
xgboost==3.0.5
|
| 16 |
+
huggingface_hub
|
| 17 |
+
langchain-huggingface>=0.0.1
|