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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Outline: Shrank llms-txt output to <200_000 input tokens
- Bundle: Added "count-tokens" procedure to inform about the size
of the outcome. Sonnet and Opus are limited to 200_000 input tokens.
- Query: Added a few more example questions specific to CrateDB

## v0.0.7 - 2025-07-22
- Prompt: Added `instructions-general.md` file when generating bundle
Expand Down
23 changes: 20 additions & 3 deletions src/cratedb_about/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ def ask(question: str, backend: t.Literal["claude", "openai"]) -> None:
if not question:
# Use the AUTOINCREMENT question or fall back to the first question if not found
default_question = next(
(q for q in Example.questions if "AUTOINCREMENT" in q),
Example.questions[0] if Example.questions else "What is CrateDB?",
(q for q in Example.knowledgebase if "AUTOINCREMENT" in q),
Example.knowledgebase[0] if Example.knowledgebase else "What is CrateDB?",
)
question = default_question
click.echo(f"Question: {question}\nAnswer:\n")
Expand All @@ -135,4 +135,21 @@ def list_questions() -> None:
"""
List a few example questions about CrateDB.
"""
click.echo("\n".join(Example.questions))

output = f"""
# Questions

## Knowledgebase

{Example.render(Example.knowledgebase)}

## Text-to-SQL

### time_series_data
{Example.render(Example.text_to_sql["time_series_data"])}

### summits
{Example.render(Example.text_to_sql["summits"])}
""".strip()

print(output) # noqa: T201
33 changes: 32 additions & 1 deletion src/cratedb_about/query/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@
import os
import typing as t
from pathlib import Path
from textwrap import dedent

from cratedb_about.settings import settings
from cratedb_about.util import get_cache_client

logger = logging.getLogger(__name__)


def cleanse(q: str) -> str:
return dedent(q).strip().replace("\n", " ")


class Example:
"""
A few example questions to ask about CrateDB.
"""

questions = [
knowledgebase = [
"What are the benefits of CrateDB?",
"Tell me about why CrateDB is different.",
"Tell me about CrateDB Cloud.",
Expand Down Expand Up @@ -43,6 +48,32 @@ class Example:
"How do I optimally synchronize data between MongoDB and CrateDB?",
]

text_to_sql = {
"time_series_data": [
"What is the average value for sensor 1?",
"What’s the name of the sensors table? Does it use any special cluster settings?",
"How many sensor measurements have been recorded?",
"When was the most recent measurement taken?",
"Do you see any irregularities in the recorded measurement values?",
cleanse("""
Can you plot the measurement values over time to visualize any trends or anomalies
by providing a Python code example and executing it?
Please highlight or annotate the outliers in the plot."""),
cleanse("""
Create several visualizations in Jupyter using matplotlib and seaborn based on data
in CrateDB’s `time_series_data` table, highlighting irregularities, and display them.
If you need to, please install required dependencies automatically."""),
],
"summits": [
"What’s the highest mountains in Switzerland (CH) in the summits table?",
"Can you provide a list of the highest mountains by country from the dataset?",
],
}

@classmethod
def render(cls, thing):
return "\n".join([f"- {item}" for item in thing])


class KnowledgeContextLoader:
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_example_question():
"""
Validate the example question bundle class.
"""
assert "How to enumerate active jobs?" in Example.questions
assert "How to enumerate active jobs?" in Example.knowledgebase


def test_ask_openai_no_api_key():
Expand Down