PolicyEngine / policyengine-api

PolicyEngine's REST API for computing policy impacts.
GNU Affero General Public License v3.0
7 stars 19 forks source link

Implement Claude #1507

Closed anth-volk closed 1 month ago

anth-volk commented 1 month ago

Fixes #1506.

This PR replaces the OpenAI integration within the get_analysis endpoint with Claude, utilizing roughly the same structure as the previous implementation did by utilizing a server-sent event stream and a time measure to progressively update the analysis table with Claude's output. This PR also updates the GitHub Actions to utilize the relevant API key, which has also been already been added to the repo. Finally, this PR adds tests to ensure that Claude functions properly.

This PR does not, however, edit the default prompt that is passed to Claude, nor edit dashboard/experiments/gpt4_api_user.py, as I was unsure of the state of that file.

An example video below demonstrates the app running off of a local version of the API that has implemented Claude. Based on the video, we may look to better tune the default prompt, as the output is clearer than previously with GPT-4, but the formatting is still not ideal.

https://github.com/PolicyEngine/policyengine-api/assets/14987227/b871fef6-90f2-463e-80fb-2b7c3f72f313