Quickstart
Get started with Persona in just a few steps
Setup Your Development Environment
Follow these steps to set up Persona locally and start building.
Clone the repository and install dependencies.
Ensure you have Docker and Docker Compose installed on your machine.
Configure Environment Variables
Create a .env
file in the root directory based on the provided example:
Edit the .env
file to include your specific configurations:
Run the Docker Containers
This command sets up the FastAPI backend and Neo4j graph database.
FastAPI will be available at http://localhost:8000
Neo4j will be available at bolt://localhost:7687
. Neo4j Browser will be available at http://localhost:7474
.
You can change the ports in the docker compose file if you are running other services on your system.
Interact with the API
Persona exposes a set of RESTful APIs to interact with user knowledge graphs. Get started with basic endpoints to create a user, ingest data, and perform RAG queries.
Create a New User
Endpoint:
Request Body:
Ingest User Data
Ingest API is designed to be used with unstructured data inherently. In the backend Persona uses a combination of LLMs and Graph Schema to construct the user’s graph. So you can ingest data as a string, following any format, and Persona will do its best to understand and store it in the graph.
Persona is primarily designed to take in user interaction logs as strings, but can work with conversational data, or any other unstructured data. For now, we will use a simple text input.
Endpoint:
Request Body:
Perform a RAG Query
Persona can answer questions based on user’s knowledge graph. This is a RAG interface to user’s data.
Endpoint:
Request Body:
Response:
Learn Anything - Ask Anything
Persona can be configured to understand custom attributes of a user for your specific use case. There are two interfaces to interact with the user’s graph. Learn and Ask.
Learn Interface
Learn interface gives you a way to instruct Persona on how to construct the graph, and what properties to focus on. Define a schema and Persona will use it for it’s next ingestion cycle.
A learning schema consists of:
- Name: Identifier for the schema
- Description: Purpose of the schema
- Attributes: Node properties to extract
- Relationships: Edge types to identify
Below is an example of a learning schema for a user’s fitness motivation.
Endpoint:
Request Body:
The graph will now be updated with the new schema, and future ingestion will be sensitive to record this data in the graph. You can give as many learning schemas as you want, and they will all be applied to the next ingestion cycle.
Querying this data will now be easier and cost effective with Cypher queries instead of RAG.
Ask Interface
ASK interace allows you to create custom APIs to answer questions based on the user’s graph. You can define a fixed question for your app, and an example output schema for the response.
You can run this as a one time query to generate new insights about your user, or as a recurring query. This will be served as a RESTful API for your app to use. The response object will follow the example output schema.
Endpoint:
Request Body:
Response:
Ensure that you define the question and the example output schema in the same context that your graph and app is built for.
This is prone to hallucinations if there are absolutely no themes related to graph. Avoid asking about topics that are not remotely related to the graph or your app.
There are better ways to implement this, and we are working on it. Meanwhile if you have any ideas, contributions are welcome.
Conclusion
You’ve now set up Persona and performed a basic RAG query. From here, you can explore the API documentation, architecture, and contribute to the project.
Welcome to the Persona community! 🚀