Skip to content

Commit

Permalink
feat: comply with multi type of agent
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Nov 8, 2023
1 parent bab56bc commit 52753f4
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions server/services/chat/olly_chat_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,30 @@ export class OllyChatService implements ChatService {
);
const memory = memoryInit(messages);

/**
* Wait for an API to fetch root agent id.
*/
const agentFrameworkResponse = (await opensearchClient.transport.request({
method: 'POST',
path: '/_plugins/_ml/agents/usjqiYsBC_Oyjc6-Rhpq/_execute',
path: '/_plugins/_ml/agents/_UoprosBZFp32K9Rsfqe/_execute',
body: {
parameters: {
question: input.content,
},
},
})) as ApiResponse<{
inference_results: Array<{ output: Array<{ name: string; result: string }> }>;
inference_results: Array<{
output: Array<{ name: string; result?: string; dataAsMap?: { response: string } }>;
}>;
}>;
const outputBody = agentFrameworkResponse.body.inference_results?.[0]?.output?.[0];
const agentFrameworkAnswer =
agentFrameworkResponse.body.inference_results[0].output[0].result;
outputBody?.dataAsMap?.response || (outputBody?.result as string);

/**
* Append history manually as suggestion requires latest history.
* Please delete following line after memory API is ready
*/
await memory.chatHistory.addUserMessage(input.content);
await memory.chatHistory.addAIChatMessage(agentFrameworkAnswer);

Expand Down

0 comments on commit 52753f4

Please sign in to comment.