kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
rodzic
0e3d19d466
commit
407d7fcfcd
|
@ -5,19 +5,15 @@ import { z } from 'zod'
|
|||
import { Agentic, ReplicateStableDiffusionTool } from '@/index'
|
||||
|
||||
async function main() {
|
||||
const openai = new OpenAIClient({
|
||||
apiKey: process.env.OPENAI_API_KEY!,
|
||||
fetchOptions: {
|
||||
timeout: false
|
||||
}
|
||||
})
|
||||
const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! })
|
||||
const agentic = new Agentic({ openai })
|
||||
|
||||
const topic = process.argv[2] || 'san francisco'
|
||||
|
||||
const res = await agentic
|
||||
.gpt4(
|
||||
`Generate {{numImages}} images of {{topic}}. Use prompts that are artistic and creative.`
|
||||
({ numImages, topic }) =>
|
||||
`Generate ${numImages} images of ${topic}. Use prompts that are artistic and creative. The output should contain ${numImages} markdown images with descriptions.`
|
||||
)
|
||||
.modelParams({ temperature: 1.0 })
|
||||
.tools([new ReplicateStableDiffusionTool()])
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
"prepare": "husky install",
|
||||
"pre-commit": "lint-staged",
|
||||
"test": "run-s test:*",
|
||||
"test:unit": "ava",
|
||||
"test:unit": "NODE_OPTIONS='--loader=tsx --no-warnings' ava",
|
||||
"test:prettier": "prettier \"**/*.{js,jsx,ts,tsx}\" --check",
|
||||
"test:eslint": "eslint \"**/*.ts\"",
|
||||
"test-cov": "c8 ava"
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
lockfileVersion: '6.1'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
dependencies:
|
||||
'@agentic/midjourney-fetch':
|
||||
specifier: ^1.0.1
|
||||
|
@ -4807,3 +4803,7 @@ packages:
|
|||
/zod@3.21.4:
|
||||
resolution: {integrity: sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==}
|
||||
dev: false
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
|
|
@ -241,6 +241,7 @@ export abstract class BaseChatCompletion<
|
|||
// console.log('<<< completion', { messages, functions })
|
||||
const completion = await this._createChatCompletion(messages, functions)
|
||||
const message = completion.message
|
||||
const functionCall = message.function_call
|
||||
// console.log('>>> completion', completion.message)
|
||||
|
||||
this._logger.info(
|
||||
|
@ -249,9 +250,7 @@ export abstract class BaseChatCompletion<
|
|||
)
|
||||
ctx.metadata.completion = completion
|
||||
|
||||
if (message.function_call && !message.content) {
|
||||
const functionCall = message.function_call
|
||||
|
||||
if (functionCall) {
|
||||
if (!isUsingTools) {
|
||||
// TODO: not sure what we should do in this case...
|
||||
output = functionCall
|
||||
|
|
|
@ -50,6 +50,7 @@ test('OpenAIChatCompletion - tools - weather', async (t) => {
|
|||
)
|
||||
.call()
|
||||
|
||||
// console.log(JSON.stringify(result, null, 2))
|
||||
t.truthy(typeof result === 'object')
|
||||
t.truthy(typeof result.answer === 'number')
|
||||
t.truthy(typeof result.units === 'string')
|
||||
|
|
Ładowanie…
Reference in New Issue