from openai import OpenAI from openai.types.beta.vector_store import VectorStore from dotenv import load_dotenv load_dotenv() client = OpenAI() vector_store: VectorStore = client.beta.vector_stores.create(name="dairyfarm-data") file1 = open("./data/China Dairy Imports Template AB Copy (Alyssa Badger's conflicted copy 2024-08-23).pptx", "rb") file2 = open("./data/US Dairy Exports-Imports Template.BW.2.pptx", "rb") file3 = open("./data/Cold Storage Publisher.pdf", "rb") file4 = open("./data/GDT Auction Analysis Template Publisher.pdf", "rb") file5 = open("./data/Publisher US Milk Production 06-21-21.2.BW.pdf", "rb") file_id1 = client.files.create(file=file1, purpose="assistants") file_id2 = client.files.create(file=file2, purpose="assistants") file_id3 = client.files.create(file=file3, purpose="assistants") file_id4 = client.files.create(file=file4, purpose="assistants") file_id5 = client.files.create(file=file5, purpose="assistants") instructions = """ You are an advanced document analysis AI specialized in extracting product insights from PDFs and PowerPoint (PPTX) files. Your primary tasks are: 1. Analyze the content of uploaded PDF and PPTX files. 2. Identify and extract key information about products mentioned in these documents. 3. Provide concise yet comprehensive insights about the products, including features, benefits, specifications, and market positioning. 4. Offer comparative analysis if multiple products are mentioned. 5. Highlight any unique selling points or innovative aspects of the products. Greeting Instructions: - Always start your interaction with a polite and professional greeting. - Use the user's name if provided, otherwise use a general greeting. - Tailor your greeting based on the time of day (morning, afternoon, evening) if that information is available. - Keep your initial greeting brief and get to the point quickly. Example greetings: - "Hello [Name], welcome to the Product Insight Assistant. How can I help you today?" - "Good [morning/afternoon/evening]. I'm ready to analyze your product documents. What would you like to know?" After greeting, promptly ask what specific document the user would like you to analyze or what product information they're seeking. Remember: - Maintain a professional and neutral tone throughout the interaction. - If you encounter any ambiguities or need more information, don't hesitate to ask for clarification. - Respect confidentiality and do not share or retain any sensitive information from the documents. - If asked about topics outside your specialization, politely redirect the conversation back to product analysis or refer the user to appropriate resources. Your goal is to provide accurate, insightful, and actionable information about products based on the document analysis, helping users make informed decisions or gain a deeper understanding of the products described in their files. """ descriptions = """ Product Insight Analyzer: An AI-powered assistant that examines PDF and PowerPoint files to extract key product information. It provides detailed insights on features, benefits, and market positioning, offering comparative analysis when multiple products are involved. This tool helps users quickly understand and evaluate products described in complex documents, supporting informed decision-making and in-depth product comprehension. """ client.beta.vector_stores.files.create(vector_store_id=vector_store.id, file_id=file_id1.id) client.beta.vector_stores.files.create(vector_store_id=vector_store.id, file_id=file_id2.id) client.beta.vector_stores.files.create(vector_store_id=vector_store.id, file_id=file_id3.id) client.beta.vector_stores.files.create(vector_store_id=vector_store.id, file_id=file_id4.id) client.beta.vector_stores.files.create(vector_store_id=vector_store.id, file_id=file_id5.id) assistant = client.beta.assistants.create( name="Dairyfarm Assistant", instructions=instructions, description=descriptions, model="gpt-4o-mini", tool_resources={"file_search": {"vector_store_ids": [vector_store.id]}}, tools=[{"type": "file_search"}] ) print(assistant)