diff --git a/apps/docs/ai-sdk/examples.mdx b/apps/docs/ai-sdk/examples.mdx index cb2b1a7f..61ad8d50 100644 --- a/apps/docs/ai-sdk/examples.mdx +++ b/apps/docs/ai-sdk/examples.mdx @@ -98,7 +98,7 @@ export async function POST(request: Request) { const { messages, customerId } = await request.json() const result = await streamText({ - model: openai('gpt-4-turbo'), + model: openai('gpt-5'), messages, tools: supermemoryTools(process.env.SUPERMEMORY_API_KEY!, { containerTags: [customerId] @@ -136,7 +136,7 @@ export async function POST(request: Request) { const { messages } = await request.json() const result = await streamText({ - model: supermemoryInfiniteChat('gpt-4-turbo'), + model: supermemoryInfiniteChat('gpt-5'), messages, system: `You are a documentation assistant. You have access to all previous conversations and can reference earlier discussions. Help users understand @@ -222,7 +222,7 @@ export async function POST(request: Request) { const { messages, projectId } = await request.json() const result = await streamText({ - model: openai('gpt-4-turbo'), + model: openai('gpt-5'), messages, tools: supermemoryTools(process.env.SUPERMEMORY_API_KEY!, { containerTags: [projectId] @@ -357,7 +357,7 @@ export async function POST(request: Request) { const { messages } = await request.json() const result = await streamText({ - model: openai('gpt-4-turbo'), + model: openai('gpt-5'), messages, tools: { // Spread Supermemory tools diff --git a/apps/docs/ai-sdk/infinite-chat.mdx b/apps/docs/ai-sdk/infinite-chat.mdx index b287eb5b..c382bcbf 100644 --- a/apps/docs/ai-sdk/infinite-chat.mdx +++ b/apps/docs/ai-sdk/infinite-chat.mdx @@ -45,7 +45,7 @@ const infiniteChat = createOpenAI({ }) const result = await streamText({ - model: infiniteChat("gpt-4-turbo"), + model: infiniteChat("gpt-5"), messages: [...] }) ``` @@ -128,7 +128,7 @@ const infiniteChat = createOpenAI({ }) const result = await streamText({ - model: infiniteChat("gpt-4-turbo"), + model: infiniteChat("gpt-5"), messages: [ { role: "user", content: "What did we discuss yesterday?" } ] diff --git a/apps/docs/ai-sdk/memory-tools.mdx b/apps/docs/ai-sdk/memory-tools.mdx index 69b961e1..cc84097f 100644 --- a/apps/docs/ai-sdk/memory-tools.mdx +++ b/apps/docs/ai-sdk/memory-tools.mdx @@ -18,7 +18,7 @@ const openai = createOpenAI({ }) const result = await streamText({ - model: openai("gpt-4-turbo"), + model: openai("gpt-5"), prompt: "Remember that my name is Alice", tools: supermemoryTools("YOUR_SUPERMEMORY_KEY") }) @@ -32,7 +32,7 @@ Semantic search through user memories: ```typescript const result = await streamText({ - model: openai("gpt-4"), + model: openai("gpt-5"), prompt: "What are my dietary preferences?", tools: supermemoryTools("API_KEY") }) @@ -64,7 +64,7 @@ Retrieve specific memory by ID: ```typescript const result = await streamText({ - model: openai("gpt-4"), + model: openai("gpt-5"), prompt: "Get the details of memory abc123", tools: supermemoryTools("API_KEY") }) @@ -87,7 +87,7 @@ import { // Use only search tool const result = await streamText({ - model: openai("gpt-4"), + model: openai("gpt-5"), prompt: "What do you know about me?", tools: { searchMemories: searchMemoriesTool("API_KEY", { diff --git a/apps/docs/cookbook/ai-sdk-integration.mdx b/apps/docs/cookbook/ai-sdk-integration.mdx index 9bde2f42..8bdafef7 100644 --- a/apps/docs/cookbook/ai-sdk-integration.mdx +++ b/apps/docs/cookbook/ai-sdk-integration.mdx @@ -97,7 +97,7 @@ export async function POST(request: Request) { const { messages, customerId } = await request.json() const result = await streamText({ - model: openai('gpt-4-turbo'), + model: openai('gpt-5'), messages, tools: supermemoryTools(process.env.SUPERMEMORY_API_KEY!, { containerTags: [customerId] @@ -135,7 +135,7 @@ export async function POST(request: Request) { const { messages } = await request.json() const result = await streamText({ - model: infiniteChat('gpt-4-turbo'), + model: infiniteChat('gpt-5'), messages, system: `You are a documentation assistant. You have access to all previous conversations and can reference earlier discussions. Help users understand @@ -221,7 +221,7 @@ export async function POST(request: Request) { const { messages, projectId } = await request.json() const result = await streamText({ - model: openai('gpt-4-turbo'), + model: openai('gpt-5'), messages, tools: supermemoryTools(process.env.SUPERMEMORY_API_KEY!, { containerTags: [projectId] @@ -354,7 +354,7 @@ export async function POST(request: Request) { const { messages } = await request.json() const result = await streamText({ - model: openai('gpt-4-turbo'), + model: openai('gpt-5'), messages, tools: { // Spread Supermemory tools diff --git a/apps/docs/cookbook/customer-support.mdx b/apps/docs/cookbook/customer-support.mdx index 250def78..32e0417e 100644 --- a/apps/docs/cookbook/customer-support.mdx +++ b/apps/docs/cookbook/customer-support.mdx @@ -9,7 +9,7 @@ Create a customer support system that remembers every interaction, tracks issues A customer support bot that: - **Remembers customer history** across all conversations and channels -- **Tracks ongoing issues** and follows up automatically +- **Tracks ongoing issues** and follows up automatically - **Provides personalized responses** based on customer tier and preferences - **Escalates complex issues** to human agents with full context - **Learns from resolutions** to improve future responses @@ -231,7 +231,7 @@ A customer support bot that: """Add a customer interaction to memory""" try: content = f"{interaction['type'].upper()}: {interaction['content']}" - + result = self.client.memories.add( content=content, container_tag=self._get_container_tag(customer_id), @@ -378,10 +378,10 @@ Status: {issue['status']}""" } export async function POST(request: Request) { - const { - message, - customerId, - customer, + const { + message, + customerId, + customer, conversationHistory = [], agentId } = await request.json() @@ -410,7 +410,7 @@ ${contextResults.map(c => `- ${c.content.substring(0, 150)}... (${(c.similarity // Determine if escalation is needed const escalationKeywords = ['angry', 'frustrated', 'cancel', 'refund', 'legal', 'complaint', 'manager', 'supervisor'] - const needsEscalation = escalationKeywords.some(keyword => + const needsEscalation = escalationKeywords.some(keyword => message.toLowerCase().includes(keyword) ) || customer.tier === 'enterprise' @@ -445,7 +445,7 @@ If you cannot resolve the issue completely, prepare a clear summary for escalati ] const result = await streamText({ - model: openai('gpt-4-turbo'), + model: openai('gpt-5'), messages, temperature: 0.3, maxTokens: 800, @@ -468,7 +468,7 @@ If you cannot resolve the issue completely, prepare a clear summary for escalati if (message.length > 50 && !contextResults.some(c => c.similarity > 0.8)) { const issueCategory = categorizeIssue(message) const priority = determinePriority(customer.tier, message) - + await contextManager.trackIssue(customerId, { subject: message.substring(0, 100), description: message, @@ -506,34 +506,34 @@ If you cannot resolve the issue completely, prepare a clear summary for escalati } const messageLower = message.toLowerCase() - + for (const [category, keywords] of Object.entries(categories)) { if (keywords.some(keyword => messageLower.includes(keyword))) { return category } } - + return 'general' } function determinePriority(tier: string, message: string): 'low' | 'medium' | 'high' | 'urgent' { const urgentKeywords = ['urgent', 'critical', 'emergency', 'down', 'broken'] const highKeywords = ['important', 'asap', 'soon', 'problem'] - + const messageLower = message.toLowerCase() - + if (urgentKeywords.some(keyword => messageLower.includes(keyword))) { return 'urgent' } - + if (tier === 'enterprise') { return highKeywords.some(keyword => messageLower.includes(keyword)) ? 'urgent' : 'high' } - + if (tier === 'pro') { return highKeywords.some(keyword => messageLower.includes(keyword)) ? 'high' : 'medium' } - + return 'low' } ``` @@ -580,29 +580,29 @@ If you cannot resolve the issue completely, prepare a clear summary for escalati } message_lower = message.lower() - + for category, keywords in categories.items(): if any(keyword in message_lower for keyword in keywords): return category - + return 'general' def determine_priority(tier: str, message: str) -> str: """Determine issue priority based on tier and message content""" urgent_keywords = ['urgent', 'critical', 'emergency', 'down', 'broken'] high_keywords = ['important', 'asap', 'soon', 'problem'] - + message_lower = message.lower() - + if any(keyword in message_lower for keyword in urgent_keywords): return 'urgent' - + if tier == 'enterprise': return 'urgent' if any(keyword in message_lower for keyword in high_keywords) else 'high' - + if tier == 'pro': return 'high' if any(keyword in message_lower for keyword in high_keywords) else 'medium' - + return 'low' @app.post("/support/chat") @@ -662,7 +662,7 @@ If you cannot resolve the issue completely, prepare a clear summary for escalati ] response = await openai_client.chat.completions.create( - model="gpt-4-turbo", + model="gpt-5", messages=messages, temperature=0.3, max_tokens=800, @@ -676,7 +676,7 @@ If you cannot resolve the issue completely, prepare a clear summary for escalati content = chunk.choices[0].delta.content full_response += content yield f"data: {json.dumps({'content': content})}\n\n" - + # Store interaction after completion context_manager.add_interaction(request.customerId, { 'type': 'chat', @@ -695,7 +695,7 @@ If you cannot resolve the issue completely, prepare a clear summary for escalati if len(request.message) > 50 and not any(c['similarity'] > 0.8 for c in context_results): issue_category = categorize_issue(request.message) priority = determine_priority(request.customer.tier, request.message) - + context_manager.track_issue(request.customerId, { 'subject': request.message[:100], 'description': request.message, @@ -750,7 +750,7 @@ export default function SupportDashboard() { const [tickets, setTickets] = useState([]) const [showEscalation, setShowEscalation] = useState(false) const [agentId] = useState('agent_001') // In real app, get from auth - + const contextManager = new CustomerContextManager() const { messages, input, handleInputChange, handleSubmit, isLoading } = useChat({ @@ -781,7 +781,7 @@ export default function SupportDashboard() { joinDate: '2023-06-15' }, { - id: 'cust_002', + id: 'cust_002', name: 'TechCorp Inc', email: 'support@techcorp.com', tier: 'enterprise', @@ -978,7 +978,7 @@ export default function SupportDashboard() {

- {interaction.content.length > 100 + {interaction.content.length > 100 ? `${interaction.content.substring(0, 100)}...` : interaction.content } @@ -986,10 +986,10 @@ export default function SupportDashboard() { {interaction.outcome && (

{interaction.outcome} @@ -1044,4 +1044,4 @@ This comprehensive customer support recipe provides the foundation for building --- -*Customize this recipe based on your specific support workflows and customer needs.* \ No newline at end of file +*Customize this recipe based on your specific support workflows and customer needs.* diff --git a/apps/docs/cookbook/document-qa.mdx b/apps/docs/cookbook/document-qa.mdx index c3bc224e..d11e947b 100644 --- a/apps/docs/cookbook/document-qa.mdx +++ b/apps/docs/cookbook/document-qa.mdx @@ -9,7 +9,7 @@ Create a powerful document Q&A system that can ingest PDFs, text files, and web A document Q&A system that: - **Ingests multiple file types** (PDFs, DOCX, text, URLs) -- **Answers questions accurately** with source citations +- **Answers questions accurately** with source citations - **Provides source references** with page numbers and document titles - **Handles follow-up questions** with conversation context - **Supports multiple document collections** for different topics @@ -192,7 +192,7 @@ A document Q&A system that: """Upload a local file to Supermemory""" if metadata is None: metadata = {} - + try: with open(file_path, 'rb') as file: result = self.client.memories.upload_file( @@ -214,7 +214,7 @@ A document Q&A system that: """Upload URL content to Supermemory""" if metadata is None: metadata = {} - + try: result = self.client.memories.add( content=url, @@ -258,11 +258,11 @@ A document Q&A system that: return [ { 'id': memory.id, - 'title': (memory.title or - memory.metadata.get('originalName') or + 'title': (memory.title or + memory.metadata.get('originalName') or 'Untitled' if memory.metadata else 'Untitled'), - 'type': (memory.metadata.get('fileType') or - memory.metadata.get('type') or + 'type': (memory.metadata.get('fileType') or + memory.metadata.get('type') or 'unknown' if memory.metadata else 'unknown'), 'uploadedAt': memory.metadata.get('uploadedAt') if memory.metadata else None, 'status': memory.status, @@ -349,9 +349,9 @@ A document Q&A system that: ] const result = await streamText({ - model: openai('gpt-4-turbo'), + model: openai('gpt-5'), messages, - system: `You are a helpful document Q&A assistant. Answer questions based ONLY on the provided document context. + system: `You are a helpful document Q&A assistant. Answer questions based ONLY on the provided document context. CONTEXT FROM DOCUMENTS: ${context} @@ -450,13 +450,13 @@ If the question cannot be answered from the provided documents, respond with: "I for index, result in enumerate(search_results.results): relevant_chunks = [ - chunk.content for chunk in result.chunks + chunk.content for chunk in result.chunks if chunk.is_relevant ][:3] - + chunk_text = '\n\n'.join(relevant_chunks) context_parts.append(f'[Document {index + 1}: "{result.title}"]\n{chunk_text}') - + sources.append({ 'id': result.document_id, 'title': result.title, @@ -472,7 +472,7 @@ If the question cannot be answered from the provided documents, respond with: "I messages = [ { "role": "system", - "content": f"""You are a helpful document Q&A assistant. Answer questions based ONLY on the provided document context. + "content": f"""You are a helpful document Q&A assistant. Answer questions based ONLY on the provided document context. CONTEXT FROM DOCUMENTS: {context} @@ -500,7 +500,7 @@ If the question cannot be answered from the provided documents, respond with: "I # Get AI response response = await openai_client.chat.completions.create( - model="gpt-4-turbo", + model="gpt-5", messages=messages, temperature=0.1, max_tokens=1000 @@ -557,7 +557,7 @@ export default function DocumentQA() { const [isUploading, setIsUploading] = useState(false) const [uploadProgress, setUploadProgress] = useState>({}) const fileInputRef = useRef(null) - + const processor = new DocumentProcessor() const { messages, input, handleInputChange, handleSubmit, isLoading } = useChat({ @@ -599,7 +599,7 @@ export default function DocumentQA() { // Refresh document list await loadDocuments() - + // Clear file input if (fileInputRef.current) { fileInputRef.current.value = '' @@ -653,7 +653,7 @@ export default function DocumentQA() {

Document Collection

- + {/* Collection Selector */}