Skip to content

Commit c5bebd4

Browse files
committed
Update pxt.json, python/hai2025/wood1_test.md, python/hai2025/wood_test.md
1 parent c0707c6 commit c5bebd4

3 files changed

Lines changed: 81 additions & 2 deletions

File tree

pxt.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@
120120
"blocks/hai2025/comfort1.md",
121121
"blocks/hai2025/comfort2.md",
122122
"blocks/hai2025/allcontrols.md",
123-
"python/hai2025/wood1_test.md"
123+
"python/hai2025/wood1_test.md",
124+
"python/hai2025/wood_test.md"
124125
],
125126
"testFiles": [],
126127
"targetVersions": {

python/hai2025/wood1_test.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### @flyoutOnly true
2-
### @hideIteration true
2+
### @hideIteration false
33
### @explicitHints true
44

55
# Classifying Materials

python/hai2025/wood_test.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
### @flyoutOnly true
2+
### @hideIteration false
3+
### @explicitHints true
4+
5+
# Classifying Materials
6+
7+
## Step 1
8+
Before we're able to train the agent's AI, we'll need to learn how to access its Application Programming Interface (API). The first step is to define the API's endpoint (what part of the API you're accessing) and authentication parameters
9+
10+
```python
11+
api_url = 'minecraft://agent.ai/'
12+
api_endpoint = 'classify'
13+
api_key = "dsf3sSFssf42"
14+
```
15+
16+
## Step 2
17+
Now that we've defined the API's endpoint we want to use, we'll want to write a function that takes an input and sends it to the API endpoint.
18+
19+
```python
20+
def make_classify_api_request(resource, data):
21+
client = MinecraftAI(
22+
url = api_url,
23+
endpoint= api_endpoint,
24+
key = api_key
25+
)
26+
27+
try:
28+
response = client.chat.completions.create(
29+
messages=[
30+
{resource : data}
31+
]
32+
)
33+
ai_message = response.content
34+
print("AI Response")
35+
print(ai_message)
36+
37+
except Exception as e:
38+
print("An error occurred: {e}")
39+
40+
```
41+
42+
## Step 3
43+
Now we need to call the function when the code is run.
44+
45+
```python
46+
make_classify_api_request("oak log","wood")
47+
```
48+
49+
## Step 4
50+
When we put it all together it looks like this
51+
52+
53+
```python
54+
api_url = 'minecraft://agent.ai/'
55+
api_endpoint = 'classify'
56+
api_key = "dsf3sSFssf42"
57+
58+
def make_classify_api_request(resource, data):
59+
client = MinecraftAI(
60+
url = api_url,
61+
endpoint= api_endpoint,
62+
key = api_key
63+
)
64+
65+
try:
66+
response = client.chat.completions.create(
67+
messages=[
68+
{resource : data}
69+
]
70+
)
71+
ai_message = response.content
72+
print("AI Response")
73+
print(ai_message)
74+
75+
except Exception as e:
76+
print("An error occurred: {e}")
77+
78+
```

0 commit comments

Comments
 (0)