Skip to content

Commit 0ae0f8d

Browse files
authored
Add workflow/chat history (#6)
1 parent 947af97 commit 0ae0f8d

26 files changed

+2236
-1196
lines changed

pyproject.toml.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[project]
2-
name = "{{ project_name_snake }}"
2+
name = "{{ project_name }}"
33
version = "0.1.0"
44
description = "Add your description here"
55
readme = "README.md"
66
authors = []
77
requires-python = ">=3.12"
88
dependencies = [
99
"llama-index-workflows>=2.2.0,<3.0.0",
10-
"llama-cloud-services>=0.6.68",
10+
"llama-cloud-services>=0.6.69",
1111
"llama-index-core>=0.14.0",
1212
"llama-index-llms-openai>=0.5.6",
1313
"llama-index-embeddings-openai>=0.5.1",

src/{{ project_name_snake }}/clients.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import httpx
44

55
from llama_cloud.client import AsyncLlamaCloud
6-
from llama_cloud_services import LlamaParse
6+
from llama_cloud_services import LlamaCloudIndex, LlamaParse
7+
from llama_cloud_services.parse import ResultType
78

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

2021

21-
def get_custom_client() -> httpx.AsyncClient:
22+
@functools.cache
23+
def get_base_cloud_client() -> httpx.AsyncClient:
2224
return httpx.AsyncClient(
2325
timeout=60,
2426
headers={"Project-Id": LLAMA_CLOUD_PROJECT_ID}
@@ -32,7 +34,7 @@ def get_llama_cloud_client() -> AsyncLlamaCloud:
3234
return AsyncLlamaCloud(
3335
base_url=LLAMA_CLOUD_BASE_URL,
3436
token=LLAMA_CLOUD_API_KEY,
35-
httpx_client=get_custom_client(),
37+
httpx_client=get_base_cloud_client(),
3638
)
3739

3840

@@ -45,8 +47,20 @@ def get_llama_parse_client() -> LlamaParse:
4547
adaptive_long_table=True,
4648
outlined_table_extraction=True,
4749
output_tables_as_HTML=True,
48-
result_type="markdown",
50+
result_type=ResultType.MD,
4951
api_key=LLAMA_CLOUD_API_KEY,
5052
project_id=LLAMA_CLOUD_PROJECT_ID,
51-
custom_client=get_custom_client(),
53+
custom_client=get_base_cloud_client(),
54+
)
55+
56+
57+
@functools.lru_cache(maxsize=None)
58+
def get_index(index_name: str) -> LlamaCloudIndex:
59+
return LlamaCloudIndex.create_index(
60+
name=index_name,
61+
project_id=LLAMA_CLOUD_PROJECT_ID,
62+
api_key=LLAMA_CLOUD_API_KEY,
63+
base_url=LLAMA_CLOUD_BASE_URL,
64+
show_progress=True,
65+
custom_client=get_base_cloud_client(),
5266
)

0 commit comments

Comments
 (0)