File
Methods
|
runTools
|
runTools(undefined: literal type)
|
|
|
Parameters :
| Name |
Type |
Optional |
literal type
|
No
|
Returns : ChatCompletionStreamingRunner
|
|
managerSystemMessage
|
Type : string
|
|
|
import { Injectable } from "@nestjs/common";
import { ChatCompletionStreamingRunner } from "openai/lib/ChatCompletionStreamingRunner";
import { ConfigService } from "@nestjs/config";
import { OpenAIWrappedService } from "../openai-wrapped/openai-wrapped.service";
import { BingSearchAgent } from "./agents/bing-search.agent";
import { PullRequestAgent } from "./agents/pull-request.agent";
import { IssuesAgent } from "./agents/issues.agent";
import { ReleaseAgent } from "./agents/releases.agent";
import { ClientAgent } from "./agents/client.agent";
@Injectable()
export class StarSearchWorkspaceToolsService {
managerSystemMessage: string;
constructor(
private configService: ConfigService,
private openAIWrappedService: OpenAIWrappedService,
private clientAgent: ClientAgent,
private bingSearchAgent: BingSearchAgent,
private pullRequestAgent: PullRequestAgent,
private issuesAgent: IssuesAgent,
private releaseAgent: ReleaseAgent
) {
this.managerSystemMessage = this.configService.get("starsearch.workspaceManagerSystemMessage")!;
}
/*
* --------------------------------------------------------------------------
* Client signals to render components
*/
runTools({
question,
lastMessage,
threadSummary,
dataset,
}: {
question: string;
lastMessage?: string;
threadSummary?: string;
dataset: string[];
}): ChatCompletionStreamingRunner {
const tools = [
/*
* ----------------------------------------------------------------------
* Client graphs/charts injectable tools
*/
this.clientAgent.renderLottoFactorTool,
/*
* ----------------------------------------------------------------------
* PR agent injected tools
*/
this.pullRequestAgent.searchAllPrsInDatasetTool,
this.pullRequestAgent.searchPrsByAuthorInDatasetTool,
/*
* ----------------------------------------------------------------------
* Issues agent injected tools
*/
this.issuesAgent.searchAllIssuesInDatasetTool,
this.issuesAgent.searchIssuesByAuthorInDatasetTool,
/*
* ----------------------------------------------------------------------
* Release agent injected tools
*/
this.releaseAgent.getReleasesInDatasetTool,
/*
* ----------------------------------------------------------------------
* Bing search agent injected tools
*/
this.bingSearchAgent.bingSearchTool,
];
let userMessage = "";
if (lastMessage && threadSummary) {
userMessage = `Dataset:
---
[${dataset.join(", ")}]
Last message:
---
${lastMessage}
Chat history summary:
---
${threadSummary}
Prompt:
---
${question}`;
} else {
userMessage = `Dataset:
---
[${dataset.join(", ")}]
Last message:
---
No chat history present.
Chat history summary:
---
No chat history present.
Prompt:
---
${question}`;
}
return this.openAIWrappedService.runToolsStream(this.managerSystemMessage, userMessage, tools);
}
}