hamnamughal commited on
Commit
7850c99
·
verified ·
1 Parent(s): 01dc2a5

Update health_tracker_agent.py

Browse files
Files changed (1) hide show
  1. health_tracker_agent.py +14 -8
health_tracker_agent.py CHANGED
@@ -1,11 +1,17 @@
1
  from transformers import AutoTokenizer, AutoModelForCausalLM
2
- import torch
 
 
 
 
3
 
4
- def track_health_status(health_input):
5
  model_name = "m42-health/med42-70b"
6
- tokenizer = AutoTokenizer.from_pretrained(model_name)
7
- model = AutoModelForCausalLM.from_pretrained(model_name)
8
- prompt = f"Based on the following health input, track possible issues or advice: {health_input}."
9
- inputs = tokenizer(prompt, return_tensors="pt")
10
- outputs = model.generate(**inputs, max_new_tokens=150)
11
- return tokenizer.decode(outputs[0], skip_special_tokens=True)
 
 
 
 
1
  from transformers import AutoTokenizer, AutoModelForCausalLM
2
+ from huggingface_hub import login
3
+
4
+ def track_health_status(input_text: str) -> str:
5
+ # Authenticate
6
+ login("your_huggingface_token_here") # <-- replace with your actual token
7
 
 
8
  model_name = "m42-health/med42-70b"
9
+
10
+ tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=True)
11
+ model = AutoModelForCausalLM.from_pretrained(model_name, use_auth_token=True)
12
+
13
+ inputs = tokenizer.encode(input_text, return_tensors="pt", truncation=True)
14
+ outputs = model.generate(inputs, max_length=512)
15
+ result = tokenizer.decode(outputs[0], skip_special_tokens=True)
16
+
17
+ return result