updated llama31 prompts

pull/5127/head
Stéphane Tetsing 3 months ago
parent a247fcce2d
commit 996e76cc26
  1. 28
      apps/remixdesktop/src/lib/InferenceServerManager.ts
  2. 2
      libs/remix-ai-core/src/inferencers/remote/remoteInference.ts
  3. 4
      libs/remix-ai-core/src/prompts/promptBuilder.ts
  4. 2
      libs/remix-ai-core/src/types/models.ts

@ -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
} }

@ -10,7 +10,7 @@ export class RemoteInferencer implements ICompletions {
api_url: string api_url: string
completion_url: string completion_url: string
max_history = 7 max_history = 7
model_op = RemoteBackendOPModel.DEEPSEEK model_op = RemoteBackendOPModel.DEEPSEEK // default model operation change this to llama if necessary
event: EventEmitter event: EventEmitter
constructor(apiUrl?:string, completionUrl?:string) { constructor(apiUrl?:string, completionUrl?:string) {

@ -2,7 +2,7 @@ import { RemoteBackendOPModel } from "../types/types"
import { ChatHistory } from "./chat" import { ChatHistory } from "./chat"
export const PromptBuilder = (inst, answr, modelop) => { export const PromptBuilder = (inst, answr, modelop) => {
if (modelop === RemoteBackendOPModel.CODELLAMA) return "" if (modelop === RemoteBackendOPModel.CODELLAMA) return `<|start_header_id|>user<|end_header_id|>${inst}<|eot_id|><|start_header_id|>assistant<|end_header_id|> ${answr}`
if (modelop === RemoteBackendOPModel.DEEPSEEK) return "\n### INSTRUCTION:\n" + inst + "\n### RESPONSE:\n" + answr if (modelop === RemoteBackendOPModel.DEEPSEEK) return "\n### INSTRUCTION:\n" + inst + "\n### RESPONSE:\n" + answr
if (modelop === RemoteBackendOPModel.MISTRAL) return "" if (modelop === RemoteBackendOPModel.MISTRAL) return ""
} }
@ -22,7 +22,7 @@ export const buildSolgptPromt = (userPrompt:string, modelOP:RemoteBackendOPModel
else newPrompt += PromptBuilder(question, answer, modelOP) else newPrompt += PromptBuilder(question, answer, modelOP)
} }
// finaly // finaly
newPrompt = "sol-gpt " + newPrompt + PromptBuilder(userPrompt.split('sol-gpt')[1], "", modelOP) newPrompt = "sol-gpt " + newPrompt + PromptBuilder(userPrompt.split('gpt')[1], "", modelOP)
return newPrompt return newPrompt
} }
} }

@ -75,7 +75,7 @@ const GenerationParams:IParams = {
topK: 40, topK: 40,
topP: 0.92, topP: 0.92,
max_new_tokens: 2000, max_new_tokens: 2000,
stream_result: true, stream_result: false,
} }
export { DefaultModels, CompletionParams, InsertionParams, GenerationParams } export { DefaultModels, CompletionParams, InsertionParams, GenerationParams }
Loading…
Cancel
Save