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 StarSearchToolsService {
managerSystemMessage: string;
constructor(
private configService: ConfigService,
private openAIWrappedService: OpenAIWrappedService,
private bingSearchAgent: BingSearchAgent,
private clientAgent: ClientAgent,
private pullRequestAgent: PullRequestAgent,
private issuesAgent: IssuesAgent,
private releaseAgent: ReleaseAgent
) {
this.managerSystemMessage = this.configService.get("starsearch.managerSystemMessage")!;
}
runTools({
question,
lastMessage,
threadSummary,
}: {
question: string;
lastMessage?: string;
threadSummary?: string;
}): ChatCompletionStreamingRunner {
const tools = [
/*
* ----------------------------------------------------------------------
* Client graphs/charts injectable tools
*/
this.clientAgent.renderLottoFactorTool,
/*
* ----------------------------------------------------------------------
* PR agent injectable tools
*/
this.pullRequestAgent.searchAllPrsTool,
this.pullRequestAgent.searchPrsByAuthorTool,
this.pullRequestAgent.searchPrsByRepoNameTool,
this.pullRequestAgent.searchPrsByRepoNameAndAuthorTool,
/*
* ----------------------------------------------------------------------
* Issues agent injectable tools
*/
this.issuesAgent.searchAllIssuesTool,
this.issuesAgent.searchIssuesByAuthorTool,
this.issuesAgent.searchIssuesByRepoNameTool,
this.issuesAgent.searchIssuesByRepoNameAndAuthorTool,
/*
* ----------------------------------------------------------------------
* Release agent injectable tools
*/
this.releaseAgent.getReleasesByRepoNameTool,
/*
* ----------------------------------------------------------------------
* Bing search agent injectable tools
*/
this.bingSearchAgent.bingSearchTool,
];
let userMessage = "";
if (lastMessage && threadSummary) {
userMessage = `Last message:
---
${lastMessage}
Chat history summary:
---
${threadSummary}
Prompt:
---
${question}`;
} else {
userMessage = `Last message:
---
No chat history present.
Chat history summary:
---
No chat history present
Prompt:
---
${question}`;
}
return this.openAIWrappedService.runToolsStream(this.managerSystemMessage, userMessage, tools);
}
}