-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #643 from transitive-bullshit/agentic
- Loading branch information
Showing
93 changed files
with
39,820 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
# ------------------------------------------------------------------------------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: [transitive-bullshit] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npm run precommit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
enable-pre-post-scripts=true | ||
package-manager-strict=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.