Skip to content

Commit

Permalink
Merge pull request #643 from transitive-bullshit/agentic
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit authored Jun 7, 2024
2 parents 89c86af + dc77d0e commit 88026ed
Show file tree
Hide file tree
Showing 93 changed files with 39,820 additions and 15 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
indent_style = space
indent_size = 2
tab_width = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ------------------------------------------------------------------------------
# This is an example .env file.
#
# All of these environment vars must be defined either in your environment or in
# a local .env file in order to run this project.
# ------------------------------------------------------------------------------
8 changes: 8 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"root": true,
"extends": ["@fisch0920/eslint-config/node"],
"rules": {
"unicorn/no-static-only-class": "off",
"@typescript-eslint/naming-convention": "off"
}
}
1 change: 1 addition & 0 deletions .github/funding.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [transitive-bullshit]
50 changes: 50 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI

on: [push, pull_request]

jobs:
test:
name: Test Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node-version:
- 20
- 21
- 22

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install pnpm
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: 9.1.4
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run test
run: pnpm run test
21 changes: 6 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

*.swp
.idea

# dependencies
/node_modules
node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/
.next/
out/

# production
/build
build/
dist/

# misc
.DS_Store
Expand All @@ -38,13 +36,6 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

# local env files
.env
.env.local
.env.build
.env.development.local
.env.test.local
.env.production.local

# data dumps
out/
old/
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run precommit
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
enable-pre-post-scripts=true
package-manager-strict=false
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"singleQuote": true,
"jsxSingleQuote": true,
"semi": false,
"useTabs": false,
"tabWidth": 2,
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
"trailingComma": "none"
}
128 changes: 128 additions & 0 deletions bin/scratch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/usr/bin/env node
import 'dotenv/config'

import restoreCursor from 'restore-cursor'

// import { SearxngClient } from '../src/services/searxng-client.js'
// import { ClearbitClient } from '../src/index.js'
// import { ProxycurlClient } from '../src/services/proxycurl-client.js'
// import { WikipediaClient } from '../src/index.js'
// import { PerigonClient } from '../src/index.js'
// import { FirecrawlClient } from '../src/index.js'
// import { ExaClient } from '../src/index.js'
// import { DiffbotClient } from '../src/index.js'
// import { WolframAlphaClient } from '../src/index.js'
// import {
// createTwitterV2Client,
// TwitterClient
// } from '../src/services/twitter/index.js'
// import { MidjourneyClient } from '../src/index.js'
// import { BingClient } from '../src/index.js'
import { TavilyClient } from '../src/index.js'

/**
* Scratch pad for testing.
*/
async function main() {
restoreCursor()

// const clearbit = new ClearbitClient()
// const res = await clearbit.companyEnrichment({
// domain: 'https://clay.com'
// })
// console.log(JSON.stringify(res, null, 2))

// const proxycurl = new ProxycurlClient()
// const res = await proxycurl.getLinkedInPerson({
// linkedin_profile_url: 'https://linkedin.com/in/fisch2'
// })
// console.log(JSON.stringify(res, null, 2))

// const wikipedia = new WikipediaClient()
// const res = await wikipedia.getPageSummary({
// // title: 'Naruto_(TV_series)'
// title: 'SpaceX'
// })
// console.log(JSON.stringify(res, null, 2))

// const searxng = new SearxngClient()
// const res = await searxng.search({
// query: 'golden gate bridge',
// engines: ['reddit']
// })
// console.log(JSON.stringify(res, null, 2))

// const perigon = new PerigonClient()
// const res = await perigon.searchArticles({
// q: 'AI agents AND startup',
// sourceGroup: 'top50tech'
// })
// console.log(JSON.stringify(res, null, 2))

// const firecrawl = new FirecrawlClient()
// const res = await firecrawl.scrapeUrl({
// url: 'https://www.bbc.com/news/articles/cp4475gwny1o'
// // url: 'https://www.theguardian.com/technology/article/2024/jun/04/openai-google-ai-risks-letter'
// // url: 'https://www.firecrawl.dev'
// })
// console.log(JSON.stringify(res, null, 2))

// const exa = new ExaClient()
// const res = await exa.search({
// query: 'OpenAI',
// contents: { text: true }
// })
// console.log(JSON.stringify(res, null, 2))

// const diffbot = new DiffbotClient()
// // const res = await diffbot.analyzeUrl({
// // url: 'https://www.bbc.com/news/articles/cp4475gwny1o'
// // })
// const res = await diffbot.enhanceEntity({
// type: 'Person',
// name: 'Kevin Raheja'
// })
// console.log(JSON.stringify(res, null, 2))

// const wolfram = new WolframAlphaClient()
// const res = await wolfram.ask({
// input: 'population of new york city'
// })
// console.log(res)

// const client = await createTwitterV2Client({
// scopes: ['tweet.read', 'users.read', 'offline.access']
// })
// const twitter = new TwitterClient({ client })
// // const res = await twitter.findUserByUsername({ username: 'transitive_bs' })
// const res = await twitter.searchRecentTweets({
// query: 'open source AI agents'
// })
// console.log(res)

// const midjourney = new MidjourneyClient()
// const res = await midjourney.imagine(
// 'tiny lil baby kittens playing with an inquisitive AI robot, kawaii, anime'
// )
// console.log(JSON.stringify(res, null, 2))

// const bing = new BingClient()
// const res = await bing.search({
// q: 'world cup 2024 freestyle wrestling news'
// })
// console.log(JSON.stringify(res, null, 2))

const tavily = new TavilyClient()
const res = await tavily.search({
query: 'when do experts predict that OpenAI will release GPT-5?',
include_answer: true
})
console.log(JSON.stringify(res, null, 2))
}

