Skip to content

LCORE-1841: More examples#1590

Merged
tisnik merged 2 commits into
lightspeed-core:mainfrom
tisnik:lcore-1841-more-examples
Apr 26, 2026
Merged

LCORE-1841: More examples#1590
tisnik merged 2 commits into
lightspeed-core:mainfrom
tisnik:lcore-1841-more-examples

Conversation

@tisnik
Copy link
Copy Markdown
Contributor

@tisnik tisnik commented Apr 26, 2026

Description

LCORE-1841: More examples

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement

Tools used to create PR

  • Assisted-by: N/A
  • Generated by: N/A

Related Tickets & Documents

  • Related Issue #LCORE-1841

Summary by CodeRabbit

  • Documentation
    • Expanded conceptual content on AI limitations in software development with new sections and illustrative examples
    • Added code examples demonstrating Python best practices including immutable collections, data model definitions, type dispatch patterns, and metadata handling with timestamps

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2026

Warning

Rate limit exceeded

@tisnik has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 49 minutes and 32 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 49 minutes and 32 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1b8258ea-244b-4874-8e9d-334d5cc17857

📥 Commits

Reviewing files that changed from the base of the PR and between 9a98c54 and 876f700.

📒 Files selected for processing (1)
  • src/runners/quota_scheduler.py

Walkthrough

The documentation and examples for the weak points for AI module are expanded with five new files: one expanded markdown document with additional sections and conceptual content, and four new Python example scripts demonstrating named constants, Pydantic models, and functools.singledispatch patterns for AI-readable code.

Changes

Cohort / File(s) Summary
Documentation Expansion
docs/demos/lcore/weak_points_for_ai.md
Expanded with new sections ("Software entropy", "Do you use AI to add new features?"), multiple Python code snippets showing named constants with Final, Pydantic models, and singledispatch examples, plus updated BDD bullets and "common ground between humans and AI" references.
Example Code Files
docs/demos/lcore/weak_points_for_ai/ex8.py, docs/demos/lcore/weak_points_for_ai/ex9.py, docs/demos/lcore/weak_points_for_ai/exA.py, docs/demos/lcore/weak_points_for_ai/exB.py
Four new demonstration scripts: ex8 adds module constants (TOPIC_SUMMARY_INTERRUPT_TIMEOUT_SECONDS, ATTACHMENT_TYPES); ex9 introduces ShieldModerationBlocked Pydantic model; exA demonstrates @singledispatch functional dispatch; exB adds TranscriptMetadata model and create_transcript_metadata factory function with timestamp/hash utilities.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'LCORE-1841: More examples' is vague and generic, using non-descriptive language that doesn't convey the specific nature or scope of the changes. Consider using a more specific title that describes what kind of examples are being added, such as 'Add documentation examples for weak points in AI-driven code analysis' or similar.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/demos/lcore/weak_points_for_ai/ex8.py (1)

1-18: ⚠️ Potential issue | 🟡 Minor

Missing import for Final.

Final is used as a type annotation but never imported. If this snippet is meant to be runnable (or just import-checkable as a .py file), add the import; otherwise consider switching this file to a .md/fenced snippet.

🛠️ Suggested fix
 # True constants are possible in Python
+from typing import Final

 # Max seconds to wait for topic summary in background task after interrupt persist.
 TOPIC_SUMMARY_INTERRUPT_TIMEOUT_SECONDS: Final[float] = 30.0
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/demos/lcore/weak_points_for_ai/ex8.py` around lines 1 - 18, The file
uses the Final type for TOPIC_SUMMARY_INTERRUPT_TIMEOUT_SECONDS and
ATTACHMENT_TYPES but never imports it; add an import for Final (e.g., from
typing import Final) at the top of the module so the annotations for
TOPIC_SUMMARY_INTERRUPT_TIMEOUT_SECONDS and ATTACHMENT_TYPES are valid and the
file is import-checkable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/demos/lcore/weak_points_for_ai.md`:
- Line 80: Header contains a typo: change the heading text "## Software
enthropy" to "## Software entropy" in docs/demos/lcore/weak_points_for_ai.md so
the spelling is corrected; locate the heading line (the "## Software enthropy"
string) and replace "enthropy" with "entropy".
- Around line 553-556: Fix the typo in the constant/name by renaming
`UBIQUITOUS_LANGUAGE.md` to `UBIQUITOUS_LANGUAGE.md` and update any occurrences
in this document (and related references) so they match the repository spelling;
ensure the link text and any variable/constant usages that reference
`UBIQUITOUS_LANGUAGE` are corrected to the single-U form
`UBIQUITOUS_LANGUAGE.md`.

