kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: switch from @agentic/openai-fetch to openai-fetch
rodzic
c13a43e41b
commit
7318eb0988
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { Agentic } from '@/agentic'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { Agentic } from '@/agentic'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { Agentic, SearchAndCrawlTool, WeatherTool } from '@/index'
|
||||
|
@ -30,7 +30,7 @@ async function main() {
|
|||
topic: z.string()
|
||||
})
|
||||
)
|
||||
.call({ topic })
|
||||
.callWithMetadata({ topic })
|
||||
|
||||
console.log('\n\n\n')
|
||||
console.log(res)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { Agentic } from '@/agentic'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { Agentic, SerpAPITool } from '@/index'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { Agentic, CalculatorTool, WeatherTool } from '@/index'
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
"test:eslint": "eslint \"**/*.ts\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@agentic/openai-fetch": "^1.5.3",
|
||||
"@anthropic-ai/sdk": "^0.4.4",
|
||||
"@inquirer/checkbox": "^1.3.1",
|
||||
"@inquirer/editor": "^1.2.0",
|
||||
|
@ -54,6 +53,7 @@
|
|||
"ky": "^0.33.3",
|
||||
"nanoid": "^4.0.2",
|
||||
"normalize-url": "^8.0.0",
|
||||
"openai-fetch": "^1.6.3",
|
||||
"p-map": "^6.0.0",
|
||||
"p-retry": "^5.1.2",
|
||||
"p-throttle": "^5.1.0",
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
lockfileVersion: '6.1'
|
||||
lockfileVersion: '6.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
dependencies:
|
||||
'@agentic/openai-fetch':
|
||||
specifier: ^1.5.3
|
||||
version: 1.5.3
|
||||
'@anthropic-ai/sdk':
|
||||
specifier: ^0.4.4
|
||||
version: 0.4.4
|
||||
|
@ -53,6 +50,9 @@ dependencies:
|
|||
normalize-url:
|
||||
specifier: ^8.0.0
|
||||
version: 8.0.0
|
||||
openai-fetch:
|
||||
specifier: ^1.6.3
|
||||
version: 1.6.3
|
||||
p-map:
|
||||
specifier: ^6.0.0
|
||||
version: 6.0.0
|
||||
|
@ -178,13 +178,6 @@ devDependencies:
|
|||
|
||||
packages:
|
||||
|
||||
/@agentic/openai-fetch@1.5.3:
|
||||
resolution: {integrity: sha512-4c5YWz6jQdGxxM+SVhf0XW3mKYnFr56hntPep+y7wRfkjUl6lgZiuU3J61esQ8bj8vSFkgSfwjf3DeZIi/IEsg==}
|
||||
dependencies:
|
||||
ky: 0.33.3
|
||||
zod: 3.21.4
|
||||
dev: false
|
||||
|
||||
/@anthropic-ai/sdk@0.4.4:
|
||||
resolution: {integrity: sha512-Z/39nQi1sSUCeLII3lsAbL1u+0JF6cR2XmUEX9sLH0VtxmIjY6cjOUYjCkYh4oapTxOkhAFnVSAFJ6cxml2qXg==}
|
||||
dependencies:
|
||||
|
@ -3322,6 +3315,13 @@ packages:
|
|||
mimic-fn: 4.0.0
|
||||
dev: true
|
||||
|
||||
/openai-fetch@1.6.3:
|
||||
resolution: {integrity: sha512-IM8bygs5qDOZ/WWB5nEPfm/JOqIj1BIO6R3gAW9vlL1oHtqO9D8ODQvkUNwMWRvW9xqqjlw4AnHYdhQ0o3NabA==}
|
||||
dependencies:
|
||||
ky: 0.33.3
|
||||
zod: 3.21.4
|
||||
dev: false
|
||||
|
||||
/optionator@0.9.1:
|
||||
resolution: {integrity: sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==}
|
||||
engines: {node: '>= 0.8.0'}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { Agentic } from '@/agentic'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { Agentic } from '@/agentic'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { Agentic } from '@/agentic'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { HumanFeedbackMechanismCLI } from '@/human-feedback'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { HumanFeedbackMechanismSlack } from '@/human-feedback'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { HumanFeedbackMechanismTwilio } from '@/human-feedback'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { Agentic } from '@/agentic'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { Agentic } from '@/agentic'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import 'dotenv/config'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { Agentic, MetaphorSearchTool } from '@/index'
|
||||
|
|
|
@ -280,21 +280,25 @@ export abstract class BaseChatCompletion<
|
|||
functionCall.name = functionName
|
||||
}
|
||||
|
||||
const rawFunctionCallArguments = functionCall.arguments?.trim()
|
||||
let functionArguments: any
|
||||
try {
|
||||
functionArguments = JSON.parse(jsonrepair(functionCall.arguments))
|
||||
} catch (err: any) {
|
||||
if (err instanceof JSONRepairError) {
|
||||
throw new errors.OutputValidationError(err.message, {
|
||||
cause: err
|
||||
})
|
||||
} else if (err instanceof SyntaxError) {
|
||||
throw new errors.OutputValidationError(
|
||||
`Invalid JSON object: ${err.message}`,
|
||||
{ cause: err }
|
||||
)
|
||||
} else {
|
||||
throw err
|
||||
|
||||
if (rawFunctionCallArguments) {
|
||||
try {
|
||||
functionArguments = JSON.parse(jsonrepair(rawFunctionCallArguments))
|
||||
} catch (err: any) {
|
||||
if (err instanceof JSONRepairError) {
|
||||
throw new errors.OutputValidationError(err.message, {
|
||||
cause: err
|
||||
})
|
||||
} else if (err instanceof SyntaxError) {
|
||||
throw new errors.OutputValidationError(
|
||||
`Invalid JSON object: ${err.message}`,
|
||||
{ cause: err }
|
||||
)
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ export async function getNumTokensForChatMessages({
|
|||
let content = message.content || ''
|
||||
if (message.function_call) {
|
||||
// TODO: this case needs testing
|
||||
content = message.function_call.arguments
|
||||
content = message.function_call.arguments || ''
|
||||
}
|
||||
|
||||
const [numTokensContent, numTokensRole, numTokensName] =
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as openai from '@agentic/openai-fetch'
|
||||
import * as anthropic from '@anthropic-ai/sdk'
|
||||
import * as openai from 'openai-fetch'
|
||||
import ky from 'ky'
|
||||
import type { Options as RetryOptions } from 'p-retry'
|
||||
import type { JsonObject, Jsonifiable } from 'type-fest'
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import * as anthropic from '@anthropic-ai/sdk'
|
||||
import { OpenAIClient } from '@agentic/openai-fetch'
|
||||
import KeyvRedis from '@keyv/redis'
|
||||
import 'dotenv/config'
|
||||
import hashObject from 'hash-obj'
|
||||
import Redis from 'ioredis'
|
||||
import Keyv from 'keyv'
|
||||
import defaultKy, { AfterResponseHook, BeforeRequestHook } from 'ky'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import pMemoize from 'p-memoize'
|
||||
|
||||
import * as types from '@/types'
|
||||
|
|
Ładowanie…
Reference in New Issue