cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Generative AI
Explore discussions on generative artificial intelligence techniques and applications within the Databricks Community. Share ideas, challenges, and breakthroughs in this cutting-edge field.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How do I query genie space's actual conversation messages? (Genie space API)

Cobs
New Contributor

 Hi I'm creating a databricks app and I want to show genie space conversations messages both from users and genie. 

This is the api i'm using : GET /api/2.0/genie/spaces/{space_id}/conversations/{conversation_id}/messages/{message_id}

Get conversation message | Genie API | REST API reference | Azure Databricks

I could get user questions but I can't really get genie's response. Only things I get is query data which I don't really need. So far best I could do was to use query title. But on messages that didn't use SQL query it doesn't even show any response from genie. 

Here is an example of data I got :

{
   "id":"asfsadf21312",
   "space_id":"asdf123123",
   "conversation_id":"sdaf123123",
   "user_id":1231241235,
   "created_timestamp":1782291337250,
   "last_updated_timestamp":1782291413342,
   "status":"COMPLETED",
   "content":"Describe this dataset and the important KPIs/categories I can analyze",
   "attachments":[
      {
         "query":{
            "title":"Stock breakdown by logistic status",
            "query":"\nSELECT \n MEASURE(`Total Stock`) AS total_stock",
            "statement_id":"01f16fasasdsadf3",
            "thoughts":[
               {
                  "thought_type":"THOUGHT_TYPE_DATA_SOURCING",
                  "content":"stocks"
               }
            ]
         },
         "attachment_id":"12312sadasdf"
      }
   ],
   "auto_regenerate_count":0,
   "message_id":"123asf"
}

According to API docs it should also return text object but I haven't gotten one. Is there any other way around that I could get the genie's actual response that I see on databricks UI? 

Any help would be appreciated!!

 

 

 

1 REPLY 1

empire_labs
New Contributor II

Hi Cobs, I hit the same wall building on the Genie API. The key is that content in the message object is the user's message, not Genie's answer. The actual response lives in the attachments array, and there are several attachment types:

- attachments[].query - the SQL query Genie generated (what you're seeing now)
- attachments[].text - Genie's natural-language response, including the final summary when available, this is what the UI renders as the answer
- attachments[].suggested_questions  follow-up suggestions
- attachments[].viz - visualization (beta, when enabled)
So for a message like your example, you'd pull attachments[].text (and fall back to attachments[].query when text is absent, e.g. SQL-only responses). For messages where Genie didn't run a query at all, the text attachment is the only place the answer exists.
Two practical tips:
1. Poll status until it's COMPLETED before reading attachments, the text attachment isn't guaranteed to be present while Genie is still working (and watch for error.type on failure).
2. To render a full conversation like the UI, use the List messages endpoint (GET /api/2.0/genie/spaces/{space_id}/conversations/{conversation_id}/messages) and iterate: user question from content, assistant answer from attachments[].text / attachments[].query.
Dump the full JSON of a known-good message to see all attachment types in your workspace - the docs list them but seeing the real shape helps.
Hope that unblocks you.
Eddie - Empire Labs