In `@docs/demos/lcore/weak_points_for_ai/ex9.py`:
- Around line 1-9: The file references BaseModel, Literal, and ResponseMessage
but never imports them; add the appropriate imports so ShieldModerationBlocked
can parse: import BaseModel from pydantic, Literal from typing, and bring in the
ResponseMessage alias (either from your utils.types alias that points to
OpenAIResponseMessage or directly import OpenAIResponseMessage from
llama_stack_api.openai_responses and alias it to ResponseMessage) so the class
ShieldModerationBlocked can be instantiated correctly.

In `@docs/demos/lcore/weak_points_for_ai/exA.py`:
- Around line 1-29: The file is missing imports for singledispatch and Any; add
"from functools import singledispatch" and "from typing import Any" at the top
so the decorator singledispatch and the Any type used in the function signature
and the registered variants (function, function.register) resolve correctly;
ensure these imports are present before the definition of function and its
registered variants.

In `@docs/demos/lcore/weak_points_for_ai/exB.py`:
- Around line 15-22: Add a concise docstring to the create_transcript_metadata
function that briefly describes its purpose (creating and returning a
TranscriptMetadata object for a conversation), documents each parameter
(user_id, conversation_id, model_id, provider_id, query_provider, query_model)
and states the return type (TranscriptMetadata); place the docstring immediately
under the def line in standard triple-quoted format and keep it short (one or
two sentences plus parameter/return annotations).
- Around line 1-33: The file references undefined symbols: BaseModel, Optional,
datetime, UTC, and _hash_user_id used by TranscriptMetadata and
create_transcript_metadata; import typing.Optional and pydantic.BaseModel,
import datetime and the UTC timezone (e.g., from datetime import datetime,
timezone or import UTC as in your repo), and import or re-export the private
helper _hash_user_id from the existing utility module (the same helper used in
src/utils/transcripts.py) so create_transcript_metadata can call it; update the
top-of-file imports accordingly and ensure the import names match the ones used
in TranscriptMetadata and create_transcript_metadata.

---

Outside diff comments:
In `@docs/demos/lcore/weak_points_for_ai/ex8.py`:
- Around line 1-18: The file uses the Final type for
TOPIC_SUMMARY_INTERRUPT_TIMEOUT_SECONDS and ATTACHMENT_TYPES but never imports
it; add an import for Final (e.g., from typing import Final) at the top of the
module so the annotations for TOPIC_SUMMARY_INTERRUPT_TIMEOUT_SECONDS and
ATTACHMENT_TYPES are valid and the file is import-checkable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 85062f2d-b254-496f-be4a-b775e27bdb0b

📥 Commits

Reviewing files that changed from the base of the PR and between 51a220e and 9a98c54.

