kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
pull/715/head
rodzic
d6252451f3
commit
7759aa43d3
|
@ -1,13 +0,0 @@
|
|||
import { timingSafeEqual } from 'node:crypto'
|
||||
|
||||
export function timingSafeCompare(a: string, b: string): boolean {
|
||||
if (typeof a !== 'string' || typeof b !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
if (a.length !== b.length) {
|
||||
return false
|
||||
}
|
||||
|
||||
return timingSafeEqual(Buffer.from(a), Buffer.from(b))
|
||||
}
|
|
@ -6,7 +6,6 @@ import { Hono } from 'hono'
|
|||
import { z } from 'zod'
|
||||
|
||||
import { type Env, parseEnv } from './env'
|
||||
import { timingSafeCompare } from './utils'
|
||||
|
||||
let serper: SerperClient
|
||||
|
||||
|
@ -65,10 +64,8 @@ export default {
|
|||
async (args, { _meta }) => {
|
||||
// Make sure the request is coming from Agentic
|
||||
assert(
|
||||
timingSafeCompare(
|
||||
(_meta?.agentic as any)?.agenticProxySecret,
|
||||
parsedEnv.AGENTIC_PROXY_SECRET
|
||||
),
|
||||
(_meta?.agentic as any)?.agenticProxySecret ===
|
||||
parsedEnv.AGENTIC_PROXY_SECRET,
|
||||
400,
|
||||
'Invalid request'
|
||||
)
|
||||
|
|
|
@ -16,8 +16,7 @@ import defaultKy, { type KyInstance } from 'ky'
|
|||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const client = await AgenticToolClient.fromIdentifier('@agentic/search')
|
||||
* const result = await client.functions.get('search').execute('search query')
|
||||
* const searchTool = await AgenticToolClient.fromIdentifier('@agentic/search')
|
||||
* ```
|
||||
*/
|
||||
export class AgenticToolClient extends AIFunctionsProvider {
|
||||
|
@ -41,6 +40,8 @@ export class AgenticToolClient extends AIFunctionsProvider {
|
|||
}) {
|
||||
super()
|
||||
|
||||
// TODO: add support for optional apiKey
|
||||
|
||||
this.project = project
|
||||
this.deployment = deployment
|
||||
this.agenticGatewayBaseUrl = agenticGatewayBaseUrl
|
||||
|
@ -82,9 +83,9 @@ export class AgenticToolClient extends AIFunctionsProvider {
|
|||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const client1 = await AgenticToolClient.fromIdentifier('@agentic/search')
|
||||
* const client2 = await AgenticToolClient.fromIdentifier('@agentic/search@v1.0.0')
|
||||
* const client3 = await AgenticToolClient.fromIdentifier('@agentic/search@latest')
|
||||
* const searchTool = await AgenticToolClient.fromIdentifier('@agentic/search')
|
||||
* const searchToolV1 = await AgenticToolClient.fromIdentifier('@agentic/search@v1.0.0')
|
||||
* const searchToolLatest = await AgenticToolClient.fromIdentifier('@agentic/search@latest')
|
||||
* ```
|
||||
*/
|
||||
static async fromIdentifier(
|
||||
|
|
Ładowanie…
Reference in New Issue