|
| 1 | +--- |
| 2 | +title: "Mixpeek integration" |
| 3 | +description: "Integrate with the Mixpeek multimodal vector store using LangChain Python." |
| 4 | +--- |
| 5 | + |
| 6 | +This guide provides a quick overview for getting started with the Mixpeek [vector store](/oss/integrations/vectorstores#overview). For detailed documentation, head to the [Mixpeek LangChain docs](https://docs.mixpeek.com/agent-integrations/langchain). |
| 7 | + |
| 8 | +## Setup |
| 9 | + |
| 10 | +To access the Mixpeek vector store, you'll need a [Mixpeek](https://mixpeek.com) account and API key. |
| 11 | + |
| 12 | +### Credentials |
| 13 | + |
| 14 | +```python Set API key icon="key" |
| 15 | +import getpass |
| 16 | +import os |
| 17 | + |
| 18 | +if "MIXPEEK_API_KEY" not in os.environ: |
| 19 | + os.environ["MIXPEEK_API_KEY"] = getpass.getpass("Enter your Mixpeek API key: ") |
| 20 | +``` |
| 21 | + |
| 22 | +To enable automated <Tooltip tip="Log each step of a model's execution to debug and improve it">tracing</Tooltip> of your model calls, set your [LangSmith](/langsmith/home) API key: |
| 23 | + |
| 24 | +```python Enable tracing icon="flask" |
| 25 | +os.environ["LANGSMITH_API_KEY"] = getpass.getpass("Enter your LangSmith API key: ") |
| 26 | +os.environ["LANGSMITH_TRACING"] = "true" |
| 27 | +``` |
| 28 | + |
| 29 | +### Installation |
| 30 | + |
| 31 | +<CodeGroup> |
| 32 | + ```python pip |
| 33 | + pip install -U langchain-mixpeek |
| 34 | + ``` |
| 35 | + ```python uv |
| 36 | + uv add langchain-mixpeek |
| 37 | + ``` |
| 38 | +</CodeGroup> |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +## Instantiation |
| 43 | + |
| 44 | +### Full config (search + ingest) |
| 45 | + |
| 46 | +```python Initialize vector store icon="database" |
| 47 | +from langchain_mixpeek import MixpeekVectorStore |
| 48 | + |
| 49 | +vector_store = MixpeekVectorStore( |
| 50 | + api_key=os.environ["MIXPEEK_API_KEY"], |
| 51 | + namespace="my-namespace", |
| 52 | + bucket_id="bkt_abc123", |
| 53 | + collection_id="col_def456", |
| 54 | + retriever_id="ret_ghi789", |
| 55 | +) |
| 56 | +``` |
| 57 | + |
| 58 | +### Search-only (minimal config) |
| 59 | + |
| 60 | +```python Search-only factory icon="magnifying-glass" |
| 61 | +vector_store = MixpeekVectorStore.from_retriever( |
| 62 | + api_key=os.environ["MIXPEEK_API_KEY"], |
| 63 | + namespace="my-namespace", |
| 64 | + retriever_id="ret_abc123", |
| 65 | +) |
| 66 | +``` |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## Manage vector store |
| 71 | + |
| 72 | +### Add items |
| 73 | + |
| 74 | +Mixpeek supports 6 content types — not just text: |
| 75 | + |
| 76 | +```python Add text icon="font" |
| 77 | +vector_store.add_texts(["Product description...", "Another document..."]) |
| 78 | +``` |
| 79 | + |
| 80 | +```python Add images icon="image" |
| 81 | +vector_store.add_images(["https://example.com/photo.jpg"]) |
| 82 | +``` |
| 83 | + |
| 84 | +```python Add video icon="video" |
| 85 | +vector_store.add_videos(["https://example.com/clip.mp4"]) |
| 86 | +``` |
| 87 | + |
| 88 | +```python Add audio icon="headphones" |
| 89 | +vector_store.add_audio(["https://example.com/recording.mp3"]) |
| 90 | +``` |
| 91 | + |
| 92 | +```python Add PDF icon="file-pdf" |
| 93 | +vector_store.add_pdfs(["https://example.com/document.pdf"]) |
| 94 | +``` |
| 95 | + |
| 96 | +```python Add spreadsheet icon="table" |
| 97 | +vector_store.add_excel(["https://example.com/data.xlsx"]) |
| 98 | +``` |
| 99 | + |
| 100 | +### Trigger processing |
| 101 | + |
| 102 | +After adding content, trigger feature extraction (embedding, OCR, transcription, face detection): |
| 103 | + |
| 104 | +```python Process content icon="wand-magic-sparkles" |
| 105 | +vector_store.trigger_processing() |
| 106 | +``` |
| 107 | + |
| 108 | +### Delete items |
| 109 | + |
| 110 | +```python Delete documents by IDs icon="trash" |
| 111 | +vector_store.delete(ids=["doc_abc123"]) |
| 112 | +``` |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +## Query vector store |
| 117 | + |
| 118 | +### Directly |
| 119 | + |
| 120 | +```python Similarity search icon="folders" |
| 121 | +results = vector_store.similarity_search(query="red cup on the table", k=5) |
| 122 | +for doc in results: |
| 123 | + print(f"* {doc.page_content} [{doc.metadata}]") |
| 124 | +``` |
| 125 | + |
| 126 | +With scores: |
| 127 | + |
| 128 | +```python Similarity search with scores icon="star-half" |
| 129 | +results = vector_store.similarity_search_with_score(query="red cup", k=5) |
| 130 | +for doc, score in results: |
| 131 | + print(f"* [SIM={score:.3f}] {doc.page_content} [{doc.metadata}]") |
| 132 | +``` |
| 133 | + |
| 134 | +### By turning into retriever |
| 135 | + |
| 136 | +```python Create retriever icon="robot" |
| 137 | +retriever = vector_store.as_retriever() |
| 138 | +retriever.invoke("find the red cup") |
| 139 | +``` |
| 140 | + |
| 141 | +--- |
| 142 | + |
| 143 | +## Convert to agent tools |
| 144 | + |
| 145 | +The vector store can be converted to agent-compatible interfaces: |
| 146 | + |
| 147 | +```python Bridge methods icon="arrows-split-up-and-left" |
| 148 | +# Single search tool |
| 149 | +tool = vector_store.as_tool() |
| 150 | + |
| 151 | +# Full 6-tool agent toolkit (search, ingest, process, classify, cluster, alert) |
| 152 | +toolkit = vector_store.as_toolkit() |
| 153 | + |
| 154 | +# LangChain retriever |
| 155 | +retriever = vector_store.as_retriever() |
| 156 | +``` |
| 157 | + |
| 158 | +--- |
| 159 | + |
| 160 | +## Platform features |
| 161 | + |
| 162 | +### Taxonomies (document classification) |
| 163 | + |
| 164 | +```python Taxonomy classification icon="tags" |
| 165 | +vector_store.create_taxonomy(name="product-categories", config={...}) |
| 166 | +results = vector_store.execute_taxonomy("tax_abc123") |
| 167 | +``` |
| 168 | + |
| 169 | +### Clusters (unsupervised grouping) |
| 170 | + |
| 171 | +```python Clustering icon="object-group" |
| 172 | +cluster = vector_store.create_cluster( |
| 173 | + cluster_type="vector", |
| 174 | + vector_config={"algorithm": "kmeans", "algorithm_params": {"n_clusters": 10}}, |
| 175 | +) |
| 176 | +vector_store.execute_cluster(cluster["cluster_id"]) |
| 177 | +groups = vector_store.get_cluster_groups(cluster["cluster_id"]) |
| 178 | +``` |
| 179 | + |
| 180 | +### Alerts (match notifications) |
| 181 | + |
| 182 | +```python Alerts icon="bell" |
| 183 | +vector_store.create_alert( |
| 184 | + name="counterfeit-detection", |
| 185 | + notification_config={ |
| 186 | + "channels": [ |
| 187 | + {"channel_type": "webhook", "config": {"url": "https://..."}}, |
| 188 | + {"channel_type": "slack", "channel_id": "#alerts"}, |
| 189 | + ], |
| 190 | + }, |
| 191 | +) |
| 192 | +``` |
| 193 | + |
| 194 | +--- |
| 195 | + |
| 196 | +## Usage for retrieval-augmented generation |
| 197 | + |
| 198 | +```python RAG chain icon="link" |
| 199 | +from langchain_core.prompts import ChatPromptTemplate |
| 200 | +from langchain_anthropic import ChatAnthropic |
| 201 | + |
| 202 | +retriever = vector_store.as_retriever() |
| 203 | +llm = ChatAnthropic(model="claude-sonnet-4-20250514") |
| 204 | + |
| 205 | +prompt = ChatPromptTemplate.from_template( |
| 206 | + "Answer using this context:\n{context}\n\nQuestion: {question}" |
| 207 | +) |
| 208 | + |
| 209 | +chain = {"context": retriever, "question": lambda x: x} | prompt | llm |
| 210 | +response = chain.invoke("what happens at 2 minutes in the video?") |
| 211 | +``` |
| 212 | + |
| 213 | +--- |
| 214 | + |
| 215 | +## API reference |
| 216 | + |
| 217 | +For detailed documentation of all MixpeekVectorStore features and configurations, head to the [Mixpeek LangChain docs](https://docs.mixpeek.com/agent-integrations/langchain). |
0 commit comments