from opperai import Opper
import time
opper = Opper(http_bearer="YOUR_API_KEY")
# First, create a function and add some entries to get a dataset with data
unique_name = f"science_qa_{int(time.time())}"
created_function = opper.functions.create(
name=unique_name,
description="Science question answering assistant",
instructions="Answer science questions clearly and accurately with helpful explanations.",
model="openai/gpt-4o-mini",
)
print(f"Created function with dataset ID: {created_function.dataset_id}")
# Add a few entries to the dataset
opper.datasets.create_entry(
dataset_id=created_function.dataset_id,
input="What is photosynthesis?",
output="Photosynthesis is the process by which plants convert sunlight, carbon dioxide, and water into glucose and oxygen.",
expected="Photosynthesis is the biological process that converts light energy into chemical energy in plants.",
)
opper.datasets.create_entry(
dataset_id=created_function.dataset_id,
input="What is gravity?",
output="Gravity is the force that attracts objects toward each other, with larger objects having stronger gravitational pull.",
expected="Gravity is a fundamental force of attraction between masses.",
)
# List dataset entries with pagination
entries = opper.datasets.list_entries(
dataset_id=created_function.dataset_id, offset=0, limit=10
)
print(f"Total entries: {entries.meta.total_count}")
for entry in entries.data:
print(f"Entry {entry.id}: {entry.input[:50]}...")
print(f" Output: {entry.output[:50]}..."){
"meta": {
"total_count": 1
},
"data": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"input": "Given this input, what is the output?",
"output": "This is the output to the dataset entry",
"expected": "This `was` the output to the dataset entry",
"comment": "This is an example of how one can edit the output"
}
]
}from opperai import Opper
import time
opper = Opper(http_bearer="YOUR_API_KEY")
# First, create a function and add some entries to get a dataset with data
unique_name = f"science_qa_{int(time.time())}"
created_function = opper.functions.create(
name=unique_name,
description="Science question answering assistant",
instructions="Answer science questions clearly and accurately with helpful explanations.",
model="openai/gpt-4o-mini",
)
print(f"Created function with dataset ID: {created_function.dataset_id}")
# Add a few entries to the dataset
opper.datasets.create_entry(
dataset_id=created_function.dataset_id,
input="What is photosynthesis?",
output="Photosynthesis is the process by which plants convert sunlight, carbon dioxide, and water into glucose and oxygen.",
expected="Photosynthesis is the biological process that converts light energy into chemical energy in plants.",
)
opper.datasets.create_entry(
dataset_id=created_function.dataset_id,
input="What is gravity?",
output="Gravity is the force that attracts objects toward each other, with larger objects having stronger gravitational pull.",
expected="Gravity is a fundamental force of attraction between masses.",
)
# List dataset entries with pagination
entries = opper.datasets.list_entries(
dataset_id=created_function.dataset_id, offset=0, limit=10
)
print(f"Total entries: {entries.meta.total_count}")
for entry in entries.data:
print(f"Entry {entry.id}: {entry.input[:50]}...")
print(f" Output: {entry.output[:50]}..."){
"meta": {
"total_count": 1
},
"data": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"input": "Given this input, what is the output?",
"output": "This is the output to the dataset entry",
"expected": "This `was` the output to the dataset entry",
"comment": "This is an example of how one can edit the output"
}
]
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
The id of the dataset
The offset of the entries to get
x >= 0The limit of the entries to get
1 <= x <= 100Successful Response
List of items returned in the response
Show child attributes
The id of the dataset entry
The input to the dataset entry
"Given this input, what is the output?"
The output to the dataset entry
"This is the output to the dataset entry"
The expected output to the dataset entry, this is an optionally edited version of the output
"Thiswasthe output to the dataset entry"
The comment to the dataset entry
"This is an example of how one can edit the output"