Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/pyright.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Pyright

on:
- push
- pull_request

jobs:
pyright:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
name: "Pyright"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Python version
run: python --version
- name: PDM installation
run: pip install --user pdm
- name: Install dependencies
run: pdm install
- name: Install devel dependencies
run: pdm install --group default,dev
- name: Run Pyright tests
run: pdm run pyright src
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# lightspeed-stack
LLM tooling stack

## About The Project

[![GitHub Pages](https://img.shields.io/badge/%20-GitHub%20Pages-informational)](https://lightspeed-core.github.io/lightspeed-stack/)
[![License](https://img.shields.io/badge/license-Apache-blue)](https://github.com/lightspeed-core/lightspeed-stack/blob/main/LICENSE)
[![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/)

Lightspeed Core Stack (LCS) is an AI powered assistant that provides answers to product questions using backend LLM services.


<!-- vim-markdown-toc GFM -->

Expand Down
30 changes: 28 additions & 2 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 13 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,31 @@ dependencies = [
Homepage = "https://github.com/lightspeed-core/lightspeed-stack"
Issues = "https://github.com/lightspeed-core/lightspeed-stack/issues"

[tool.pdm]
distribution = true

[dependency-groups]
dev = [
"black>=25.1.0",
"pytest>=8.3.2",
"pytest-cov>=5.0.0",
"pytest-mock>=3.14.0",
"pyright>=1.1.401",
]

[tool.pdm.scripts]
start = "pdm run make run"
test-unit = "pdm run make test-unit"
test-integration = "pdm run make test-integration"

[tool.pytest.ini_options]
pythonpath = [
"src"
]
addopts = [
"--import-mode=importlib",
]

[tool.pylint.main]
source-roots = "src"

[tool.pdm]
distribution = true

[tool.pdm.scripts]
start = "pdm run make run"
test-unit = "pdm run make test-unit"
test-integration = "pdm run make test-integration"

13 changes: 11 additions & 2 deletions src/app/endpoints/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ def select_model_id(client: LlamaStackClient, query_request: QueryRequest) -> st
if not model_id:
logger.info("No model specified in request, using the first available LLM")
try:
return next(m for m in models if m.model_type == "llm").identifier
model = next(
m
for m in models
if m.model_type == "llm" # pyright: ignore[reportAttributeAccessIssue]
).identifier
logger.info(f"Selected model: {model}")
return model
except (StopIteration, AttributeError):
message = "No LLM model found in available models"
logger.error(message)
Expand Down Expand Up @@ -113,14 +119,17 @@ def retrieve_response(
tools=[],
)
session_id = agent.create_session("chat_session")
logger.debug(f"Session ID: {session_id}")
response = agent.create_turn(
messages=[UserMessage(role="user", content=query_request.query)],
session_id=session_id,
documents=query_request.get_documents(),
stream=False,
)

return str(response.output_message.content)
return str(
response.output_message.content # pyright: ignore[reportAttributeAccessIssue]
)


def validate_attachments_metadata(attachments: list[Attachment]) -> None:
Expand Down
9 changes: 6 additions & 3 deletions src/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

from fastapi import FastAPI
from app import routers

import version
from log import get_logger
from configuration import configuration


logger = get_logger(__name__)


logger.info("Initializing app")

service_name = configuration.configuration.name

app = FastAPI(
title="Lightspeed-core service - OpenAPI",
description="Lightspeed-core service API specification.",
title=f"{service_name} service - OpenAPI",
description=f"{service_name} service API specification.",
version=version.__version__,
license_info={
"name": "Apache 2.0",
Expand Down