Skip to content

Conversation

@kdid
Copy link
Contributor

@kdid kdid commented Oct 2, 2025

Summary

Barebones implementation of websocket to be used for AI batch edit.

fixes https://github.com/nulib/repodev_planning_and_docs/issues/5669

Specific Changes in this PR

Two GraphQL endpoints implemented. Return dummy data, no streaming.

  • chatResponse subscription
  • sendChatMessage mutation

Version bump required by the PR

See Semantic Versioning 2.0.0 for help discerning which is required.

  • Patch
  • Minor
  • Major

Steps to Test

*Log into Meadow as Editor or above.

I've been testing it in postman by directly connecting to the websocket and then sending:

["1","1","__absinthe__:control","phx_join",{}]

followed by:

["1","2","__absinthe__:control","doc",{"query":"subscription {\n  chatResponse(conversationId: \"3336\"){\n    conversationId\n    message\n    type\n  }\n}","variables":{}}]

And then separately sending in a GraphQL mutation in GraphiQL (conversation id must match the subscription):
(I couldn't the GQL subscription to work using the GraphQL type request in Postman - if you do please let me know how you did it)

mutation {
  sendChatMessage(
    conversationId: 3336,
    type: "chat",
  	prompt: "Please add subject headings",
    query: "id:(207de63a-af53-4ef7-b05a-615a30721745 OR 1352daa3-a274-430e-a80e-a782066afc38)"
    
  ){
    conversationId
    type
    prompt
    query
  }
}

🚀 Deployment Notes

Note - if you check any of these boxes go to the (always open) main <- staging PR and add detailed notes and instructions to help out others who may end up deploying your changes to production

  • Backward compatible API changes
    • Database Schema changes
    • GraphQL API
    • Elasticsearch API
    • Ingest Sheet
    • CSV metadata export/update API
    • Shared Links export API
  • Backwards-incompatible API changes
    • Database Schema changes
    • GraphQL API
    • Elasticsearch API
    • Ingest Sheet
    • CSV metadata export/update API
    • Shared Links export API
  • Requires data migration
  • Requires database triggers disabled during deployment/migration
  • Requires reindex
  • Terraform changes
    • Adds/requires new or changed Terraform variables
  • Pipeline configuration changes (requires mix meadow.pipeline.setup run)
  • Requires new variable added to miscellany
  • Specific deployment synchronization instructions with other apps/API's
  • Other specific instructions/tasks

Tested/Verified

  • End users/stakeholders

@kdid kdid changed the title 5669 chat socket Implement websocket to be used for AI batch edit Oct 7, 2025
@kdid kdid force-pushed the 5669-chat-socket branch from 5f8e54c to ec8ea4d Compare October 8, 2025 15:56
@kdid kdid self-assigned this Oct 8, 2025
@kdid kdid marked this pull request as ready for review October 8, 2025 16:07
Copy link
Member

@mathewjordan mathewjordan left a comment

Choose a reason for hiding this comment

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

I think I have this working. I am seeing that the response back from the mutation is the data that is sent in:

{
  "data": {
    "sendChatMessage": {
      "conversationId": "3336",
      "prompt": "Please add subject headings",
      "query": "id:(207de63a-af53-4ef7-b05a-615a30721745 OR 1352daa3-a274-430e-a80e-a782066afc38)",
      "type": "chat"
    }
  }
}

Should I be seeing?

{
  conversation_id: conversation_id,
  message: "Here is your plan....",
  type: "plan",
}

@kdid
Copy link
Contributor Author

kdid commented Oct 8, 2025

mathewjordan - No, because the response to the mutation is immediate. The real response will come through the subscription after the chat has done it's work. It probably could just be on "OK" kind of a response in the mutation.

@bmquinn
Copy link
Contributor

bmquinn commented Oct 8, 2025

I noticed that when I send the chat message a second time (re-submitting the mutation in graphiql) it gives a 403 error response:

[
    null,
    null,
    "__absinthe__:doc:-576460752303411454:BF2519FB2B25CBEF5E890BE18AF7E21382193691625B0AD575C3DEC9D156A413",
    "subscription:data",
    {
        "result": {
            "data": {
                "chatResponse": null
            },
            "errors": [
                {
                    "message": "Forbidden",
                    "status": 403,
                    "path": [
                        "chatResponse"
                    ],
                    "locations": [
                        {
                            "line": 2,
                            "column": 3
                        }
                    ]
                }
            ]
        },
        "subscriptionId": "__absinthe__:doc:-576460752303411454:BF2519FB2B25CBEF5E890BE18AF7E21382193691625B0AD575C3DEC9D156A413"
    }
]

Are you seeing that as well @kdid ?

@mathewjordan
Copy link
Member

I am not seeing the 403.

@mathewjordan mathewjordan self-requested a review October 8, 2025 18:59
@kdid
Copy link
Contributor Author

kdid commented Oct 8, 2025

@bmquinn - try again. I removed the editor auth on the subscription. I think that was not the right way to do that. Or - it doesn't work via Postman.

@kdid kdid force-pushed the 5669-chat-socket branch from 2e28148 to 6b5e1c0 Compare October 8, 2025 19:14
Copy link
Member

@mathewjordan mathewjordan left a comment

Choose a reason for hiding this comment

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

I think this is working as expected. Looks good to me!

image

Copy link
Contributor

@bmquinn bmquinn left a comment

Choose a reason for hiding this comment

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

Works great on my end! 👍

@kdid kdid merged commit 4df9274 into deploy/meadow-ai Oct 8, 2025
3 checks passed
@kdid kdid deleted the 5669-chat-socket branch October 8, 2025 20:59
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.

5 participants