문서에서 Python

Docstring을 고려하여 Python 함수 생성

모델을 직접 쿼리하고 Cloud 콘솔에서 다른 매개변수 값을 사용하거나 Vertex AI API를 직접 호출하여 반환된 결과를 테스트할 수 있습니다.

자유 형식 프롬프트


from collections import namedtuple
from math import sqrt


# A point has an x and a y coordinate
Point = namedtuple('Point', 'x y')
# A triangle is defined by three points
Triangle = namedtuple('Triangle', 'a b c')


def distance(p, q):
"""Returns the distance between the provided pair of points"""
return sqrt((p.x - q.x)**2 + (p.y - q.y)**2)


def perimeter(triangle):
"""Returns the perimeter of the provided triangle"""
return distance(triangle.a, triangle.b) + distance(triangle.b, triangle.c) + distance(triangle.c, triangle.a)


def area(triangle):
"""Returns the area of the provided triangle using Heron's formula"""

docstring에 따라 영역 함수 본문을 작성합니다.

응답


from collections import namedtuple
from math import sqrt


# A point has an x and a y coordinate
Point = namedtuple('Point', 'x y')
# A triangle is defined by three points
Triangle = namedtuple('Triangle', 'a b c')


def distance(p, q):
"""Returns the distance between the provided pair of points"""
return sqrt((p.x - q.x)**2 + (p.y - q.y)**2)


def perimeter(triangle):
"""Returns the perimeter of the provided triangle"""
return distance(triangle.a, triangle.b) + distance(triangle.b, triangle.c) + distance(triangle.c, triangle.a)


def area(triangle):
"""Returns the area of the provided triangle using Heron's formula"""
s = perimeter(triangle) / 2
return sqrt(s * (s - distance(triangle.a, triangle.b)) * (s - distance(triangle.b, triangle.c)) * (s - distance(triangle.c, triangle.a)))
모델: gemini-1.5-flash-001
강도: 1
최대 출력 토큰: 8192
최상위 K: 40
최상위 P: 0.95