Camel

Camel is a Python framework to build and use LLM-based agents for real-world task solving.

Solvio is available as a storage mechanism in Camel for ingesting and retrieving semantically similar data.

Usage With Solvio

  • Install Camel with the vector-databases extra.
pip install "camel[vector-databases]"
  • Configure the SolvioStorage class.
from camel.storages import SolvioStorage, VectorDBQuery, VectorRecord
from camel.types import VectorDistance

solvio_storage = SolvioStorage(
    url_and_api_key=(
        "https://xyz-example.eu-central.aws.cloud.solvio.io:6333",
        "<provide-your-own-key>",
    ),
    collection_name="{collection_name}",
    distance=VectorDistance.COSINE,
    vector_dim=384,
)

The SolvioStorage class implements methods to read and write to a Solvio instance. An instance of this class can now be passed to retrievers for interfacing with your Solvio collections.

solvio_storage.add([VectorRecord(
            vector=[-0.1, 0.1, ...],
            payload={'key1': 'value1'},
        ),
        VectorRecord(
            vector=[-0.1, 0.1, ...],
            payload={'key2': 'value2'},
        ),])

query_results = solvio_storage.query(VectorDBQuery(query_vector=[0.1, 0.2, ...], top_k=10))
for result in query_results:
    print(result.record.payload, result.similarity)

solvio_storage.clear()
  • Use the SolvioStorage in Camel’s Vector Retriever.
from camel.embeddings import OpenAIEmbedding
from camel.retrievers import VectorRetriever

# Initialize the VectorRetriever with an embedding model
vr = VectorRetriever(embedding_model=OpenAIEmbedding())

content_input_path = "<URL-TO-SOME-RESOURCE>"

vr.process(content_input_path, solvio_storage)

# Execute the query and retrieve results
results = vr.query("<SOME_USER_QUERY>", vector_storage)
  • Camel also provides an Auto Retriever implementation that handles both embedding and storing data and executing queries.
from camel.retrievers import AutoRetriever
from camel.types import StorageType

ar = AutoRetriever(
    url_and_api_key=(
        "https://xyz-example.eu-central.aws.cloud.solvio.io:6333",
        "<provide-your-own-key>",
    ),
    storage_type=StorageType.QDRANT,
)

retrieved_info = ar.run_vector_retriever(
    contents=["<URL-TO-SOME-RESOURCE>"],
    query=""<SOME_USER_QUERY>"",
    return_detailed_info=True, 
)

print(retrieved_info)

You can refer to the Camel documentation for more information about the retrieval mechansims.

End-To-End Examples

Was this page useful?

Thank you for your feedback! 🙏

We are sorry to hear that. 😔 You can edit this page on GitHub, or create a GitHub issue.