mirror of
https://github.com/run-llama/llamacloud-mcp.git
synced 2026-07-01 21:24:03 -04:00
update deps
This commit is contained in:
+29
-6
@@ -2,8 +2,8 @@ import click
|
||||
import os
|
||||
|
||||
from mcp.server.fastmcp import Context, FastMCP
|
||||
from llama_cloud_services import LlamaExtract
|
||||
from llama_index.indices.managed.llama_cloud import LlamaCloudIndex
|
||||
from llama_cloud import AsyncLlamaCloud
|
||||
from llama_cloud.lib.index import LlamaCloudIndex
|
||||
from typing import Awaitable, Callable, Optional
|
||||
|
||||
|
||||
@@ -39,13 +39,36 @@ def make_extract_tool(
|
||||
await ctx.info(
|
||||
f"Extracting data using agent: {agent_name} with file path: {file_path}"
|
||||
)
|
||||
llama_extract = LlamaExtract(
|
||||
client = AsyncLlamaCloud()
|
||||
|
||||
# Find the extraction agent by name
|
||||
agents = await client.extraction.extraction_agents.list(
|
||||
organization_id=org_id,
|
||||
project_id=project_id,
|
||||
)
|
||||
extract_agent = llama_extract.get_agent(name=agent_name)
|
||||
result = await extract_agent.aextract(file_path)
|
||||
return str(result)
|
||||
|
||||
agent_id = None
|
||||
for agent in agents:
|
||||
if agent.name == agent_name:
|
||||
agent_id = agent.id
|
||||
break
|
||||
|
||||
if agent_id is None:
|
||||
raise ValueError(f"Extraction agent '{agent_name}' not found")
|
||||
|
||||
# Upload file
|
||||
file_obj = await client.files.create(
|
||||
file=file_path,
|
||||
purpose="extract",
|
||||
)
|
||||
|
||||
# Extract and wait for result
|
||||
result = await client.extraction.jobs.extract(
|
||||
extraction_agent_id=agent_id,
|
||||
file_id=file_obj.id,
|
||||
)
|
||||
|
||||
return str(result.data)
|
||||
except Exception as e:
|
||||
await ctx.error(f"Error extracting data: {str(e)}")
|
||||
return f"Error extracting data: {str(e)}"
|
||||
|
||||
+3
-5
@@ -14,11 +14,10 @@ description = "Expose LlamaCloud services as MCP tools"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = [
|
||||
"llama-index-indices-managed-llama-cloud>=0.6.9",
|
||||
"llama-cloud>=1.0",
|
||||
"llama-index-core>=0.12.0",
|
||||
"mcp[cli]>=1.6.0",
|
||||
"python-dotenv>=1.1.0",
|
||||
"llama-index-tools-mcp>=0.1.0",
|
||||
"llama-cloud-services",
|
||||
"click"
|
||||
]
|
||||
license = "MIT"
|
||||
@@ -31,8 +30,7 @@ keywords = [
|
||||
"mcp",
|
||||
"llama",
|
||||
"llamacloud",
|
||||
"llama-cloud",
|
||||
"llama-cloud-services"
|
||||
"llama-cloud"
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
|
||||
Reference in New Issue
Block a user