Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 22, 2025

This PR adds three powerful new memory methods that significantly improve the developer experience for populating Langbase memory from various content sources.

New Methods

memories.uploadText()

Upload text content directly to memory without file handling:

await langbase.memories.uploadText({
  memoryName: 'my-memory',
  text: 'Your content here...',
  documentName: 'optional-name.txt', // Auto-generates if not provided
  meta: { type: 'user-content' }
});

memories.uploadFromSearch()

Search the web and upload results directly to memory:

await langbase.memories.uploadFromSearch({
  memoryName: 'research-memory',
  query: 'What is artificial intelligence?',
  service: 'exa',
  totalResults: 5,
  apiKey: 'your-exa-key',
  documentNamePrefix: 'ai-research'
});

memories.uploadFromCrawl()

Crawl URLs and upload content directly to memory:

await langbase.memories.uploadFromCrawl({
  memoryName: 'docs-memory',
  url: ['https://example.com', 'https://example.com/about'],
  maxPages: 2,
  apiKey: 'your-crawl-key',
  service: 'spider'
});

Key Features

  • Seamless Integration: Leverages existing webSearch and webCrawl tools without modification
  • Smart Content Formatting: Combines URL and content for better context in search/crawl results
  • Automatic Metadata: Adds source tracking (search query, URLs, services used) to all uploads
  • Flexible Document Naming: Auto-generation with timestamps or custom prefixes
  • Type Safety: Complete TypeScript interfaces with proper exports
  • Error Handling: Comprehensive error propagation and validation

Implementation Details

The methods follow the same upload pattern as existing uploadDocs(), using the signed URL approach for efficient content upload. Search and crawl methods return arrays of responses for batch operations, while text upload returns a single response.

Content from search/crawl is formatted as:

URL: https://example.com

Content:
[Page content here...]

Testing & Documentation

  • ✅ 5 comprehensive test cases covering all methods and edge cases
  • ✅ Complete working examples for each method
  • ✅ Full API documentation with parameter descriptions
  • ✅ TypeScript compilation and type exports verified

This enhancement addresses the common need to populate memory from various sources and provides a streamlined developer experience for building knowledge bases, research collections, and content repositories.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] memory: make better memory methods like uploadText, and others like where a tool like search or web fetch is used to add content from a page to memory Add enhanced memory methods: uploadText, uploadFromSearch, uploadFromCrawl Sep 22, 2025
@Copilot Copilot AI requested a review from ahmadawais September 22, 2025 01:32
Copilot finished work on behalf of ahmadawais September 22, 2025 01:32
@ahmadawais
Copy link
Member

@saqibameen fyi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants