POST
/
datasets
/
{dataset_id}
from opperai import Opper
import time

opper = Opper(http_bearer="YOUR_API_KEY")

# First, create a function to get a dataset_id
unique_name = f"geography_qa_{int(time.time())}"
created_function = opper.functions.create(
    name=unique_name,
    description="Geography question answering assistant",
    instructions="Answer geography questions accurately and concisely.",
    model="openai/gpt-4o-mini",
)

print(f"Created function with ID: {created_function.id}")
print(f"Function dataset ID: {created_function.dataset_id}")

# Create a new dataset entry using the function's dataset_id
entry = opper.datasets.create_entry(
    dataset_id=created_function.dataset_id,
    input="What is the capital of France?",
    output="The capital of France is Paris.",
    expected="Paris is the capital and largest city of France.",
    comment="Basic geography question with enhanced expected output",
)

print(f"Created entry: {entry.id}")
print(f"Input: {entry.input}")
print(f"Output: {entry.output}")
{
  "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"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

dataset_id
string
required

The id of the dataset

Body

application/json

Response

200
application/json

Successful Response

The response is of type object.