{"id":20021453,"url":"https://github.com/dieg0code/portfolio_04_personal_intelligent_assistant","last_synced_at":"2026-04-11T09:02:23.854Z","repository":{"id":257510226,"uuid":"858454031","full_name":"Dieg0Code/portfolio_04_personal_intelligent_assistant","owner":"Dieg0Code","description":"Serverless Personal Intelligent Assistant (PIA), with semantic search and Retrieval Augmented Generation (OpenAI, Supabase, PgVector)","archived":false,"fork":false,"pushed_at":"2025-01-27T05:29:17.000Z","size":140,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-27T06:27:09.408Z","etag":null,"topics":["aws","golang","lambda","pgvector","retrieval-augmented-generation","supabase","terraform"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dieg0Code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-16T23:25:05.000Z","updated_at":"2025-01-27T05:29:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"638cee5b-5c0b-4258-bc16-63c41082abf9","html_url":"https://github.com/Dieg0Code/portfolio_04_personal_intelligent_assistant","commit_stats":null,"previous_names":["dieg0code/portfolio_04_rag_diary_serverless","dieg0code/portfolio_04_personal_intelligent_assistant"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dieg0Code%2Fportfolio_04_personal_intelligent_assistant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dieg0Code%2Fportfolio_04_personal_intelligent_assistant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dieg0Code%2Fportfolio_04_personal_intelligent_assistant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dieg0Code%2Fportfolio_04_personal_intelligent_assistant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dieg0Code","download_url":"https://codeload.github.com/Dieg0Code/portfolio_04_personal_intelligent_assistant/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241455377,"owners_count":19965602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","golang","lambda","pgvector","retrieval-augmented-generation","supabase","terraform"],"created_at":"2024-11-13T08:36:49.617Z","updated_at":"2025-12-31T01:06:11.467Z","avatar_url":"https://github.com/Dieg0Code.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PIA\n\n![infra](infra.png)\n\n## Configuration\n\n### Environment Variables\n\nNeed to set the following environment variables:\n\n```env\nSUPABASE_URL=yoursupabaseurl\nSUPABASE_KEY=yoursupabasekey\nOPENAI_API_KEY=youropenaikey\n```\n\n_In my case, I'm using Github secrets to store these values._\n\n### Terraform\n\nAlso need to create an s3 bucket and a DynamoDB table for terraform state.\n\nS3 bucket:\n\n```bash\naws s3api create-bucket --bucket terraform-state-rag-diary --region sa-east-1 --create-bucket-configuration LocationConstraint=sa-east-1\n```\n\nEnable versioning for the bucket (optional):\n\n```bash\naws s3api put-bucket-versioning --bucket terraform-state-rag-diary --versioning-configuration Status=Enabled\n```\n\nDynamoDB table:\n\n```bash\naws dynamodb create-table \\\n    --table-name terraform_locks_diary \\\n    --attribute-definitions AttributeName=LockID,AttributeType=S \\\n    --key-schema AttributeName=LockID,KeyType=HASH \\\n    --billing-mode PAY_PER_REQUEST \\\n    --region sa-east-1\n```\n\n### Supabase\n\nI'm using supabase and PgVector to store the diary entries with a column for the OpenAI text embedding.\n\nNeed to enable the `pgvector` extension:\n\n```sql\ncreate extension if not exists vector;\n```\n\nCreate a new table called `diary` with the following columns:\n\n```sql\nCREATE TABLE IF NOT EXISTS diary (\n    id bigserial PRIMARY KEY,\n    title text NOT NULL,\n    content text NOT NULL,\n    created_at timestamp NOT NULL DEFAULT NOW(),\n    embedding vector(3072) NOT NULL -- openai text embedding (large)\n);\n```\n\nCreate a stored procedure called `search_diary`:\n\n```sql\ncreate or replace function search_diary(\n    query_embedding vector(3072),\n    similarity_threshold float,\n    match_count int\n)\nreturns table (\n    id bigint,\n    title text,\n    content text,\n    created_at timestamp,\n    similarity float\n)\nlanguage plpgsql\nas $$\nbegin\n    return query\n    select\n        diary.id,\n        diary.title,\n        diary.content,\n        diary.created_at,\n        diary.embedding \u003c#\u003e query_embedding as similarity\n    from\n        diary\n    where\n        diary.embedding \u003c#\u003e query_embedding \u003c similarity_threshold\n    order by\n        diary.embedding \u003c#\u003e query_embedding\n    limit\n        match_count;\nend;\n$$;\n```\n\nThat's the store procedure that does the semantic search.\n\nCreate a index for the `embedding` column (optional):\n\n```sql\ncreate index on public.diary\nusing ivfflat (embedding vector_cosine_ops)\nwith (lists = 100);\n```\n\nasd\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdieg0code%2Fportfolio_04_personal_intelligent_assistant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdieg0code%2Fportfolio_04_personal_intelligent_assistant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdieg0code%2Fportfolio_04_personal_intelligent_assistant/lists"}