C3 AI Documentation Home

Query Logging and Feedback

Fetch query results

Query results store the query, chain-of-thought reasoning, answer, who asked it, and when.

Latest query result

JavaScript
lastQueryResult = Genai.Query.Result.fetch({ order: "descending(meta.created)", limit: 1 }).first()

Filtered by user

JavaScript
Genai.Query.Result.fetch({ filter: Filter.eq("meta.createdBy", User.myUser().id) })

Query count by user

JavaScript
c3Grid(Genai.Query.Result.eval({
    "group": "meta.createdBy",
    "projection": "meta.createdBy, count()",
    "order": "descending(count())"
}))

View user feedback on queries

Each piece of feedback is stored as a Genai.Query.Result.Feedback record and contains the following fields:

  • helpful (required boolean): whether the result was helpful (true = thumbs up, false = thumbs down)
  • comment: optional free-text comment from the user
  • additionalFeedback: optional list of additional tags selected from Genai.Query.Result.Feedback.Enum:
    • Positive tags: Helpful, Accurate
    • Negative tags: Not Helpful, Inaccurate, Outdated, Harmful
    • Response format tags: Text Summary, Image, Table
    • Structured data tags: Database Query, Visualization, Edited Structured Query Spec

Positive feedback

JavaScript
Genai.Query.Result.Feedback.fetch({ filter: "helpful == true"})

Negative feedback

JavaScript
Genai.Query.Result.Feedback.fetch({ filter: "helpful == false"})

Feedback with additional tags

JavaScript
Genai.Query.Result.Feedback.fetch({ filter: "additionalFeedback contains 'Inaccurate'"})

Debug failures and poor answers

Engine Log

The engine log contains error messages and chain-of-thought reasoning for your query.

JavaScript
engineLog = queryResult.parsedEngineLog

The engine log shows the:

  • Prompt passed to the LLM
  • Error stack trace when a query fails
  • Retrieved passages for unstructured data
  • Post-processing steps to database query for structured data

Engine Log UX

Past query results and engine logs can also be viewed in the UI by selecting the History nav item. For more details, see Query Engine Log UX.

Improve quality of answers

Unstructured queries

  • Add or remove documents.
  • Add and embed document metadata in indexed content.
  • Adjust LLM model parameters and prompts.

Structured queries

  • Add or remove data sources.
  • Edit table and column descriptions to accurately represent data.
  • Add few-shot examples to the prompt for generating an eval spec:
    • Add a sample question and spec for a query that received positive feedback.
    • Add a sample question and corrected spec for a query that received negative feedback.

See also

Was this page helpful?