OpenFn / lightning

OpenFn/Lightning ⚡️ is the newest version of the OpenFn DPG and provides a web UI to visually manage complex workflow automation projects.
https://openfn.github.io/lightning/
GNU Lesser General Public License v3.0
115 stars 31 forks source link

Ai service #2216

Closed stuartc closed 2 days ago

stuartc commented 4 days ago

Validation Steps

OPENAI_API_KEY, your OpenAI API key. APOLLO_ENDPOINT, can use https://apollo.staging.openfn.org/.

Log in as a superuser, and go to edit a job - you should have the AI assistant menu item available.

Notes for the reviewer

There is no chat persistence between page navigation or reloads.

Related issue

Fixes #2193

Review checklist

codecov[bot] commented 3 days ago

Codecov Report

Attention: Patch coverage is 28.30189% with 76 lines in your changes missing coverage. Please review.

Project coverage is 88.93%. Comparing base (9423bd7) to head (c1708f5).

Files Patch % Lines
...g_web/live/workflow_live/ai_assistant_component.ex 0.00% 43 Missing :warning:
lib/lightning/ai_assistant/ai_assistant.ex 4.34% 22 Missing :warning:
lib/lightning_web/live/workflow_live/edit.ex 78.26% 5 Missing :warning:
lib/lightning/apollo_client.ex 50.00% 3 Missing :warning:
lib/lightning/config.ex 50.00% 3 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2216 +/- ## ========================================== - Coverage 89.67% 88.93% -0.75% ========================================== Files 275 278 +3 Lines 9055 9145 +90 ========================================== + Hits 8120 8133 +13 - Misses 935 1012 +77 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

midigofrank commented 2 days ago
  1. When clicking "run" from the middle panel, I notice that the AI chat panel gets wiped clear. (I also notice that the input panel flashes unexpectedly and then comes back.) Can you look into this?

@stuartc I think the chat gets cleared because the update callback of the LiveComponent gets called after the LiveView handle_params and that creates a new session.

I think we really need an external place to cache the session history to shield the user from losing the history maybe due to a liveview crash or something we don't account for.

stuartc commented 2 days ago

@midigofrank @taylordowns2000 I've fixed the wiping of the chat state on clicking run here: https://github.com/OpenFn/lightning/pull/2216/commits/8363a28bf9f17585d58ea37edf4a2bc702ad65f6