https://github.com/memgraph/genai-stack
A template for building GenAI applications with Memgraph.
https://github.com/memgraph/genai-stack
Last synced: 10 months ago
JSON representation
A template for building GenAI applications with Memgraph.
- Host: GitHub
- URL: https://github.com/memgraph/genai-stack
- Owner: memgraph
- License: mit
- Created: 2024-05-23T09:36:57.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-30T14:15:09.000Z (about 1 year ago)
- Last Synced: 2025-01-30T15:26:38.840Z (about 1 year ago)
- Language: Python
- Homepage:
- Size: 192 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Memgraph GenAI Stack
**Docker Compose + FastAPI + LangChain + Ollama + Memgraph**
This demo is a template for building GenAI applications with Memgraph.
## App architecture

## Dataset
In order for schema to be generated, a dataset needs to be loaded in Memgraph before the application is started. The Game of Thrones dataset is preloaded in this demo. To preload your own dataset, update the `dataset.cypherl` file.
The first three lines in the CYPHERL file are there, so the data doesn't reload on each run. (`STORAGE MODE IN_MEMORY_ANALYTICAL; DROP GRAPH; STORAGE MODE IN_MEMORY_TRANSACTIONAL;`)
## Start the app
To utilize `GPT-4` model, create the `.env` file in the root directory and set your OpenAI API key:
```
OPENAI_API_KEY=
```
Run the app:
```
docker compose up
```
This demo offers querying Memgraph with the natural language via LangChain utilizing two different models:
- [GPT-4](#ask-memgraph-with-gpt-4)
- [Llama 3](#ask-memgraph-with-llama-3)
### Ask Memgraph with GPT-4
Ask Memgraph with GPT-4 model:
```
curl -X POST "http://localhost:8000/ask/gpt" -H "Content-Type: application/json" -d '{"question": "How many seasons there are?"}'
```
Here is the response:
```
{"question":"How many seasons there are?","response":"There are 8 seasons."}%
```
### Ask Memgraph with Llama 3
Ask Memgraph with Llama3 model:
```
curl -X POST "http://localhost:8000/ask/llama" -H "Content-Type: application/json" -d '{"question": "How many seasons there are?"}'
```
Here is the response:
```
{"question":"How many seasons there are?","response":"There are 8 seasons."}%
```