gtani commited on
Commit
1cbd2de
Β·
verified Β·
1 Parent(s): 324e5e6

Delete bedrock_test_Pixtral.py

Browse files
Files changed (1) hide show
  1. bedrock_test_Pixtral.py +0 -58
bedrock_test_Pixtral.py DELETED
@@ -1,58 +0,0 @@
1
-
2
-
3
-
4
- #%%
5
- aws_access_key_id='AKIA2UC26WDCAFOF7X64'
6
- aws_secret_access_key='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'
7
- aws_region = "eu-central-1"
8
- #%%
9
-
10
- import boto3
11
- import json
12
-
13
- from botocore.exceptions import ClientError
14
-
15
-
16
- bedrock_runtime = session.client(service_name='bedrock-runtime')
17
-
18
- # 🏷️ Model ID for Pixtral
19
- model_id = 'mistral.pixtral-large-2502-v1:0'
20
-
21
- # ✏️ Define your prompt
22
- prompt = "Describe the purpose of a 'hello world' program in one line."
23
-
24
- # 🧾 Format the request payload
25
- native_request = {
26
- "inputText": prompt,
27
- "textGenerationConfig": {
28
- "maxTokenCount": 512,
29
- "temperature": 0.5,
30
- "topP": 0.9
31
- }
32
- }
33
-
34
- # πŸ”„ Convert to JSON
35
- request = json.dumps(native_request)
36
-
37
- try:
38
- # πŸš€ Invoke the model
39
- response = bedrock_runtime.invoke_model(
40
- modelId=model_id,
41
- body=request,
42
- contentType="application/json",
43
- accept="application/json"
44
- )
45
-
46
- # πŸ“¦ Decode the response body
47
- model_response = json.loads(response["body"].read())
48
-
49
- # πŸ—¨οΈ Extract and print output text
50
- response_text = model_response["results"][0]["outputText"]
51
- print("βœ… Model response:")
52
- print(response_text)
53
-
54
- except ClientError as e:
55
- print(f"❌ ClientError: {e.response['Error']['Message']}")
56
- except Exception as e:
57
- print(f"❌ ERROR: Can't invoke '{model_id}'. Reason: {e}")
58
- #%%