try {
await main()
} catch (err) {
console.error('error', err)
process.exit(1)
}
26 changes: 26 additions & 0 deletions examples/ai-sdk/browserbase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node
import 'dotenv/config'

import { openai } from '@ai-sdk/openai'
import { Browserbase, BrowserbaseAISDK } from '@browserbasehq/sdk'
import { generateText } from 'ai'

async function main() {
const browserbase = new Browserbase()

const browserTool = BrowserbaseAISDK(browserbase, { textContent: true })
console.log(browserTool.parameters)

const result = await generateText({
model: openai('gpt-4o'),
tools: { browserTool },
toolChoice: 'required',
temperature: 0,
system: 'You are a helpful assistant. Be as concise as possible.',
prompt: 'What is the weather in San Francisco?'
})

console.log(result.toolResults[0])
}

await main()
24 changes: 24 additions & 0 deletions examples/ai-sdk/weather.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node
import 'dotenv/config'

import { WeatherClient } from '@agentic/stdlib'
import { createAISDKTools } from '@agentic/stdlib/ai-sdk'
import { openai } from '@ai-sdk/openai'
import { generateText } from 'ai'

async function main() {
const weather = new WeatherClient()

const result = await generateText({
model: openai('gpt-4o'),
tools: createAISDKTools(weather),
toolChoice: 'required',
temperature: 0,
system: 'You are a helpful assistant. Be as concise as possible.',
prompt: 'What is the weather in San Francisco?'
})

console.log(result.toolResults[0])
}

await main()
28 changes: 28 additions & 0 deletions examples/dexter/analyze.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env node
import 'dotenv/config'

import { DiffbotClient, SearchAndCrawl, SerpAPIClient } from '@agentic/stdlib'
import { createDexterFunctions } from '@agentic/stdlib/dexter'
import { ChatModel, createAIRunner } from '@dexaai/dexter'

async function main() {
const serpapi = new SerpAPIClient()
const diffbot = new DiffbotClient()
const searchAndCrawl = new SearchAndCrawl({ serpapi, diffbot })

const runner = createAIRunner({
chatModel: new ChatModel({
params: { model: 'gpt-4o', temperature: 0 }
// debug: true
}),
functions: createDexterFunctions(searchAndCrawl),
systemMessage:
'You are a McKinsey analyst who is an expert at writing executive summaries. Always cite your sources and respond using Markdown.'
})

const topic = 'the 2024 olympics'
const result = await runner(`Summarize the latest news on ${topic}`)
console.log(result)
}

await main()
23 changes: 23 additions & 0 deletions examples/dexter/code-interpreter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env node
import 'dotenv/config'

import { createDexterFunctions } from '@agentic/stdlib/dexter'
import { e2b } from '@agentic/stdlib/e2b'
import { ChatModel, createAIRunner } from '@dexaai/dexter'

async function main() {
const runner = createAIRunner({
chatModel: new ChatModel({
params: { model: 'gpt-4o', temperature: 0 },
debug: true
}),
functions: createDexterFunctions(e2b)
})

const result = await runner(
'Visualize a distribution of height of men based on the latest data you know. Also print the median value.'
)
console.log(result)
}

await main()
Loading

0 comments on commit 88026ed

Please sign in to comment.