0.0.1389 • Published 2 years ago

loopgpt-js v0.0.1389

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years 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

2 years ago

0.0.1388

2 years ago

0.0.1387

2 years ago

0.0.1386

2 years ago

0.0.1385

2 years ago

0.0.1384

2 years ago

0.0.1383

2 years ago

0.0.1382

2 years ago

0.0.1381

2 years ago

0.0.138

2 years ago

0.0.137

2 years ago

0.0.136

2 years ago

0.0.135

2 years ago

0.0.134

2 years ago

0.0.133

2 years ago

0.0.132

2 years ago

0.0.131

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.1

2 years ago