update langchain and add arxiv and pubmed tools

This commit is contained in:
Eng. Elias
2024-03-24 14:53:59 +04:00
parent a654f454b8
commit f3ff09bb4e
8 changed files with 38 additions and 18 deletions

View File

@@ -0,0 +1,10 @@
-- AlterEnum
-- This migration adds more than one value to an enum.
-- With PostgreSQL versions 11 and earlier, this is not possible
-- in a single migration. This can be worked around by creating
-- multiple migrations, each migration adding only one value to
-- the enum.
ALTER TYPE "AgentTool" ADD VALUE 'ARXIV';
ALTER TYPE "AgentTool" ADD VALUE 'PUBMED';

View File

@@ -17,6 +17,8 @@ enum AgentTool {
WIKIPEDIA
YAHOO_FINANCE
YUOUTUBE_SEARCH
ARXIV
PUBMED
}
model Agent {

View File

@@ -74,9 +74,9 @@ jsonpatch==1.33
jsonpointer==2.4
kubernetes==29.0.0
lancedb==0.5.7
langchain==0.1.12
langchain-community==0.0.28
langchain-core==0.1.32
langchain==0.1.13
langchain-community==0.0.29
langchain-core==0.1.33
langchain-experimental==0.0.52
langchain-google-genai==0.0.9
langchain-openai==0.0.5

View File

@@ -3,13 +3,15 @@ import os
from textwrap import dedent
from crewai import Agent, Task, Crew, Process
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_community.tools import DuckDuckGoSearchRun
from langchain_community.tools.ddg_search import DuckDuckGoSearchRun
from langchain_community.tools.semanticscholar.tool import SemanticScholarQueryRun
from langchain_community.tools.wikidata.tool import WikidataAPIWrapper, WikidataQueryRun
from langchain_community.tools import WikipediaQueryRun
from langchain_community.utilities import WikipediaAPIWrapper
from langchain_community.tools.wikipedia.tool import WikipediaQueryRun
from langchain_community.utilities.wikipedia import WikipediaAPIWrapper
from langchain_community.tools.yahoo_finance_news import YahooFinanceNewsTool
from langchain_community.tools import YouTubeSearchTool
from langchain_community.tools.youtube.search import YouTubeSearchTool
from langchain_community.tools.arxiv.tool import ArxivQueryRun
from langchain_community.tools.pubmed.tool import PubmedQueryRun
from dotenv import load_dotenv
load_dotenv()
@@ -26,6 +28,8 @@ tool_dict = {
"WIKIPEDIA": WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper()),
"YAHOO_FINANCE": YahooFinanceNewsTool(),
"YUOUTUBE_SEARCH": YouTubeSearchTool(),
"ARXIV": ArxivQueryRun(),
"PUBMED": PubmedQueryRun(),
}

View File

@@ -6,6 +6,8 @@ const typeDefs = `#graphql
WIKIPEDIA
YAHOO_FINANCE
YUOUTUBE_SEARCH
ARXIV
PUBMED
}
type Agent {
@@ -98,7 +100,7 @@ const typeDefs = `#graphql
createMission(
name: String!
crew: [Int!] = []
verbose: Boolean = false
verbose: Boolean
process: MissionProcess = "SEQUENTIAL"
): Mission!

View File

@@ -79,6 +79,7 @@ export default function MissionModal(props: {
tasks: missionData.tasks.map((task) => ({
name: task.name,
description: task.description,
expected_output: task.expected_output,
agent: Number.parseInt(task.agent?.id as string),
})),
},
@@ -359,14 +360,12 @@ export default function MissionModal(props: {
</div>
<div>
<label className="font-bold text-lg">Result:</label>
{mission?.result && (
<div
className="border-2 rounded p-2"
style={{ whiteSpace: "pre-line" }}
>
{missionResult}
</div>
)}
<div
className="border-2 rounded p-2"
style={{ whiteSpace: "pre-line" }}
>
{missionResult}
</div>
</div>
</>
)}

View File

@@ -53,7 +53,8 @@ export const tools = [
{ text: "WIKIPEDIA", value: "WIKIPEDIA" },
{ text: "YAHOO_FINANCE", value: "YAHOO_FINANCE" },
{ text: "YUOUTUBE_SEARCH", value: "YUOUTUBE_SEARCH" },
{ text: "CodeDocsSearchTool", value: "CodeDocsSearchTool" },
{ text: "ARXIV", value: "ARXIV" },
{ text: "PUBMED", value: "PUBMED" },
];
const game = `

View File

@@ -4,7 +4,9 @@ type Tool =
| "WIKIDATA"
| "WIKIPEDIA"
| "YAHOO_FINANCE"
| "YUOUTUBE_SEARCH";
| "YUOUTUBE_SEARCH"
| "ARXIV"
| "PUBMED";
export type Agent = {
id?: number | string;