PATCH
/
functions
/
{function_id}
from opperai import Opper
import time

opper = Opper(http_bearer="YOUR_API_KEY")

# First, create a function to have a real ID to work with
unique_name = f"question_answerer_{int(time.time())}"
created_function = opper.functions.create(
    name=unique_name,
    description="Basic question answering assistant",
    instructions="You are a helpful assistant that provides clear, concise answers to questions.",
    model="openai/gpt-4o-mini",
)

print(f"Created function with ID: {created_function.id}")
print(f"Original model: {created_function.model}")

# Update the function's instructions and model
updated_function = opper.functions.update(
    function_id=created_function.id,
    instructions="You are an expert assistant that provides detailed, well-researched answers. Always cite your reasoning.",
    model="openai/gpt-4o",
    description="Enhanced question answerer with better reasoning capabilities",
)

print(f"Updated function: {updated_function.name}")
print(f"New instructions: {updated_function.instructions}")
print(f"New model: {updated_function.model}")
print(f"New revision ID: {updated_function.revision_id}")
{
  "name": "my-function",
  "description": "This function is used to add two numbers and return the result.",
  "instructions": "You are a calculator that adds two numbers and returns the result.",
  "input_schema": {
    "properties": {
      "x": {
        "title": "X",
        "type": "integer"
      },
      "y": {
        "title": "Y",
        "type": "integer"
      }
    },
    "required": [
      "x",
      "y"
    ],
    "title": "OpperInputExample",
    "type": "object"
  },
  "output_schema": {
    "properties": {
      "sum": {
        "title": "Sum",
        "type": "integer"
      }
    },
    "required": [
      "sum"
    ],
    "title": "OpperOutputExample",
    "type": "object"
  },
  "model": {
    "extra_headers": {},
    "name": "openai/gpt-4o-mini",
    "options": {
      "temperature": 0.5
    }
  },
  "configuration": {
    "beta.evaluation.enabled": true,
    "invocation.cache.ttl": 0,
    "invocation.few_shot.count": 0,
    "invocation.structured_generation.max_attempts": 5
  },
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "dataset_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "revision_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}

Authorizations

Authorization
string
header
required

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

Path Parameters

function_id
string
required

Unique identifier of the function given as a UUID

Body

application/json

Response

200
application/json

Successful Response

The response is of type object.