0.0.1389 • Published 12 months ago

loopgpt-js v0.0.1389

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

LoopGPT-JS

A lightweight Javascript implementation of the loopgpt Python module by Fariz Rahman For use in browser environments, particularly off the main thread within web worker processes

Add to your node project:

npm install loopgpt-js

Usage example:

const loopgpt = require('loopgpt-js')
const { Agent } = loopgpt

async function initLoop() {
  // you could save the api key(s) on a server and fetch it when needed
  const apiKeyResponse = await fetch('/api/openai', {
    method: 'POST',
  })

  const { apiKey } = await apiKeyResponse.json()

  // or you could pass it in directly
  const keys = {
    openai: apiKey,
    google: {
      googleApiKey: 'GOOGLE_API_KEY',
      googleCxId: 'CUSTOM_SEARCH_ENGINE_ID',
    },
  }

  // Create a new instance of the Agent class
  const agent = new Agent({
    keys: keys,
    goals: [
      'Run the web_search command for "California wildflowers" and then produce an overview of your findings with descriptions of each flower and their native area,',
    ],
  })

  const chat = async () => {
    let response
    response = await agent.chat({ message: null })

    while (response?.command?.name !== 'task_complete') {
      response = await agent.chat({ run_tool: true })
      console.log(agent)
      console.log(response)
    }
  }

  chat()
}

initLoop()
0.0.1389

12 months ago

0.0.1388

1 year ago

0.0.1387

1 year ago

0.0.1386

1 year ago

0.0.1385

1 year ago

0.0.1384

1 year ago

0.0.1383

1 year ago

0.0.1382

1 year ago

0.0.1381

1 year ago

0.0.138

1 year ago

0.0.137

1 year ago

0.0.136

1 year ago

0.0.135

1 year ago

0.0.134

1 year ago

0.0.133

1 year ago

0.0.132

1 year ago

0.0.131

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.1

1 year ago