Skip to content

Commit fb02768

Browse files
authored
chore: add readme section for backend url and use in llm analysis (fabric8-analytics#853)
1 parent 310a585 commit fb02768

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ The Red Hat Dependency Analytics extension has some configurable parameters that
9292

9393
### Configurable parameters
9494

95+
#### Exhort backend URL
96+
97+
Specify the URL of the Exhort backend used to analyze project dependencies. The default URL is https://rhda.rhcloud.com.
98+
9599
#### Red Hat Dependency Analytics Report File Path:
96100
Specify the local path to create the Red Hat Dependency Analytics report file.
97101
The default path is `/tmp/redhatDependencyAnalyticsReport.html`.

src/config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class Config {
6363
private readonly DEFAULT_SKOPEO_EXECUTABLE = 'skopeo';
6464
private readonly DEFAULT_DOCKER_EXECUTABLE = 'docker';
6565
private readonly DEFAULT_PODMAN_EXECUTABLE = 'podman';
66+
private readonly DEFAULT_EXHORT_DEV_URL = 'https://exhort.stage.devshift.net';
67+
private readonly DEFAULT_EXHORT_PROD_URL = 'https://rhda.rhcloud.com';
6668

6769
/**
6870
* Creates an instance of the Config class.
@@ -95,11 +97,13 @@ class Config {
9597
const redhatPreferGradleWrapper = vscode.workspace.getConfiguration('java.import.gradle.wrapper').get('enabled', true);
9698
const preferGradleWrapper = rhdaPreferGradleWrapper === 'fallback' ? redhatPreferGradleWrapper : rhdaPreferGradleWrapper === 'true';
9799

100+
const defaultBackendUrl = process.env['TRUSTIFY_DA_DEV_MODE'] === 'true' ? this.DEFAULT_EXHORT_DEV_URL : this.DEFAULT_EXHORT_PROD_URL;
101+
98102
this.stackAnalysisCommand = commands.STACK_ANALYSIS_COMMAND;
99103
this.trackRecommendationAcceptanceCommand = commands.TRACK_RECOMMENDATION_ACCEPTANCE_COMMAND;
100104
this.recommendationsEnabled = rhdaConfig.recommendations.enabled;
101105
this.utmSource = GlobalState.UTM_SOURCE;
102-
this.backendUrl = rhdaConfig.backendUrl || this.DEFAULT_BACKEND_URL;
106+
this.backendUrl = rhdaConfig.backendUrl || defaultBackendUrl;
103107
this.exhortProxyUrl = this.getEffectiveHttpProxyUrl();
104108
/* istanbul ignore next */
105109
this.matchManifestVersions = rhdaConfig.matchManifestVersions ? 'true' : 'false';

src/llmAnalysis.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { globalConfig } from './config';
2+
13
/* eslint-disable @typescript-eslint/naming-convention */
24
export interface ListModelCardResponse {
35
id: string,
@@ -56,9 +58,6 @@ export interface ModelCardResponse {
5658
}[]
5759
}
5860

59-
export const exhortDevDefaultUrl = 'https://exhort.stage.devshift.net';
60-
export const exhortDefaultUrl = 'https://rhda.rhcloud.com';
61-
6261
// eslint-disable-next-line @typescript-eslint/no-unused-vars
6362
export async function llmAnalysis(models: string[]): Promise<ListModelCardResponse[] | undefined> {
6463
const reqBody = JSON.stringify({
@@ -69,7 +68,7 @@ export async function llmAnalysis(models: string[]): Promise<ListModelCardRespon
6968
})
7069
});
7170

72-
const resp = await fetch(`${selectExhortBackend()}/api/v4/model-cards/`, {
71+
const resp = await fetch(`${globalConfig.backendUrl}/api/v4/model-cards/`, {
7372
method: 'POST',
7473
body: reqBody,
7574
});
@@ -81,16 +80,10 @@ export async function llmAnalysis(models: string[]): Promise<ListModelCardRespon
8180
}
8281

8382
export async function llmAnalysisDetails(modelID: string): Promise<ModelCardResponse | undefined> {
84-
const resp = await fetch(`${selectExhortBackend()}/api/v4/model-cards/${modelID}`);
83+
const resp = await fetch(`${globalConfig.backendUrl}/api/v4/model-cards/${modelID}`);
8584
if (!resp.ok) {
8685
return undefined;
8786
}
8887
return resp.json() as Promise<ModelCardResponse>;
8988
}
9089

91-
function selectExhortBackend() {
92-
if (process.env['TRUSTIFY_DA_DEV_MODE'] === 'true') {
93-
return exhortDevDefaultUrl;
94-
}
95-
return exhortDefaultUrl;
96-
}

0 commit comments

Comments
 (0)