Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,29 @@ from tenacity import retry, wait_random_exponential, stop_after_attempt
|
|
| 12 |
GPT_MODEL = "gpt-3.5-turbo-1106"
|
| 13 |
openai.api_key = os.environ['OPENAI_API_KEY']
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
def openai_api_calculate_cost(usage,model=GPT_MODEL):
|
| 16 |
pricing = {
|
| 17 |
# 'gpt-3.5-turbo-4k': {
|
|
|
|
| 12 |
GPT_MODEL = "gpt-3.5-turbo-1106"
|
| 13 |
openai.api_key = os.environ['OPENAI_API_KEY']
|
| 14 |
|
| 15 |
+
# Now let's define the function specification:
|
| 16 |
+
functions = [
|
| 17 |
+
{
|
| 18 |
+
"name": "exec_python",
|
| 19 |
+
"description": "run cell in ipython and return the execution result.",
|
| 20 |
+
"parameters": {
|
| 21 |
+
"type": "object",
|
| 22 |
+
"properties": {
|
| 23 |
+
"cell": {
|
| 24 |
+
"type": "string",
|
| 25 |
+
"description": "Valid Python cell to execute.",
|
| 26 |
+
}
|
| 27 |
+
},
|
| 28 |
+
"required": ["cell"],
|
| 29 |
+
},
|
| 30 |
+
},
|
| 31 |
+
]
|
| 32 |
+
|
| 33 |
+
# In order to run these functions automatically, we should maintain a dictionary:
|
| 34 |
+
functions_dict = {
|
| 35 |
+
"exec_python": exec_python,
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
def openai_api_calculate_cost(usage,model=GPT_MODEL):
|
| 39 |
pricing = {
|
| 40 |
# 'gpt-3.5-turbo-4k': {
|