mirror of
https://github.com/run-llama/notebookllama.git
synced 2026-07-01 22:14:04 -04:00
fix: resolve regional API support issues and improve code maintainability
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import os
|
||||
import sys
|
||||
from dotenv import load_dotenv
|
||||
import pandas as pd
|
||||
import json
|
||||
import os
|
||||
import warnings
|
||||
from datetime import datetime
|
||||
|
||||
@@ -11,7 +12,9 @@ from llama_cloud_services.extract import SourceText
|
||||
from typing_extensions import override
|
||||
from typing import List, Tuple, Union, Optional, Dict
|
||||
|
||||
from .utils import (
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
from notebookllama.utils import (
|
||||
create_llamacloud_client,
|
||||
create_llama_extract_client,
|
||||
create_llama_parse_client,
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
import sys
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from llama_index.core.query_engine import CitationQueryEngine
|
||||
from llama_index.core.base.response.schema import Response
|
||||
from llama_index.llms.openai import OpenAIResponses
|
||||
from typing import Union, cast
|
||||
|
||||
from .utils import create_llamacloud_index
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
from notebookllama.utils import create_llamacloud_index
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import os
|
||||
import sys
|
||||
from querying import query_index
|
||||
from processing import process_file
|
||||
from mindmap import get_mind_map
|
||||
from fastmcp import FastMCP
|
||||
from typing import List, Union, Literal
|
||||
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
|
||||
mcp: FastMCP = FastMCP(name="MCP For NotebookLM")
|
||||
|
||||
|
||||
|
||||
+16
-10
@@ -52,8 +52,12 @@ def create_llamacloud_client() -> AsyncLlamaCloud:
|
||||
Returns:
|
||||
AsyncLlamaCloud: Configured client instance
|
||||
"""
|
||||
config = get_llamacloud_config()
|
||||
return AsyncLlamaCloud(**config)
|
||||
token = os.getenv("LLAMACLOUD_API_KEY")
|
||||
base_url = get_llamacloud_base_url()
|
||||
if base_url:
|
||||
return AsyncLlamaCloud(token=token, base_url=base_url)
|
||||
else:
|
||||
return AsyncLlamaCloud(token=token)
|
||||
|
||||
|
||||
def create_llama_extract_client() -> LlamaExtract:
|
||||
@@ -63,8 +67,12 @@ def create_llama_extract_client() -> LlamaExtract:
|
||||
Returns:
|
||||
LlamaExtract: Configured client instance
|
||||
"""
|
||||
config = get_llamacloud_config()
|
||||
return LlamaExtract(**config)
|
||||
api_key = os.getenv("LLAMACLOUD_API_KEY")
|
||||
base_url = get_llamacloud_base_url()
|
||||
if base_url:
|
||||
return LlamaExtract(api_key=api_key, base_url=base_url)
|
||||
else:
|
||||
return LlamaExtract(api_key=api_key)
|
||||
|
||||
|
||||
def create_llama_parse_client(result_type: str = "markdown") -> LlamaParse:
|
||||
@@ -77,14 +85,12 @@ def create_llama_parse_client(result_type: str = "markdown") -> LlamaParse:
|
||||
Returns:
|
||||
LlamaParse: Configured client instance
|
||||
"""
|
||||
config = get_llamacloud_config()
|
||||
base_url = config.get("base_url")
|
||||
api_key = os.getenv("LLAMACLOUD_API_KEY")
|
||||
base_url = get_llamacloud_base_url()
|
||||
if base_url:
|
||||
return LlamaParse(
|
||||
api_key=config["token"], result_type=result_type, base_url=base_url
|
||||
)
|
||||
return LlamaParse(api_key=api_key, result_type=result_type, base_url=base_url)
|
||||
else:
|
||||
return LlamaParse(api_key=config["token"], result_type=result_type)
|
||||
return LlamaParse(api_key=api_key, result_type=result_type)
|
||||
|
||||
|
||||
def create_llamacloud_index(api_key: str, pipeline_id: str) -> LlamaCloudIndex:
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import os
|
||||
import sys
|
||||
import asyncio
|
||||
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
from dotenv import load_dotenv
|
||||
from tools.cli.embedding_app import EmbeddingSetupApp
|
||||
from src.notebookllama.utils import create_llamacloud_client
|
||||
@@ -46,7 +44,9 @@ def main():
|
||||
transform_config=transform_config,
|
||||
)
|
||||
|
||||
pipeline = client.pipelines.upsert_pipeline(request=pipeline_request)
|
||||
pipeline = asyncio.run(
|
||||
client.pipelines.upsert_pipeline(request=pipeline_request)
|
||||
)
|
||||
|
||||
with open(".env", "a") as f:
|
||||
f.write(f'\nLLAMACLOUD_PIPELINE_ID="{pipeline.id}"')
|
||||
|
||||
Reference in New Issue
Block a user