⛔ Files ignored due to path filters (1)
  • docs/demos/lcore/images/APhilosophyOfSoftwareDesign.jpg is excluded by !**/*.jpg
📒 Files selected for processing (5)
  • docs/demos/lcore/weak_points_for_ai.md
  • docs/demos/lcore/weak_points_for_ai/ex8.py
  • docs/demos/lcore/weak_points_for_ai/ex9.py
  • docs/demos/lcore/weak_points_for_ai/exA.py
  • docs/demos/lcore/weak_points_for_ai/exB.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: unit_tests (3.13)
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: build-pr
  • GitHub Check: Pylinter
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
  • GitHub Check: E2E: server mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Use absolute imports for internal modules: from authentication import get_auth_dependency
Import FastAPI dependencies with: from fastapi import APIRouter, HTTPException, Request, status, Depends
Import Llama Stack client with: from llama_stack_client import AsyncLlamaStackClient
Check constants.py for shared constants before defining new ones
All modules start with descriptive docstrings explaining purpose
Use logger = get_logger(__name__) from log.py for module logging
Type aliases defined at module level for clarity
Use Final[type] as type hint for all constants
All functions require docstrings with brief descriptions
Complete type annotations for parameters and return types in functions
Use typing_extensions.Self for model validators in Pydantic models
Use modern union type syntax str | int instead of Union[str, int]
Use Optional[Type] for optional type hints
Use snake_case with descriptive, action-oriented function names (get_, validate_, check_)
Avoid in-place parameter modification anti-patterns; return new data structures instead
Use async def for I/O operations and external API calls
Handle APIConnectionError from Llama Stack in error handling
Use standard log levels with clear purposes: debug, info, warning, error
All classes require descriptive docstrings explaining purpose
Use PascalCase for class names with standard suffixes: Configuration, Error/Exception, Resolver, Interface
Use ABC for abstract base classes with @abstractmethod decorators
Use @model_validator and @field_validator for Pydantic model validation
Complete type annotations for all class attributes; use specific types, not Any
Follow Google Python docstring conventions with Parameters, Returns, Raises, and Attributes sections

Files:

  • docs/demos/lcore/weak_points_for_ai/ex9.py
  • docs/demos/lcore/weak_points_for_ai/ex8.py
  • docs/demos/lcore/weak_points_for_ai/exB.py
  • docs/demos/lcore/weak_points_for_ai/exA.py
🧠 Learnings (1)
📚 Learning: 2026-04-19T15:40:25.624Z
Learnt from: CR
Repo: lightspeed-core/lightspeed-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-19T15:40:25.624Z
Learning: Applies to **/constants.py : Central `constants.py` for shared constants with descriptive comments

Applied to files:

  • docs/demos/lcore/weak_points_for_ai/ex8.py
  • docs/demos/lcore/weak_points_for_ai.md
🪛 LanguageTool
docs/demos/lcore/weak_points_for_ai.md

[grammar] ~80-~80: Ensure spelling is correct
Context: ...or AI to reason about --- ## Software enthropy * "The Pragmatic Programmer" [Thomas & Hun...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[style] ~95-~95: It might be better to use ‘times’ with the time-relative pronoun ‘when’. (Alternatively, use ‘in/on which’.)
Context: ... pressure on this field * Especially in times where "code is cheap" is repeatedly said ---...

(WHEN_WHERE)

🔇 Additional comments (1)
docs/demos/lcore/weak_points_for_ai/exA.py (1)

13-15: No changes required; code is compatible with project's Python version.

The project specifies requires-python = ">=3.12,<3.14" in pyproject.toml. PEP 604 union types in singledispatch.register() are supported from Python 3.11+, so @function.register(list | tuple) works correctly on Python 3.12 and requires no modification.

			> Likely an incorrect or invalid review comment.


---

## Software enthropy
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Typo: "enthropy" → "entropy".

-## Software enthropy
+## Software entropy
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Software enthropy
## Software entropy
🧰 Tools
🪛 LanguageTool

[grammar] ~80-~80: Ensure spelling is correct
Context: ...or AI to reason about --- ## Software enthropy * "The Pragmatic Programmer" [Thomas & Hun...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/demos/lcore/weak_points_for_ai.md` at line 80, Header contains a typo:
change the heading text "## Software enthropy" to "## Software entropy" in
docs/demos/lcore/weak_points_for_ai.md so the spelling is corrected; locate the
heading line (the "## Software enthropy" string) and replace "enthropy" with
"entropy".

Comment on lines +553 to +556
- `UBIQUITUOUS_LANGUAGE.md` idea
- terms used in project with definition
- should be used in code (functions, vars, comments)
- https://github.com/mattpocock/skills/blob/main/ubiquitous-language/SKILL.md
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Typo: UBIQUITUOUS_LANGUAGE.mdUBIQUITOUS_LANGUAGE.md.

The referenced repository on line 556 uses the correct spelling (ubiquitous-language); the constant on line 553 has an extra U.

