C3 AI Documentation Home

Query Logging and Feedback

Fetch query results

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

Latest query result

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

Filtered by user

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

Query count by user

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

View user feedback on queries

Positive feedback

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

Negative feedback

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

Debug failures and poor answers

Engine Log

See error messages and chain-of-thought reasoning corresponding to a user's query in the engine log.

engineLog = queryResult.parseEngineLog().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 clicking the History nav menu icon. See Engine Log UX documentation for more details.

Improving quality of answers

Unstructured queries

Structured queries

  • Add/remove data sources
  • Edit table and column descriptions to accurately represent data
  • Add few shot examples to the prompt for generating eval spec
    • Add sample question and spec for a query that received positive feedback
    • Add sample question and corrected spec for a query that received negative feedback
Was this page helpful?