* Initializes a new AgentRPC instance. * @param apiSecret The API Secret for your AgentRPC cluster. If not provided, it will be read from the `INFERABLE_API_SECRET` environment variable. * @param options Additional options for the AgentRPC client. * @param options.endpoint The endpoint for
(options?: {
apiSecret?: string;
endpoint?: string;
machineId?: string;
})
| 73 | * ``` |
| 74 | */ |
| 75 | constructor(options?: { |
| 76 | apiSecret?: string; |
| 77 | endpoint?: string; |
| 78 | machineId?: string; |
| 79 | }) { |
| 80 | const apiSecret = options?.apiSecret; |
| 81 | |
| 82 | if (!apiSecret) { |
| 83 | throw new AgentRPCError(`No API Secret provided.`); |
| 84 | } |
| 85 | |
| 86 | const [prefix, clusterId, rand] = apiSecret.split("_"); |
| 87 | |
| 88 | if (prefix !== "sk" || !clusterId || !rand) { |
| 89 | throw new AgentRPCError(`Invalid API Secret.`); |
| 90 | } else { |
| 91 | this.apiSecret = apiSecret; |
| 92 | this.clusterId = clusterId; |
| 93 | } |
| 94 | |
| 95 | this.endpoint = options?.endpoint || "https://api.agentrpc.com"; |
| 96 | |
| 97 | this.machineId = options?.machineId || machineId(); |
| 98 | |
| 99 | this.client = createApiClient({ |
| 100 | baseUrl: this.endpoint, |
| 101 | machineId: this.machineId, |
| 102 | apiSecret: this.apiSecret, |
| 103 | }); |
| 104 | } |
| 105 | |
| 106 | public OpenAI = { |
| 107 | getTools: async (): Promise<OpenAI.ChatCompletionTool[]> => { |
nothing calls this directly
no test coverage detected