-    - `UBIQUITUOUS_LANGUAGE.md` idea
+    - `UBIQUITOUS_LANGUAGE.md` idea
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- `UBIQUITUOUS_LANGUAGE.md` idea
- terms used in project with definition
- should be used in code (functions, vars, comments)
- https://github.com/mattpocock/skills/blob/main/ubiquitous-language/SKILL.md
- `UBIQUITOUS_LANGUAGE.md` idea
- terms used in project with definition
- should be used in code (functions, vars, comments)
- https://github.com/mattpocock/skills/blob/main/ubiquitous-language/SKILL.md
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/demos/lcore/weak_points_for_ai.md` around lines 553 - 556, Fix the typo
in the constant/name by renaming `UBIQUITOUS_LANGUAGE.md` to
`UBIQUITOUS_LANGUAGE.md` and update any occurrences in this document (and
related references) so they match the repository spelling; ensure the link text
and any variable/constant usages that reference `UBIQUITOUS_LANGUAGE` are
corrected to the single-U form `UBIQUITOUS_LANGUAGE.md`.

Comment on lines +1 to +9
# Pydantic model utilization

class ShieldModerationBlocked(BaseModel):
"""Shield moderation blocked the content; refusal details are present."""

decision: Literal["blocked"] = "blocked"
message: str
moderation_id: str
refusal_response: ResponseMessage
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Missing imports — file will not parse/run.

BaseModel, Literal, and ResponseMessage are referenced but never imported. Per src/utils/types.py:17-26, ResponseMessage is the alias for OpenAIResponseMessage from llama_stack_api.openai_responses.

🛠️ Suggested fix
 # Pydantic model utilization
+from typing import Literal
+
+from pydantic import BaseModel
+from llama_stack_api.openai_responses import OpenAIResponseMessage as ResponseMessage


 class ShieldModerationBlocked(BaseModel):
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/demos/lcore/weak_points_for_ai/ex9.py` around lines 1 - 9, The file
references BaseModel, Literal, and ResponseMessage but never imports them; add
the appropriate imports so ShieldModerationBlocked can parse: import BaseModel
from pydantic, Literal from typing, and bring in the ResponseMessage alias
(either from your utils.types alias that points to OpenAIResponseMessage or
directly import OpenAIResponseMessage from llama_stack_api.openai_responses and
alias it to ResponseMessage) so the class ShieldModerationBlocked can be
instantiated correctly.

Comment on lines +1 to +29
# Dynamic dispatch: functional style

@singledispatch
def function(arg: Any) -> None:
print("Original function with argument", arg, "that has type", type(arg))


@function.register
def _(arg: int | str) -> None:
print("Integer variant with int or str argument:", arg)


@function.register(list | tuple)
def _(arg: list[Any] | tuple[Any, ...]) -> None:
print("List or tuple variant with argument:", arg)


@function.register
def _(arg: None) -> None:
print("None variant with argument:", arg)


function(42)
function("foo")
function(["foo", "bar", "baz"])
function(("foo", "bar", "baz"))
function(1.4142)
function(None)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Missing imports for singledispatch and Any.

 # Dynamic dispatch: functional style
+from functools import singledispatch
+from typing import Any


 `@singledispatch`
 def function(arg: Any) -> None:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Dynamic dispatch: functional style
