https://github.com/jcserv/portfolio-api
portfolio-api is a simple retrieval augmented generation API to allow users to ask questions about the content in a developer portfolio
https://github.com/jcserv/portfolio-api
api go openai rag sqlite
Last synced: 2 months ago
JSON representation
portfolio-api is a simple retrieval augmented generation API to allow users to ask questions about the content in a developer portfolio
- Host: GitHub
- URL: https://github.com/jcserv/portfolio-api
- Owner: jcserv
- License: gpl-3.0
- Created: 2024-11-05T01:41:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-17T22:06:16.000Z (over 1 year ago)
- Last Synced: 2025-01-24T16:12:12.382Z (over 1 year ago)
- Topics: api, go, openai, rag, sqlite
- Language: Go
- Homepage:
- Size: 49.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# portfolio-api

`portfolio-api` is a retrieval augmented generation API to allow users to ask questions about the content in a developer portfolio.
Intended to be integrated into a portfolio website.
## how it works
1. Opens `experience.json` and `projects.json` files to retrieve experiences and projects.
2. Generates vector embeddings for each experience and project, stores them in a SQLite database.
- Duplicates are ignored by checking the content hash
3. User sends `POST /api/v1/ask` request with a question
4. Calculates cosine similarity between the question and each embedding in the database
- This is currently being done in the application layer, but should be done in the database layer if the db has a large amount of embeddings
5. Top 3 most similar documents are used to generate a prompt for the LLM
## installation
### prerequisites
- [Go](https://go.dev/doc/install)
- [Docker](https://docs.docker.com/get-docker/)
### local development
1. Clone the repository
2. Initialize .env file with the respective variables
3. Run `source <(make exportenv)`
4. Run `make run/docker`