Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update doc20241218 #7

Merged
merged 11 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions net/serper-agent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

# @graphai/serper_agent for GraphAI

serper agent

### Install

```sh
yarn add @graphai/serper_agent
```


### Usage

```typescript
import { GraphAI } from "graphai";
import { serperAgent } from "@graphai/serper_agent";

const agents = { serperAgent };

const graph = new GraphAI(graph_data, agents);
const result = await graph.run();
```

### Agents description
- serperAgent - serper agent

### Input/Output/Params Schema & samples
- [serperAgent](https://github.com/receptron/graphai/blob/main/docs/agentDocs/net/serperAgent.md)

### Input/Params example
- serperAgent

```typescript
{
"inputs": {
"query": "apple inc"
},
"params": {}
}
```


### Environment Variables
- serperAgent
- SERPER_API_KEY







9 changes: 9 additions & 0 deletions net/serper-agent/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import eslintBase from "../../config/eslint.config.base.mjs";

export default [
{
files: ["{src,test}/**/*.{js,ts,yaml,yml,json}"],
},
{},
...eslintBase,
];
26 changes: 26 additions & 0 deletions net/serper-agent/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@graphai/serper_agent",
"version": "0.0.1",
"description": "serper agent",
"main": "lib/index.js",
"files": [
"./lib"
],
"scripts": {
"build": "tsc",
"eslint": "eslint src --fix",
"format": "prettier --write '{src,tests}/**/*.ts'",
"doc": "npx agentdoc",
"test_run": "node --test --require ts-node/register ./tests/run_*.ts",
"test": "node --test --require ts-node/register ./tests/test_*.ts",
"ci": "yarn run format && yarn run eslint && yarn run test && yarn run build"
},
"author": "isamu arimoto",
"license": "MIT",
"devDependencies": {},
"dependencies": {},
"types": "./lib/index.d.ts",
"directories": {
"lib": "lib"
}
}
3 changes: 3 additions & 0 deletions net/serper-agent/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import serperAgent from "./serper_agent";

export { serperAgent };
246 changes: 246 additions & 0 deletions net/serper-agent/src/serper_agent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
import { AgentFunction, AgentFunctionInfo } from "graphai";
import axios from "axios";

export const serperAgent: AgentFunction = async ({ namedInputs }) => {
const apiKey = process.env.SERPER_API_KEY ?? "";
const { query } = namedInputs;
const data = JSON.stringify({
q: query,
});

const config = {
method: "post",
maxBodyLength: Infinity,
url: "https://google.serper.dev/search",
headers: {
"X-API-KEY": apiKey,
"Content-Type": "application/json",
},
data: data,
};

try {
const response = await axios.request(config);
return response.data;
} catch (error) {
console.error(error);
if (error instanceof Error) {
return { error: error.message };
}
return { error: String(error) };
}
};

