xebia-functional / xef

Building applications with LLMs through composability, in Kotlin, Scala, ...

Home Page:https://xef.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GraphQL integration

rafaparadela opened this issue · comments

We are interested in creating a new module to integrate GraphQL as another data source. Some requirements:

Tabular data model (Created in the ticket #500)

  • Define a data model to represent tabular query results very generically.
    • No matter the nature of the query, the result should be expressed in terms of this new model.
    • It should contain a list of columns with name and type
    • It should contain a list of rows where each row matches the columns' specifications.

GraphQL Interaction

  • Expose an operation that receives a query in string format, performs it, and returns the result in the tabular format mentioned above.
  • Uses Apollo Kotlin to instantiate the GraphQL clients.

LLM Interaction

  • Expose an operation that receives these arguments:

    • GraphQL endpoint
    • Existing conversation
    • Involved Schema in SDL format (with models, aggregations, connections, queries, etc) (a string) including the descriptions of the nature of some fields to provide more context. Like the possible values if they are enumerations, etc (a string)
    • The user input
  • And performs:

    • Inject the relevant schema and description of the fields in a new Prompt
    • Run the call to the LLM to infer the output.
  • And finally returns an object that includes:

    • The GraphQL query that satisfies the input
    • A friendly response for the user (with wildcards like XXX to replace the final values in the response)