-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmemory.docs.delete.py
More file actions
42 lines (29 loc) · 1021 Bytes
/
memory.docs.delete.py
File metadata and controls
42 lines (29 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
Example demonstrating how to delete documents from a memory in Langbase.
"""
import json
import os
from dotenv import load_dotenv
from langbase import Langbase
def main():
load_dotenv()
# Get API key from environment variable
langbase_api_key = os.getenv("LANGBASE_API_KEY")
# Initialize the client
langbase = Langbase(api_key=langbase_api_key)
# Memory name and document ID to delete
memory_name = "product-knowledge" # Replace with your memory name
document_name = "intro.txt" # Replace with the document name you want to delete
# Delete the document
try:
response = langbase.memories.documents.delete(
memory_name=memory_name, document_name=document_name
)
print(
f"Document '{document_name}' deleted successfully from memory '{memory_name}'"
)
print(json.dumps(response, indent=2))
except Exception as e:
print(f"Error deleting document: {e}")
if __name__ == "__main__":
main()