const serperAgentInfo: AgentFunctionInfo = {
name: "serperAgent",
agent: serperAgent,
mock: serperAgent,

samples: [
{
params: {},
inputs: { query: "apple inc" },
result: {
searchParameters: {
q: "apple inc",
type: "search",
engine: "google",
},
knowledgeGraph: {
title: "Apple",
type: "Technology company",
website: "http://www.apple.com/",
imageUrl: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQwGQRv5TjjkycpctY66mOg_e2-npacrmjAb6_jAWhzlzkFE3OTjxyzbA&s=0",
description:
"Apple Inc. is an American multinational corporation and technology company headquartered and incorporated in Cupertino, California, in Silicon Valley. It is best known for its consumer electronics, software, and services.",
descriptionSource: "Wikipedia",
descriptionLink: "https://en.wikipedia.org/wiki/Apple_Inc.",
attributes: {
"Customer service": "1 (800) 275-2273",
Founders: "Steve Jobs, Steve Wozniak, and Ronald Wayne",
Headquarters: "Cupertino, CA",
CEO: "Tim Cook (Aug 24, 2011–)",
CFO: "Luca Maestri",
Founded: "April 1, 1976, Los Altos, CA",
},
},
organic: [
{
title: "Apple",
link: "https://www.apple.com/",
snippet:
"Discover the innovative world of Apple and shop everything iPhone, iPad, Apple Watch, Mac, and Apple TV, plus explore accessories, entertainment, ...",
sitelinks: [
{
title: "Support",
link: "https://support.apple.com/",
},
{
title: "Careers at Apple",
link: "https://www.apple.com/careers/us/",
},
{
title: "Contact Apple",
link: "https://www.apple.com/contact/",
},
{
title: "Store",
link: "https://www.apple.com/store",
},
{
title: "Investor Relations",
link: "https://investor.apple.com/investor-relations/default.aspx",
},
],
position: 1,
},
{
title: "Apple Inc. - Wikipedia",
link: "https://en.wikipedia.org/wiki/Apple_Inc.",
snippet:
"Apple Inc. is an American multinational corporation and technology company headquartered and incorporated in Cupertino, California, in Silicon Valley.",
sitelinks: [
{
title: "History",
link: "https://en.wikipedia.org/wiki/History_of_Apple_Inc.",
},
{
title: "List of Apple products",
link: "https://en.wikipedia.org/wiki/List_of_Apple_products",
},
{
title: "Litigation involving Apple Inc.",
link: "https://en.wikipedia.org/wiki/Litigation_involving_Apple_Inc.",
},
{
title: "Apple Park",
link: "https://en.wikipedia.org/wiki/Apple_Park",
},
],
position: 2,
},
{
title: "Apple Inc. | History, Products, Headquarters, & Facts - Britannica",
link: "https://www.britannica.com/money/Apple-Inc",
snippet:
"Apple Inc. is an American multinational technology company that revolutionized the technology sector through its innovation of computer software, ...",
position: 3,
},
{
title: "Apple Inc. (AAPL) Company Profile & Facts - Yahoo Finance",
link: "https://finance.yahoo.com/quote/AAPL/profile/",
snippet:
"(408) 996-1010 https://www.apple.com. Sector: Technology. Industry: Consumer Electronics. Full Time Employees: 164,000. Description. Apple Inc. designs ...",
position: 4,
},
{
title: "AAPL: Apple Inc Stock Price Quote - NASDAQ GS - Bloomberg",
link: "https://www.bloomberg.com/quote/AAPL:US",
snippet:
"Stock analysis for Apple Inc (AAPL:NASDAQ GS) including stock price, stock chart, company news, key statistics, fundamentals and company profile.",
position: 5,
},
{
title: "Apple Inc. (AAPL) Stock Price Today - WSJ",
link: "https://www.wsj.com/market-data/quotes/AAPL",
snippet:
"Apple Inc. engages in the design, manufacture, and sale of smartphones, personal computers, tablets, wearables and accessories, and other varieties of related ...",
position: 6,
},
{
title: "Apple Inc. (AAPL) Stock Price, News, Quote & History - Yahoo Finance",
link: "https://finance.yahoo.com/quote/AAPL/",
snippet:
"Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables, and accessories worldwide. The company offers iPhone, ...",
sitelinks: [
{
title: "Profile",
link: "https://finance.yahoo.com/quote/AAPL/profile/",
},
{
title: "Statistics",
link: "https://finance.yahoo.com/quote/AAPL/key-statistics/",
},
{
title: "Chart",
link: "https://finance.yahoo.com/quote/AAPL/chart/",
},
{
title: "News",
link: "https://finance.yahoo.com/quote/AAPL/news/",
},
],
position: 7,
},
],
peopleAlsoAsk: [
{
question: "What is the Apple Inc?",
snippet: '"Inc." in Apple Inc. stands for "Incorporated".',
title: "What does the 'Inc.' in Apple Inc. mean? - Quora",
link: "https://www.quora.com/What-does-the-Inc-in-Apple-Inc-mean",
},
{
question: "Who owns Apple Inc?",
snippet:
"Apple (AAPL) Ownership Overview The ownership structure of Apple (AAPL) stock is a mix of institutional, retail, and individual investors. Approximately 49.07% of the company's stock is owned by Institutional Investors, 0.06% is owned by Insiders, and 50.87% is owned by Public Companies and Individual Investors.",
title: "Who owns Apple? AAPL Stock Ownership - TipRanks.com",
link: "https://www.tipranks.com/stocks/aapl/ownership",
},
{
question: "Why did Apple change to Apple Inc?",
snippet:
"During his keynote speech at the Macworld Expo on January 9, 2007, Jobs announced the renaming of Apple Computer, Inc. to Apple Inc., because the company had broadened its focus from computers to consumer electronics. This event also saw the announcement of the iPhone and the Apple TV.",
title: "Apple Inc. - Wikipedia",
link: "https://en.wikipedia.org/wiki/Apple_Inc.",
},
{
question: "What is Apple Inc known for?",
snippet:
"Apple Inc. is an American multinational technology company that revolutionized the technology sector through its innovation of computer software, personal computers, mobile tablets, smartphones, and computer peripherals.",
title: "Apple Inc. | History, Products, Headquarters, & Facts - Britannica",
link: "https://www.britannica.com/money/Apple-Inc",
},
],
relatedSearches: [
{
query: "Find My iPhone",
},
{
query: "apple inc คืออะไร",
},
{
query: "Apple Inc full form",
},
{
query: "Apple company history",
},
{
query: "Apple company owner",
},
{
query: "Apple Inc website",
},
{
query: "Apple Inc usa",
},
{
query: "Apple Inc address",
},
{
query: "Apple Inc industry",
},
],
credits: 1,
},
},
],
description: "serper agent",
category: ["net"],
author: "isamu arimoto",
repository: "https://github.com/isamu/graphai-agents",
license: "MIT",
environmentVariables: ["SERPER_API_KEY"],
};

export default serperAgentInfo;
10 changes: 10 additions & 0 deletions net/serper-agent/tests/test_agent_runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as packages from "../src/index";
import { agentTestRunner } from "@receptron/test_utils/lib/agent_test_runner";

const main = async () => {
for await (const agentInfo of Object.values(packages)) {
await agentTestRunner(agentInfo);
}
};

main();
13 changes: 13 additions & 0 deletions net/serper-agent/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../config/tsconfig.base.json",
"compilerOptions": {
"baseUrl": "./",
"rootDir": "./src/",
"outDir": "./lib",
"paths": {
"@/*": ["./src/*"],
"~/*": ["./tests/*"],
}
},
"include": ["src"]
}
2 changes: 1 addition & 1 deletion net/slack_agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"dependencies": {
"@slack/web-api": "^7.3.4",
"dotenv": "^16.4.7",
"graphai": "^0.6.6"
"graphai": "^0.6.7"
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"private": true,
"repository": {
"type": "git",
"url": "git+https://github.com/isamu/ts-mono.git"
"url": "git@github.com:receptron/graphai-agents.git"
},
"author": "",
"license": "MIT",
Expand All @@ -35,12 +35,12 @@
"@receptron/test_utils": "^0.2.2",
"@types/node": "^22.10.2",
"eslint": "^9.17.0",
"graphai": "^0.6.6",
"graphai": "^0.6.7",
"graphai_agent_utils": "^0.0.1",
"prettier": "^3.4.2",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.0"
"typescript-eslint": "^8.18.1"
}
}
Loading
Loading