mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-06-09 19:47:39 +08:00
feat: add websearch tools
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Agent, Runner, hostedMcpTool, withTrace } from "@openai/agents";
|
import { Agent, Runner, hostedMcpTool, withTrace, webSearchTool } from "@openai/agents";
|
||||||
|
|
||||||
export type WorkflowInput = { input_as_text: string };
|
export type WorkflowInput = { input_as_text: string };
|
||||||
|
|
||||||
@@ -6,8 +6,9 @@ export abstract class BotFather {
|
|||||||
protected readonly openisleToken = (process.env.OPENISLE_TOKEN ?? "").trim();
|
protected readonly openisleToken = (process.env.OPENISLE_TOKEN ?? "").trim();
|
||||||
protected readonly weatherToken = (process.env.APIFY_API_TOKEN ?? "").trim();
|
protected readonly weatherToken = (process.env.APIFY_API_TOKEN ?? "").trim();
|
||||||
|
|
||||||
protected readonly mcp = this.createHostedMcpTool();
|
protected readonly openisleMcp = this.createHostedMcpTool();
|
||||||
protected readonly weatherMcp = this.createWeatherMcpTool();
|
protected readonly weatherMcp = this.createWeatherMcpTool();
|
||||||
|
protected readonly webSearchPreview = this.createWebSearchPreviewTool();
|
||||||
protected readonly agent: Agent;
|
protected readonly agent: Agent;
|
||||||
|
|
||||||
constructor(protected readonly name: string) {
|
constructor(protected readonly name: string) {
|
||||||
@@ -27,7 +28,11 @@ export abstract class BotFather {
|
|||||||
this.agent = new Agent({
|
this.agent = new Agent({
|
||||||
name: this.name,
|
name: this.name,
|
||||||
instructions: this.buildInstructions(),
|
instructions: this.buildInstructions(),
|
||||||
tools: [this.mcp, this.weatherMcp],
|
tools: [
|
||||||
|
this.openisleMcp,
|
||||||
|
this.weatherMcp,
|
||||||
|
this.webSearchPreview
|
||||||
|
],
|
||||||
model: "gpt-4o",
|
model: "gpt-4o",
|
||||||
modelSettings: {
|
modelSettings: {
|
||||||
temperature: 0.7,
|
temperature: 0.7,
|
||||||
@@ -56,6 +61,19 @@ export abstract class BotFather {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private createWebSearchPreviewTool() {
|
||||||
|
return webSearchTool({
|
||||||
|
userLocation: {
|
||||||
|
type: "approximate",
|
||||||
|
country: undefined,
|
||||||
|
region: undefined,
|
||||||
|
city: undefined,
|
||||||
|
timezone: undefined
|
||||||
|
},
|
||||||
|
searchContextSize: "medium"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
private createHostedMcpTool() {
|
private createHostedMcpTool() {
|
||||||
const token = this.openisleToken;
|
const token = this.openisleToken;
|
||||||
const authConfig = token
|
const authConfig = token
|
||||||
|
|||||||
Reference in New Issue
Block a user