You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The interface requires an API Key to interact with large language models (LLM) hosted by KCL e-Research (ER).
9
+
The web application has three prototypes, each one on a separate screen.
10
10
11
-
If you are a KDL member of staff you can generate your own API Key like this:
12
-
1. Go to [the LLM platform hosted by ER](https://ai.create.kcl.ac.uk/)
13
-
2. Click the account icon in the top right corner of the screen: a drop down menu appears
14
-
3. Click 'Settings' in the menu; a Setting model appears
15
-
4. Click Account on the left hand side
16
-
5. click "Generate New API Key" near the bottom of the modal
17
-
6. copy the key and paste it in a private place for future referrence. Do not share it with anyone
18
-
7. Now you can paste that API Key in the Settings Tab of [the natural language processing application](https://kingsdigitallab.github.io/algorithmic-justice/nlpui.html) developped by KDL
11
+
1. A **questionnaire** about a driver's statement that can be answered by a magistrate or a large language model (LLM).
12
+
2. A **highlighter** to ask a LLM to highlight passages in the driver statement which are relevant to the users query.
13
+
3. An **integrated prototype** that lets a magistrate select cases to consult the automated answers to predefined questions from a LLM and the resulting fine calculated with an algorithm from the answers and the driver's weekly wage.
19
14
20
-
If everything goes well, you can return to the 'Highlighter' tab and ask a question to the language model.
15
+
# Interacting with LLMs
21
16
22
-
# Local set up
17
+
By default the application use **cached** responses from LLMs.
18
+
19
+
If you want to prompt live LLMs,
20
+
you'll need to select the URL of an LLM inference platform in the setting screen
21
+
and paste your API token.
22
+
23
+
If your machine has a GPU,
24
+
you can install and use a [local Ollama platform](https://ollama.com/),
25
+
usually at `http://localhost:11434/v1`. After installation, type
26
+
`ollama pull qwen3.5:4b` to download that particular LLM.
27
+
Check the [Ollama models list on their site](https://ollama.com/search)
28
+
to see what else you can download.
29
+
30
+
You can use [KCL e-Research (ER) AI Hub](https://ai.create.kcl.ac.uk/)
31
+
if you are a KCL staff member.
32
+
That platform URL is `https://api.ai.create.kcl.ac.uk/v1`.
33
+
Note that you will need to access it through ER VPN and
34
+
[create your own API Key](https://ai.create.kcl.ac.uk/dashboard/api-keys/create):
35
+
36
+
Another simple option is to use the [OpenRouter platform](https://openrouter.ai/)
37
+
which is a third-party service that offers a large number of paid-for and free models.
38
+
All you need is to create an account and an API key.
39
+
40
+
If everything goes well, you can return to the 'Highlighter' or 'Highlighter'
41
+
tab and ask a question to the language model.
42
+
43
+
# Running the application on your local machine
23
44
24
45
First clone this repository.
25
46
@@ -37,3 +58,14 @@ cd app
37
58
npm start
38
59
```
39
60
61
+
Then visit the index page at `http://localhost:3000` to access the prototypes.
62
+
63
+
# Data and tools
64
+
65
+
*[`settings.mjs`](app/settings.mjs): application-wide settings, such as API URLs and prompt templates for the LLM. `SETTINGS` is a special structure which values can be temporarily edited in the browser on the settings tab of the first prototype before prompting the LLMs.
66
+
67
+
*[`app-data.json`](app/data/app-data.json): contains the questionnaire, with algorithmic effect of each yes answer, the sample cases, and buckets indexed by the sum of effects from questionnaire and the the ratio applied to the monthly wage to calcualte the fine.
68
+
69
+
*[`responses.json`](app/data/responses.json): contains all the cached responses from the LLM for every combination of question and case in the questionnaire.
70
+
71
+
*[`cache.mjs`](tools/cache.mjs): a command line tool to get live responses from the LLM for every combination of question and case in the questionnaire and save them in `responses.json`.
0 commit comments