Spaces:
Runtime error
Runtime error
import pprint | |
import google.generativeai as palm | |
palm.configure(api_key='AIzaSyCLy2IgNwMBDbhYH_zvUDo0AMWQdRLQI0E') | |
prompt = """ | |
You are an expert at explaining coding interview solutions in Python. | |
Explain the following solution: | |
``` | |
def coinChange(self, coins: List[int], amount: int) -> int: | |
dp = [amount + 1] * (amount + 1) | |
dp[0] = 0 | |
for a in range(1, amount + 1): | |
for c in coins: | |
if a - c >= 0: | |
dp[a] = min(dp[a], 1 + dp[a - c]) | |
return dp[amount] if dp[amount] != amount + 1 else -1 | |
``` | |
Think about it step by step, and show your work. | |
Afterwards, run through an example input. | |
""" | |
completion = palm.generate_text( | |
model='models/text-bison-001', | |
prompt=prompt, | |
temperature=0, | |
# The maximum length of the response | |
max_output_tokens=1200, | |
) | |
print(completion.result) | |