Skip to content

Commit

Permalink
Merge branch 'main' into fix-poetry-add-ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarflakstad committed Mar 20, 2024
2 parents 8c177cb + 65f7f5a commit 3cc3561
Show file tree
Hide file tree
Showing 20 changed files with 1,945 additions and 14 deletions.
2 changes: 1 addition & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Steps and commands for running the app are to be included here
- Example API for Top 10 Search:
```
curl --location 'http://127.0.0.1:8000/top-search-queries' \
curl --location 'http://127.0.0.1:8000/topqueries?limit=10' \
--header 'Authorization: Bearer <access token>'
```
Expand Down
11 changes: 7 additions & 4 deletions backend/app/api/endpoints/search_endpoint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fastapi import APIRouter, Depends
from fastapi import APIRouter, Depends, HTTPException
from fastapi.responses import JSONResponse
from fastapi_versioning import version
from authx import AuthX, AuthXConfig
Expand Down Expand Up @@ -53,18 +53,21 @@ async def get_search_results(query: str = "") -> JSONResponse:


@router.get(
"/top-search-queries",
"/topqueries",
summary="List all top search queries",
description="List all Top Search Queries",
dependencies=[Depends(security.access_token_required)],
response_model=list[str],
)
@version(1, 0)
async def get_top_search_queries() -> JSONResponse:
async def get_top_search_queries(limit: int) -> JSONResponse:
logger.debug("Search_Endpoint.get_top_search_queries")

if limit <= 0:
raise HTTPException(status_code=400, detail="Limit should be greater than 0")

cache = Redis()
last_x_keys = await cache.get_sorted_set("searched_queries", 0, 10)
last_x_keys = await cache.get_sorted_set("searched_queries", 0, limit - 1)

logger.debug(f"Search_Endpoint.get_top_search_queries. result: {last_x_keys}")

Expand Down
4 changes: 3 additions & 1 deletion backend/app/router/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, config):
prompt_template_str=self.ROUTER_PROMPT,
)

async def query_and_get_answer(self, search_text):
async def query_and_get_answer(self, search_text) -> str:
# search router call
logger.debug(
f"Orchestrator.query_and_get_answer.router_id search_text: {search_text}"
Expand Down Expand Up @@ -134,5 +134,7 @@ async def query_and_get_answer(self, search_text):
logger.debug(
f"Orchestrator.query_and_get_answer.response_synthesis: {result}"
)
result = result.get('result', '') + "\n\n" + "Source: " + ', '.join(result.get('source', []))
logger.debug(f"Orchestrator.query_and_get_answer.response_synthesis: {result}")

return result
31 changes: 23 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: '3.8'
version: "3.8"

services:
backend:
build: backend
ports:
- 8000:80
- 8000:80
volumes:
- ./backend:/usr/src/app
networks:
Expand All @@ -15,6 +15,21 @@ services:
cache:
condition: service_healthy

server:
build: server
restart: always
ports:
- 3030:3030
networks:
- curieo_db
volumes:
- ./server:/usr/src/app
depends_on:
db:
condition: service_healthy
cache:
condition: service_healthy

frontend:
build: frontend
restart: always
Expand All @@ -28,17 +43,17 @@ services:
db:
image: postgres:14-alpine
ports:
- 5432:5432/tcp
- 5432:5432/tcp
networks:
curieo_db:
aliases:
- curieo_db
volumes:
- db_data:/var/lib/postgresql/data
- db_data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=postgres
- POSTGRES_DB=aact
- POSTGRES_HOST_AUTH_METHOD=trust
- POSTGRES_USER=postgres
- POSTGRES_DB=aact
- POSTGRES_HOST_AUTH_METHOD=trust
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
Expand All @@ -48,7 +63,7 @@ services:
cache:
image: redis:alpine
ports:
- 6379:6379/tcp
- 6379:6379/tcp
networks:
curieo_db:
aliases:
Expand Down
2 changes: 2 additions & 0 deletions server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sample_data/
target/
29 changes: 29 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# Config and environment
.env
config/local.toml

# Generated by Cargo
# will have compiled files and executables
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
# Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
Loading

0 comments on commit 3cc3561

Please sign in to comment.