Pris1512 commited on
Commit
af8f586
·
verified ·
1 Parent(s): 59138f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py CHANGED
@@ -17,6 +17,45 @@ hub = {
17
 
18
 
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  # create Hugging Face Model Class
21
  huggingface_model = HuggingFaceModel(
22
  image_uri=get_huggingface_llm_image_uri("huggingface",version="3.2.3"),
 
17
 
18
 
19
 
20
+ # create Hugging Face Model Class
21
+ huggingface_model = HuggingFaceModel(
22
+ image_uri=get_huggingface_llm_image_uri("huggingface",version="3.2.3"),
23
+ env=hub,
24
+ role=role,
25
+ )
26
+
27
+ # deploy model to SageMaker Inference
28
+ predictor = huggingface_model.deploy(
29
+ initial_instance_count=1,
30
+ instance_type="ml.g5.2xlarge",
31
+ container_startup_health_check_timeout=300,
32
+ )
33
+
34
+ # send request
35
+ predictor.predict({
36
+ "inputs": "Hi, what can you help me with?",
37
+ })
38
+
39
+
40
+ import json
41
+ import sagemaker
42
+ import boto3
43
+ from sagemaker.huggingface import HuggingFaceModel, get_huggingface_llm_image_uri
44
+
45
+ try:
46
+ role = sagemaker.get_execution_role()
47
+ except ValueError:
48
+ iam = boto3.client('iam')
49
+ role = iam.get_role(RoleName='sagemaker_execution_role')['Role']['Arn']
50
+
51
+ # Hub Model configuration. https://huggingface.co/models
52
+ hub = {
53
+ 'HF_MODEL_ID':'praneethposina/customer_support_bot',
54
+ 'SM_NUM_GPUS': json.dumps(1)
55
+ }
56
+
57
+
58
+
59
  # create Hugging Face Model Class
60
  huggingface_model = HuggingFaceModel(
61
  image_uri=get_huggingface_llm_image_uri("huggingface",version="3.2.3"),