@singledispatch
def function(arg: Any) -> None:
print("Original function with argument", arg, "that has type", type(arg))
@function.register
def _(arg: int | str) -> None:
print("Integer variant with int or str argument:", arg)
@function.register(list | tuple)
def _(arg: list[Any] | tuple[Any, ...]) -> None:
print("List or tuple variant with argument:", arg)
@function.register
def _(arg: None) -> None:
print("None variant with argument:", arg)
function(42)
function("foo")
function(["foo", "bar", "baz"])
function(("foo", "bar", "baz"))
function(1.4142)
function(None)
# Dynamic dispatch: functional style
from functools import singledispatch
from typing import Any
`@singledispatch`
def function(arg: Any) -> None:
print("Original function with argument", arg, "that has type", type(arg))
`@function.register`
def _(arg: int | str) -> None:
print("Integer variant with int or str argument:", arg)
`@function.register`(list | tuple)
def _(arg: list[Any] | tuple[Any, ...]) -> None:
print("List or tuple variant with argument:", arg)
`@function.register`
def _(arg: None) -> None:
print("None variant with argument:", arg)
function(42)
function("foo")
function(["foo", "bar", "baz"])
function(("foo", "bar", "baz"))
function(1.4142)
function(None)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/demos/lcore/weak_points_for_ai/exA.py` around lines 1 - 29, The file is
missing imports for singledispatch and Any; add "from functools import
singledispatch" and "from typing import Any" at the top so the decorator
singledispatch and the Any type used in the function signature and the
registered variants (function, function.register) resolve correctly; ensure
these imports are present before the definition of function and its registered
variants.

Comment on lines +1 to +33
# Pydantic model utilization

class TranscriptMetadata(BaseModel):
"""Metadata for a transcript entry."""

provider: Optional[str] = None
model: str
query_provider: Optional[str] = None
query_model: Optional[str] = None
user_id: str
conversation_id: str
timestamp: str


def create_transcript_metadata(
user_id: str,
conversation_id: str,
model_id: str,
provider_id: Optional[str],
query_provider: Optional[str],
query_model: Optional[str],
) -> TranscriptMetadata:
hashed_user_id = _hash_user_id(user_id)

return TranscriptMetadata(
provider=provider_id,
model=model_id,
query_provider=query_provider,
query_model=query_model,
user_id=hashed_user_id,
conversation_id=conversation_id,
timestamp=datetime.now(UTC).isoformat(),
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Missing imports and helper reference.

BaseModel, Optional, datetime, UTC, and _hash_user_id are all referenced without being imported/defined. Per src/utils/transcripts.py:6-10 and :30-43, UTC/datetime come from the stdlib and _hash_user_id is a private helper there.

🛠️ Suggested fix
 # Pydantic model utilization
+from datetime import UTC, datetime
+from typing import Optional
+
+from pydantic import BaseModel
+
+from utils.transcripts import _hash_user_id


 class TranscriptMetadata(BaseModel):
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/demos/lcore/weak_points_for_ai/exB.py` around lines 1 - 33, The file
references undefined symbols: BaseModel, Optional, datetime, UTC, and
_hash_user_id used by TranscriptMetadata and create_transcript_metadata; import
typing.Optional and pydantic.BaseModel, import datetime and the UTC timezone
(e.g., from datetime import datetime, timezone or import UTC as in your repo),
and import or re-export the private helper _hash_user_id from the existing
utility module (the same helper used in src/utils/transcripts.py) so
create_transcript_metadata can call it; update the top-of-file imports
accordingly and ensure the import names match the ones used in
TranscriptMetadata and create_transcript_metadata.

Comment on lines +15 to +22
def create_transcript_metadata(
user_id: str,
conversation_id: str,
model_id: str,
provider_id: Optional[str],
query_provider: Optional[str],
query_model: Optional[str],
) -> TranscriptMetadata:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Add a docstring to create_transcript_metadata.

As per coding guidelines: "All functions require docstrings with brief descriptions".

 def create_transcript_metadata(
     user_id: str,
     conversation_id: str,
     model_id: str,
     provider_id: Optional[str],
     query_provider: Optional[str],
     query_model: Optional[str],
 ) -> TranscriptMetadata:
+    """Build a TranscriptMetadata with a hashed user_id and current UTC timestamp."""
     hashed_user_id = _hash_user_id(user_id)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/demos/lcore/weak_points_for_ai/exB.py` around lines 15 - 22, Add a
concise docstring to the create_transcript_metadata function that briefly
describes its purpose (creating and returning a TranscriptMetadata object for a
conversation), documents each parameter (user_id, conversation_id, model_id,
provider_id, query_provider, query_model) and states the return type
(TranscriptMetadata); place the docstring immediately under the def line in
standard triple-quoted format and keep it short (one or two sentences plus
parameter/return annotations).

@tisnik tisnik merged commit 0725e1d into lightspeed-core:main Apr 26, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant