-
Notifications
You must be signed in to change notification settings - Fork 13
PostgreSQL database integration for conversation persistence #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
3c504da
chore: update deps
palaniappan-r 346a6ce
feat: add session id to input object
palaniappan-r 7b453ca
feat: implement database models and CRUD operations
palaniappan-r 175fa14
feat: add conversations API with DB integration
palaniappan-r 970f26e
feat: add api docs
palaniappan-r b2b9e22
chore: move api docs
palaniappan-r 046e80d
feat: delete unused chains api
palaniappan-r f618d05
feat: add database configuration to .env.example
palaniappan-r eab4938
chore: update deps
palaniappan-r faca754
feat: update dockerfile
palaniappan-r 0eb2c0c
feat: Add postgresql and pgadmin services
palaniappan-r 4b75461
feat: add response models for conversations endpoints
palaniappan-r d3660f5
chore: update deps
palaniappan-r 0e02868
feat: include conversations router
palaniappan-r 30759dc
feat: initialize database module
palaniappan-r 045383a
fix: Expose core components in package init
palaniappan-r 108d70d
feat: load environment variables and configure CUDA settings
palaniappan-r adc9ea9
chore: update deps
palaniappan-r a4b7ca4
fix: update embeddings type
palaniappan-r 7b8ba17
refactor: move CUDA environment variable setup to main entry point
palaniappan-r 6e4b3bf
fix: update healthcheck command to include database name
palaniappan-r 7b6db80
refactor: replace session_id with conversation_id in db models
palaniappan-r a8c5f8e
refactor: update type hints
palaniappan-r 83537bc
refactor: formatting changes
palaniappan-r 4e85fbd
fix: handle incomplete message pairs
palaniappan-r ebf88f8
fix: remove hardcoded PostgreSQL environment variables
palaniappan-r d635686
Merge branch 'master' into backend-db
palaniappan-r 2e9d22a
feat: update psycopg2 dependency to psycopg2-binary
palaniappan-r fbb0307
fix: update import from graphs to conversations
palaniappan-r 6dd183e
chore: update google-cloud-storage dependency
palaniappan-r e8cf6f2
fix: use retriever graph
palaniappan-r 43ac935
fix: revert google-cloud-storage dependency
palaniappan-r d28d45e
fix: add return type hints
palaniappan-r 8c8ef8e
fix: add return type hint to lifespan function
palaniappan-r f14f31f
docs: add docstrings for endpoints
palaniappan-r 76c7bc0
fix: untrack data folder
palaniappan-r 7e28524
docs: update README with PostgreSQL setup instructions
palaniappan-r 8cb48bb
remove api_docs
luarss 2551efa
remove unused response_models
luarss b4d4c74
db models:
luarss 9438d9a
specific docker-compose commands
luarss 115a603
improve history string robustness
luarss e7a3146
fix LLM response extraction (docker compose)
luarss 989df79
add unit tests
luarss 8f32f66
reduce docstring verbosity
luarss dcbbb7f
feat: save streamed conversation messages to the database
palaniappan-r 123aa95
fix streaming for more messages
luarss 6205242
add streaming unit tests
luarss 5e6ff82
fix lint
luarss 1107a9c
fix test
luarss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| .env | ||
| *.ipynb | ||
| __pycache__/ | ||
| backend/data/* | ||
| backend/data/ | ||
| backend/src/*.json | ||
| *.pyc | ||
| *.egg-info/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,38 @@ | ||
| from fastapi import FastAPI | ||
| from .routers import graphs, healthcheck, helpers, ui | ||
| from .routers import healthcheck, helpers, ui, conversations | ||
| from fastapi.middleware.cors import CORSMiddleware | ||
| from contextlib import asynccontextmanager | ||
| from src.database.config import init_database | ||
| import logging | ||
| from typing import AsyncGenerator | ||
|
|
||
| app = FastAPI() | ||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| @asynccontextmanager | ||
| async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]: | ||
| """Initialize database on startup.""" | ||
| logger.info("Initializing database connection...") | ||
| init_database() | ||
| yield | ||
| logger.info("Shutting down...") | ||
|
|
||
|
|
||
| app = FastAPI(lifespan=lifespan) | ||
|
|
||
| # Add CORS middleware | ||
| app.add_middleware( | ||
| CORSMiddleware, | ||
| allow_origins=[ | ||
| "http://localhost:3000", | ||
| "http://127.0.0.1:3000", | ||
| "http://localhost:8001", # mock endpoint | ||
| "http://localhost:8001", | ||
| "http://127.0.0.1:8001", | ||
| ], | ||
| allow_credentials=True, | ||
| allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"], | ||
| allow_headers=["*"], | ||
| ) | ||
| app.include_router(healthcheck.router) | ||
| app.include_router(graphs.router) | ||
| app.include_router(helpers.router) | ||
| app.include_router(ui.router) | ||
| app.include_router(conversations.router) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.