Skip to content
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
4 changes: 2 additions & 2 deletions pyproject.toml.jinja
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[project]
name = "{{ project_name_snake }}"
name = "{{ project_name }}"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
authors = []
requires-python = ">=3.12"
dependencies = [
"llama-index-workflows>=2.2.0,<3.0.0",
"llama-cloud-services>=0.6.68",
"llama-cloud-services>=0.6.69",
"llama-index-core>=0.14.0",
"llama-index-llms-openai>=0.5.6",
"llama-index-embeddings-openai>=0.5.1",
Expand Down
24 changes: 19 additions & 5 deletions src/{{ project_name_snake }}/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import httpx

from llama_cloud.client import AsyncLlamaCloud
from llama_cloud_services import LlamaParse
from llama_cloud_services import LlamaCloudIndex, LlamaParse
from llama_cloud_services.parse import ResultType

# deployed agents may infer their name from the deployment name
# Note: Make sure that an agent deployment with this name actually exists
Expand All @@ -18,7 +19,8 @@
INDEX_NAME = "document_qa_index"


def get_custom_client() -> httpx.AsyncClient:
@functools.cache
def get_base_cloud_client() -> httpx.AsyncClient:
return httpx.AsyncClient(
timeout=60,
headers={"Project-Id": LLAMA_CLOUD_PROJECT_ID}
Expand All @@ -32,7 +34,7 @@ def get_llama_cloud_client() -> AsyncLlamaCloud:
return AsyncLlamaCloud(
base_url=LLAMA_CLOUD_BASE_URL,
token=LLAMA_CLOUD_API_KEY,
httpx_client=get_custom_client(),
httpx_client=get_base_cloud_client(),
)


Expand All @@ -45,8 +47,20 @@ def get_llama_parse_client() -> LlamaParse:
adaptive_long_table=True,
outlined_table_extraction=True,
output_tables_as_HTML=True,
result_type="markdown",
result_type=ResultType.MD,
api_key=LLAMA_CLOUD_API_KEY,
project_id=LLAMA_CLOUD_PROJECT_ID,
custom_client=get_custom_client(),
custom_client=get_base_cloud_client(),
)


@functools.lru_cache(maxsize=None)
def get_index(index_name: str) -> LlamaCloudIndex:
return LlamaCloudIndex.create_index(
name=index_name,
project_id=LLAMA_CLOUD_PROJECT_ID,
api_key=LLAMA_CLOUD_API_KEY,
base_url=LLAMA_CLOUD_BASE_URL,
show_progress=True,
custom_client=get_base_cloud_client(),
)
Loading