Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,13 +5,13 @@ from dotenv import load_dotenv
|
|
| 5 |
import uuid
|
| 6 |
import time
|
| 7 |
import os
|
| 8 |
-
|
| 9 |
import pandas as pd
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
| 16 |
# Step 1: Clone the Dataset Repository
|
| 17 |
repo = Repository(
|
|
@@ -22,27 +22,20 @@ repo = Repository(
|
|
| 22 |
)
|
| 23 |
repo.git_pull() # Pull the latest changes (if any)
|
| 24 |
|
| 25 |
-
# Step 2: Load the PDF File
|
| 26 |
file_path = "Test_csv/Basic_Info_GrunddatenKH141123.csv"
|
| 27 |
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
openai.api_key = OPENAI_API_KEY
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
# Create a file for the assistant
|
| 36 |
-
file = openai.File.create(
|
| 37 |
file=open("Test_csv/Basic_Info_GrunddatenKH141123.csv", "rb"),
|
| 38 |
purpose='assistants'
|
| 39 |
)
|
| 40 |
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
)
|
| 46 |
|
| 47 |
|
| 48 |
|
|
|
|
| 5 |
import uuid
|
| 6 |
import time
|
| 7 |
import os
|
| 8 |
+
from openai import OpenAI # Updated import
|
| 9 |
import pandas as pd
|
| 10 |
|
| 11 |
+
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 12 |
|
| 13 |
+
# Initialize the OpenAI client with the new method
|
| 14 |
+
client = OpenAI(api_key=OPENAI_API_KEY)
|
|
|
|
| 15 |
|
| 16 |
# Step 1: Clone the Dataset Repository
|
| 17 |
repo = Repository(
|
|
|
|
| 22 |
)
|
| 23 |
repo.git_pull() # Pull the latest changes (if any)
|
| 24 |
|
|
|
|
| 25 |
file_path = "Test_csv/Basic_Info_GrunddatenKH141123.csv"
|
| 26 |
|
| 27 |
|
| 28 |
+
# Step 2: Load the CSV File and Create a File for the Assistant
|
| 29 |
+
# Updated method for file creation
|
| 30 |
+
file = client.files.create(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
file=open("Test_csv/Basic_Info_GrunddatenKH141123.csv", "rb"),
|
| 32 |
purpose='assistants'
|
| 33 |
)
|
| 34 |
|
| 35 |
|
| 36 |
+
# Set your OpenAI Assistant ID here
|
| 37 |
+
assistant_id = os.getenv("assistant_id")
|
| 38 |
+
|
|
|
|
| 39 |
|
| 40 |
|
| 41 |
|