|
|
@ -243,6 +243,23 @@ export class InferenceManager implements ICompletions { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async _handleExistingServer() { |
|
|
|
|
|
|
|
// check if the server is already running, kill it
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
const options = { headers: { 'Content-Type': 'application/json', } } |
|
|
|
|
|
|
|
const state = await axios.get(this.inferenceURL+"/state", options) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (state.data?.status) { |
|
|
|
|
|
|
|
console.log('Found existing Inference server running') |
|
|
|
|
|
|
|
this.stopInferenceServer() |
|
|
|
|
|
|
|
await axios.post(this.inferenceURL+"/kill", options) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
// catch connection refused
|
|
|
|
|
|
|
|
console.log('No existing Inference server running') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async _startServer() { |
|
|
|
private async _startServer() { |
|
|
|
const serverAvailable = await this._downloadInferenceServer() |
|
|
|
const serverAvailable = await this._downloadInferenceServer() |
|
|
|
if (!serverAvailable) { |
|
|
|
if (!serverAvailable) { |
|
|
@ -250,6 +267,9 @@ export class InferenceManager implements ICompletions { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// kill existing server if running
|
|
|
|
|
|
|
|
this._handleExistingServer() |
|
|
|
|
|
|
|
|
|
|
|
return new Promise<void>((resolve, reject) => { |
|
|
|
return new Promise<void>((resolve, reject) => { |
|
|
|
let serverPath = "" |
|
|
|
let serverPath = "" |
|
|
|
try { |
|
|
|
try { |
|
|
@ -274,7 +294,7 @@ export class InferenceManager implements ICompletions { |
|
|
|
|
|
|
|
|
|
|
|
const spawnArgs = [this.port]; |
|
|
|
const spawnArgs = [this.port]; |
|
|
|
|
|
|
|
|
|
|
|
console.log(`Spawning process: ${serverPath} ${spawnArgs.join(' ')}`); |
|
|
|
// console.log(`Spawning process: ${serverPath} ${spawnArgs.join(' ')}`);
|
|
|
|
this.inferenceProcess = spawn(serverPath, spawnArgs); |
|
|
|
this.inferenceProcess = spawn(serverPath, spawnArgs); |
|
|
|
|
|
|
|
|
|
|
|
this.inferenceProcess.stdout.on('data', (data) => { |
|
|
|
this.inferenceProcess.stdout.on('data', (data) => { |
|
|
@ -455,11 +475,11 @@ export class InferenceManager implements ICompletions { |
|
|
|
} |
|
|
|
} |
|
|
|
let modelOP = undefined |
|
|
|
let modelOP = undefined |
|
|
|
for (const model of this.selectedModels) { |
|
|
|
for (const model of this.selectedModels) { |
|
|
|
if (model?.modelOP) { |
|
|
|
if (model.modelType === ModelType.GENERAL) { |
|
|
|
modelOP = model.modelOP |
|
|
|
modelOP = model.modelOP |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
const prompt = buildSolgptPromt(userPrompt, this.selectedModels[0]?.modelOP) |
|
|
|
const prompt = buildSolgptPromt(userPrompt, modelOP) |
|
|
|
|
|
|
|
|
|
|
|
if (GenerationParams.stream_result) { |
|
|
|
if (GenerationParams.stream_result) { |
|
|
|
return this._streamInferenceRequest('solidity_answer', { prompt, ...params }) |
|
|
|
return this._streamInferenceRequest('solidity_answer', { prompt, ...params }) |
|
|
@ -468,6 +488,4 @@ export class InferenceManager implements ICompletions { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// kill dangling process making use of the port
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |