add-assistant #31
@ -69,7 +69,7 @@ class ConfigureAssistant:
|
||||
instructions=AI_ASSISTANT_INSTRUCTIONS,
|
||||
model="gpt-4o",
|
||||
temperature=0.1,
|
||||
tools=[{"type": "file_search"}, {"type": "code_interpreter"}],
|
||||
tools=[{"type": "file_search"}, ], # {"type": "code_interpreter"}], # Code interpreter doesn't seem to return a delta properly
|
||||
)
|
||||
|
||||
def get_file_paths(self, excluded_folders=None):
|
||||
@ -101,10 +101,16 @@ class ConfigureAssistant:
|
||||
# TO DO: Preprocess Outjob and PcbDoc files into something OpenAI (or future vector DB) can understand
|
||||
excluded_extensions = ["schdoc", "exe", "so", "dll", "outjob", "pcbdoc", "png"]
|
||||
|
||||
if extension in self.SUPPORTED_FORMATS and extension not in excluded_extensions:
|
||||
return os.path.basename(file_path), True
|
||||
# If the extension is not in supported formats and not in excluded extensions, rename the file
|
||||
if extension not in self.SUPPORTED_FORMATS and extension not in excluded_extensions:
|
||||
new_file_path = f"{file_path}.txt"
|
||||
os.rename(file_path, new_file_path)
|
||||
print(f"Renamed unsupported file: {file_path} to {new_file_path}")
|
||||
return new_file_path, True
|
||||
elif extension in self.SUPPORTED_FORMATS:
|
||||
return file_path, True
|
||||
else:
|
||||
print(f"Skipping unsupported file: {file_path}")
|
||||
print(f"Skipping excluded file: {file_path}")
|
||||
return file_path, False
|
||||
|
||||
def create_vector_store(self):
|
||||
@ -127,10 +133,10 @@ class ConfigureAssistant:
|
||||
if not should_upload:
|
||||
continue
|
||||
try:
|
||||
with open(path, "rb") as file_stream:
|
||||
with open(new_filename, "rb") as file_stream:
|
||||
file_content = file_stream.read()
|
||||
spoofed_file = io.BytesIO(file_content)
|
||||
spoofed_file.name = new_filename # Spoof the filename
|
||||
spoofed_file.name = os.path.basename(new_filename) # Spoof the filename
|
||||
# Upload the file to the vector store
|
||||
file_batch = (
|
||||
self.client.beta.vector_stores.file_batches.upload_and_poll(
|
||||
|
@ -1,7 +1,8 @@
|
||||
import os
|
||||
import logging
|
||||
import pandas as pd
|
||||
from openai import OpenAI
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import pandas as pd
|
||||
import textwrap
|
||||
|
||||
class OpenAIResourceManager:
|
||||
@ -167,12 +168,30 @@ class OpenAIResourceManager:
|
||||
print("")
|
||||
self.show_all_files()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
||||
def main():
|
||||
"""
|
||||
Main function that either shows or deletes resources based on the command line arguments.
|
||||
"""
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Displays or deletes all resources associated with the OpenAI account."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--delete", action="store_true", help="Flag to delete resources instead of showing them."
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Get the OpenAI API key from the environment variables
|
||||
api_key = os.getenv("OPENAI_API_KEY")
|
||||
# Create an instance of the OpenAIResourceManager
|
||||
manager = OpenAIResourceManager(api_key=api_key)
|
||||
|
||||
# Show or delete all resources in tables
|
||||
# Delete resources conditionally
|
||||
if args.delete:
|
||||
manager.delete_all_resources()
|
||||
|
||||
manager.show_all_resources()
|
||||
# manager.delete_all_resources()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -189,7 +189,7 @@ if __name__ == "__main__":
|
||||
parser.add_argument(
|
||||
"--assistant_id",
|
||||
type=str,
|
||||
default="asst_JUXTF2T6n3RFDjkolNqdtPxj",
|
||||
default="asst_W20wgEl0ZModBiMWzcgC0E3E",
|
||||
help="The assistant ID to use.",
|
||||
)
|
||||
parser.add_argument(
|
||||
|
Loading…
Reference in New Issue
Block a user