Skip to content

Commit

Permalink
Conversation cache
Browse files Browse the repository at this point in the history
  • Loading branch information
frankyhollywood committed Aug 13, 2024
1 parent 72ca06a commit cfacd57
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 24 deletions.
1 change: 1 addition & 0 deletions charts/fairspace/templates/project/configmap-saturn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ data:
port: 8090
livenessPort: 8091
publicUrl: {{ template "fairspace.url" . }}
llmConversationCachePath: "/data/saturn/conversations"
jena:
metadataBaseIRI: http://{{ .Values.fairspace.ingress.domain }}/iri/
datasetPath: "/data/saturn/db"
Expand Down
25 changes: 25 additions & 0 deletions charts/fairspace/templates/project/stateful-set.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ spec:
{{- if has "ExtraStorage" .Values.fairspace.features }}
- name: extra-file-storage
mountPath: /data/saturn/extra-files
{{- end }}
{{- if has "LlmSearch" .Values.fairspace.features }}
- name: llm
mountPath: /data/saturn/conversations
{{- end }}
livenessProbe:
httpGet:
Expand Down Expand Up @@ -204,6 +208,27 @@ spec:
{{- else }}
storageClassName: {{ .Values.saturn.persistence.files.storageClass | quote }}
{{- end }}
{{- end }}
- metadata:
name: llm
labels:
app: saturn
{{- include "fairspace.labels" . | nindent 8 }}
{{- if .Values.saturn.persistence.llm.annotations }}
annotations:
{{ toYaml .Values.saturn.persistence.llm.annotations | indent 8 }}
{{- end }}
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{ .Values.saturn.persistence.llm.size | quote }}
{{- if .Values.saturn.persistence.llm.storageClass }}
{{- if (eq "-" .Values.saturn.persistence.llm.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: {{ .Values.saturn.persistence.llm.storageClass | quote }}
{{- end }}
{{- end }}
{{- if has "ExtraStorage" .Values.fairspace.features }}
- metadata:
Expand Down
45 changes: 26 additions & 19 deletions projects/mercury/src/layout/__tests__/MainMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,43 @@ import ServicesContext from '../../common/contexts/ServicesContext';
import UserContext from '../../users/UserContext';
import ExternalStoragesContext from '../../external-storage/ExternalStoragesContext';
import ExternalMetadataSourceContext from '../../metadata/metadata-sources/ExternalMetadataSourceContext';
import FeaturesContext from '../../common/contexts/FeaturesContext';
import InternalMetadataSourceContext from '../../metadata/metadata-sources/InternalMetadataSourceContext';
import MetadataViewContext from '../../metadata/views/MetadataViewContext';
import MainMenu from '../MainMenu';
import {DEFAULT_METADATA_VIEW_MENU_LABEL} from '../../constants';
import theme from '../../App.theme';

const mockFeatureContext = {
isFeatureEnabled: jest.fn()
};

describe('MainMenu', () => {
const setup = (user, services, externalStorages, externalMetadataSources, internalMetadata, views) => {
return render(
<ThemeProvider theme={theme}>
<Router>
<ServicesContext.Provider value={{services}}>
<UserContext.Provider value={{currentUser: user}}>
<ExternalStoragesContext.Provider value={{externalStorages}}>
<ExternalMetadataSourceContext.Provider value={{externalMetadataSources}}>
<InternalMetadataSourceContext.Provider
value={{
internalMetadataIcon: internalMetadata.icon,
internalMetadataLabel:
internalMetadata.label || DEFAULT_METADATA_VIEW_MENU_LABEL
}}
>
<MetadataViewContext.Provider value={{views}}>
<MainMenu open />
</MetadataViewContext.Provider>
</InternalMetadataSourceContext.Provider>
</ExternalMetadataSourceContext.Provider>
</ExternalStoragesContext.Provider>
</UserContext.Provider>
</ServicesContext.Provider>
<FeaturesContext.Provider value={mockFeatureContext}>
<ServicesContext.Provider value={{services}}>
<UserContext.Provider value={{currentUser: user}}>
<ExternalStoragesContext.Provider value={{externalStorages}}>
<ExternalMetadataSourceContext.Provider value={{externalMetadataSources}}>
<InternalMetadataSourceContext.Provider
value={{
internalMetadataIcon: internalMetadata.icon,
internalMetadataLabel:
internalMetadata.label || DEFAULT_METADATA_VIEW_MENU_LABEL
}}
>
<MetadataViewContext.Provider value={{views}}>
<MainMenu open />
</MetadataViewContext.Provider>
</InternalMetadataSourceContext.Provider>
</ExternalMetadataSourceContext.Provider>
</ExternalStoragesContext.Provider>
</UserContext.Provider>
</ServicesContext.Provider>
</FeaturesContext.Provider>
</Router>
</ThemeProvider>
);
Expand Down
4 changes: 1 addition & 3 deletions projects/saturn/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dependencies {
implementation "com.sparkjava:spark-core:2.9.4"
implementation 'com.pivovarit:throwing-function:1.5.1'
implementation 'com.google.guava:guava:33.0.0-jre'
// implementation 'jakarta.servlet:jakarta.servlet-api:6.0.0' // To be updated when Jena 5 is released.
// implementation 'jakarta.servlet:jakarta.servlet-api:6.0.0' // To be updated when Jena 5 is released.
implementation('com.io-informatics.oss:jackson-jsonld:0.1.1') {
exclude group: 'com.github.jsonld-java'
}
Expand All @@ -69,8 +69,6 @@ dependencies {
implementation "org.postgresql:postgresql:${postgresqlVersion}"
implementation "com.zaxxer:HikariCP:5.1.0"

implementation("org.json:json:20240303")

runtimeOnly 'org.apache.logging.log4j:log4j-api:2.23.0'
runtimeOnly 'org.apache.logging.log4j:log4j-core:2.23.0'
runtimeOnly 'org.apache.logging.log4j:log4j-slf4j2-impl:2.23.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public class Config {

public Search search = new Search();

public String llmConversationCachePath = "data/conversations";

public static class Jena {
public String metadataBaseIRI = "http://localhost/iri/";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
import java.util.stream.Collectors;

import lombok.extern.log4j.*;
import io.fairspace.saturn.services.llm.LlmConversation;
import org.json.JSONObject;
import spark.Request;

import io.fairspace.saturn.services.BaseApp;

import static io.fairspace.saturn.auth.RequestContext.getAccessToken;
import static io.fairspace.saturn.config.ConfigLoader.CONFIG;

import static org.eclipse.jetty.http.MimeTypes.Type.APPLICATION_JSON;
import static spark.Spark.get;
import static spark.Spark.post;

@Log4j2
public class AiSearchApp extends BaseApp {
final String CACHE_DIR = "./data/conversations/";
final String CACHE_DIR = CONFIG.llmConversationCachePath;

public AiSearchApp(String basePath) {
super(basePath);
Expand Down

0 comments on commit cfacd57

Please sign in to comment.