src/star-search/agents/releases.agent.ts
Properties |
Methods |
|
constructor(configService: ConfigService, openAIWrappedService: OpenAIWrappedService, releaseGithubEventsService: ReleaseGithubEventsService)
|
||||||||||||
|
Defined in src/star-search/agents/releases.agent.ts:9
|
||||||||||||
|
Parameters :
|
| Public Async getReleasesByReponame | |||||
getReleasesByReponame(undefined: ReleasesParams)
|
|||||
|
Defined in src/star-search/agents/releases.agent.ts:19
|
|||||
|
Parameters :
Returns :
unknown
|
| Public Async getReleasesInDataset | |||||
getReleasesInDataset(undefined: ReleasesInDatasetParams)
|
|||||
|
Defined in src/star-search/agents/releases.agent.ts:41
|
|||||
|
Parameters :
Returns :
unknown
|
| Async runAgentTools | ||||||
runAgentTools(agentParams: ReleaseAgentParams)
|
||||||
|
Defined in src/star-search/agents/releases.agent.ts:62
|
||||||
|
Parameters :
Returns :
Promise<string | null | >
|
| agentSystemMessage |
Type : string
|
|
Defined in src/star-search/agents/releases.agent.ts:9
|
| Public getReleasesByRepoNameTool |
Default value : this.openAIWrappedService.makeRunnableToolFunction({
function: async (params: ReleasesParams) => this.getReleasesByReponame(params),
schema: ReleasesParams,
name: "getReleasesByReponame",
description:
"Gets the latest GitHub releases and their context for a specific repository. The repoName parameter should be of the form: 'organization/name'. Example: facebook/react.",
})
|
|
Defined in src/star-search/agents/releases.agent.ts:33
|
| Public getReleasesInDatasetTool |
Default value : this.openAIWrappedService.makeRunnableToolFunction({
function: async (params: ReleasesInDatasetParams) => this.getReleasesInDataset(params),
schema: ReleasesInDatasetParams,
name: "getReleasesInDataset",
description: `Gets the latest GitHub releases and their metadata within the given dataset over a range of days.`,
})
|
|
Defined in src/star-search/agents/releases.agent.ts:55
|
import { Injectable } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { OpenAIWrappedService } from "../../openai-wrapped/openai-wrapped.service";
import { ReleaseGithubEventsService } from "../../timescale/release_github_events.service";
import { ReleaseAgentParams, ReleasesInDatasetParams, ReleasesParams } from "../schemas/releases.schema";
@Injectable()
export class ReleaseAgent {
agentSystemMessage: string;
constructor(
private configService: ConfigService,
private openAIWrappedService: OpenAIWrappedService,
private releaseGithubEventsService: ReleaseGithubEventsService
) {
this.agentSystemMessage = this.configService.get("starsearch.releaseAgentSystemMessage")!;
}
public async getReleasesByReponame({ repoName, range }: ReleasesParams) {
const results = await this.releaseGithubEventsService.getReleases({
repos: repoName,
range,
skip: 0,
});
if (results.length === 0) {
return "no releases found";
}
return results;
}
public getReleasesByRepoNameTool = this.openAIWrappedService.makeRunnableToolFunction({
function: async (params: ReleasesParams) => this.getReleasesByReponame(params),
schema: ReleasesParams,
name: "getReleasesByReponame",
description:
"Gets the latest GitHub releases and their context for a specific repository. The repoName parameter should be of the form: 'organization/name'. Example: facebook/react.",
});
public async getReleasesInDataset({ dataset, range }: ReleasesInDatasetParams) {
const results = await this.releaseGithubEventsService.getReleases({
repos: dataset,
range,
skip: 0,
});
if (results.length === 0) {
return "no releases found";
}
return results;
}
public getReleasesInDatasetTool = this.openAIWrappedService.makeRunnableToolFunction({
function: async (params: ReleasesInDatasetParams) => this.getReleasesInDataset(params),
schema: ReleasesInDatasetParams,
name: "getReleasesInDataset",
description: `Gets the latest GitHub releases and their metadata within the given dataset over a range of days.`,
});
async runAgentTools(agentParams: ReleaseAgentParams): Promise<string | null | unknown> {
const tools = [this.getReleasesByRepoNameTool, this.getReleasesInDatasetTool];
if (agentParams.dataset) {
agentParams.prompt += `\n\nDataset: ${agentParams.dataset}`;
}
const runner = this.openAIWrappedService
.runTools(this.agentSystemMessage, agentParams.prompt, tools)
.on("message", (msg) => console.log("release agent msg", msg))
.on("functionCall", (functionCall) => console.log("release agent functionCall", functionCall))
.on("functionCallResult", (functionCallResult) =>
console.log("release agent functionCallResult", functionCallResult)
);
return runner.finalContent();
}
}