Skip to content

feat: able to display file url from llamacloud #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 50 commits into from
Jul 18, 2024

Conversation

thucpn
Copy link
Collaborator

@thucpn thucpn commented Jul 5, 2024

Summary by CodeRabbit

  • New Features

    • Added support for displaying files sourced from LlamaCloud indexes.
    • Introduced directory creation for "llamacloud" within the "output" directory.
  • Enhancements

    • Improved document processing and metadata handling for files.
    • Enhanced chat message content handling and document ID management.
    • Added functionality for loading and saving documents based on MIME types.
  • Bug Fixes

    • Improved error handling during asynchronous operations.

Copy link

changeset-bot bot commented Jul 5, 2024

🦋 Changeset detected

Latest commit: 25b74a1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-llama Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

coderabbitai bot commented Jul 5, 2024

Walkthrough

This update integrates LlamaCloudIndex for document insertion and processing, refines FastAPI services and routing, enhances document handling in Python and TypeScript, and introduces asynchronous processing in event handling. Significant changes include renaming classes, modifying method signatures, altering import orders, and adding new helper functions for documents and pipelines.

Changes

Files/Groups Change Summary
templates/types/streaming/fastapi/app/api/services/file.py Integrated LlamaCloudIndex, updated store_and_parse_file and process_file methods, renamed class FileController to PrivateFileService, removed file_metadata_func.
templates/types/streaming/fastapi/app/api/routers/models.py Introduced LlamaCloudFile class, added imports for ChatMessage, MessageRole, and NodeWithScore, added get_download_files method in SourceNodes class.
templates/types/streaming/fastapi/main.py Reordered imports, swapped init_settings() and init_observability() calls, adjusted routing setup for chat_router and file_upload_router.
templates/components/vectordbs/python/none/generate.py Reordered imports, added get_documents and init_settings imports, updated generate_datasource function to set is_local_file metadata.
templates/components/vectordbs/typescript/llamacloud/generate.ts Added import for getDataSource, updated loadAndIndex function to call getDataSource before indexing documents.
templates/components/llamaindex/typescript/documents/helper.ts Added functions loadDocuments and saveDocument for handling documents based on MIME types.
templates/components/llamaindex/typescript/documents/pipeline.ts Introduced runPipeline function for document ingestion, added addNodesToVectorStore helper function.
templates/components/llamaindex/typescript/streaming/events.ts Added asynchronous behavior to appendSourceData, introduced error handling, updated getNodeUrl and appendSourceData to be async.
templates/components/vectordbs/python/llamacloud/generate.py Added loop to set is_local_file metadata for each document before passing to LlamaCloudIndex.from_documents().
.changeset/happy-hairs-kick.md Included a patch named "create-llama" to enable displaying files from LlamaCloud indexes.
helpers/index.ts Added functionality to create a "llamacloud" directory within the "output" directory.

Poem

In a world of code so bright,
LlamaCloud takes flight,
Documents stream and flow,
Metadata in tow,
Asynchronous whispers hum,
Chat and files become one,
In FastAPI’s warm glow.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@thucpn thucpn marked this pull request as ready for review July 8, 2024 06:38
@thucpn thucpn requested a review from marcusschiesser July 8, 2024 06:39
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 11

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 07fcefd and 9aead8a.

Files selected for processing (9)
  • .changeset/happy-hairs-kick.md (1 hunks)
  • templates/types/streaming/express/src/controllers/service.ts (1 hunks)
  • templates/types/streaming/express/src/controllers/stream-helper.ts (3 hunks)
  • templates/types/streaming/fastapi/app/api/routers/models.py (2 hunks)
  • templates/types/streaming/fastapi/app/service.py (1 hunks)
  • templates/types/streaming/nextjs/app/api/chat/service.ts (1 hunks)
  • templates/types/streaming/nextjs/app/api/chat/stream-helper.ts (3 hunks)
  • templates/types/streaming/nextjs/app/components/ui/chat/chat-message/chat-sources.tsx (5 hunks)
  • templates/types/streaming/nextjs/app/components/ui/chat/widgets/PdfDialog.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • .changeset/happy-hairs-kick.md
Additional context used
Biome
templates/types/streaming/express/src/controllers/service.ts

[error] 7-48: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)


[error] 37-37: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 42-42: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

templates/types/streaming/nextjs/app/api/chat/service.ts

[error] 7-48: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)


[error] 37-37: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 42-42: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

Ruff
templates/types/streaming/fastapi/app/api/routers/models.py

3-3: requests imported but unused

Remove unused import: requests

(F401)

Additional comments not posted (9)
templates/types/streaming/fastapi/app/service.py (2)

8-16: Verify API key presence and add error handling.

Ensure that the LLAMA_CLOUD_API_KEY environment variable is set. Add error handling for the request to manage potential failures.

+        if not os.getenv("LLAMA_CLOUD_API_KEY"):
+            raise EnvironmentError("LLAMA_CLOUD_API_KEY not set")

         response = requests.request("GET", url, headers=headers, data=payload)
+        if response.status_code != 200:
+            raise requests.HTTPError(f"Failed to fetch files: {response.status_code}")

19-27: Verify API key presence and add error handling.

Ensure that the LLAMA_CLOUD_API_KEY environment variable is set. Add error handling for the request to manage potential failures.

+        if not os.getenv("LLAMA_CLOUD_API_KEY"):
+            raise EnvironmentError("LLAMA_CLOUD_API_KEY not set")

         response = requests.request("GET", url, headers=headers, data=payload)
+        if response.status_code != 200:
+            raise requests.HTTPError(f"Failed to fetch file detail: {response.status_code}")
templates/types/streaming/nextjs/app/components/ui/chat/widgets/PdfDialog.tsx (1)

27-32: LGTM!

The JSX changes to display the file URL with improved styling and structure look good to me.

templates/types/streaming/express/src/controllers/service.ts (2)

8-16: Verify API key presence, add error handling, and consider refactoring.

Ensure that the LLAMA_CLOUD_API_KEY environment variable is set. Add error handling for the request to manage potential failures. Consider refactoring to a simple function as the class contains only static members.

+    if (!process.env.LLAMA_CLOUD_API_KEY) {
+      throw new Error("LLAMA_CLOUD_API_KEY not set");
+    }

    const response = await fetch(url, { method: "GET", headers });
+    if (!response.ok) {
+      throw new Error(`Failed to fetch files: ${response.status}`);
+    }

    const data = await response.json();
    return data;

19-31: Verify API key presence, add error handling, and consider refactoring.

Ensure that the LLAMA_CLOUD_API_KEY environment variable is set. Add error handling for the request to manage potential failures. Consider refactoring to a simple function as the class contains only static members.

+    if (!process.env.LLAMA_CLOUD_API_KEY) {
+      throw new Error("LLAMA_CLOUD_API_KEY not set");
+    }

    const response = await fetch(url, { method: "GET", headers });
+    if (!response.ok) {
+      throw new Error(`Failed to fetch file detail: ${response.status}`);
+    }

    const data = (await response.json()) as { url: string };
    return data;
templates/types/streaming/nextjs/app/api/chat/service.ts (2)

8-16: Verify API key presence, add error handling, and consider refactoring.

Ensure that the LLAMA_CLOUD_API_KEY environment variable is set. Add error handling for the request to manage potential failures. Consider refactoring to a simple function as the class contains only static members.

+    if (!process.env.LLAMA_CLOUD_API_KEY) {
+      throw new Error("LLAMA_CLOUD_API_KEY not set");
+    }

    const response = await fetch(url, { method: "GET", headers });
+    if (!response.ok) {
+      throw new Error(`Failed to fetch files: ${response.status}`);
+    }

    const data = await response.json();
    return data;

19-31: Verify API key presence, add error handling, and consider refactoring.

Ensure that the LLAMA_CLOUD_API_KEY environment variable is set. Add error handling for the request to manage potential failures. Consider refactoring to a simple function as the class contains only static members.

+    if (!process.env.LLAMA_CLOUD_API_KEY) {
+      throw new Error("LLAMA_CLOUD_API_KEY not set");
+    }

    const response = await fetch(url, { method: "GET", headers });
+    if (!response.ok) {
+      throw new Error(`Failed to fetch file detail: ${response.status}`);
+    }

    const data = (await response.json()) as { url: string };
    return data;
templates/types/streaming/nextjs/app/components/ui/chat/chat-message/chat-sources.tsx (2)

Line range hint 26-64: LGTM!

The changes in the ChatSources component enhance its functionality by adding new logic to handle and display file URLs. The filtering and sorting logic is implemented correctly.


72-117: LGTM!

The new SourceNodeItem component correctly handles the display of file URLs and conditionally displays a PdfDialog component based on the validity of PDF URLs. The logic to check the validity of PDF URLs is implemented correctly.

…b.com:run-llama/create-llama into feat/able-to-display-file-url-from-llamacloud
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9aead8a and 72beab6.

Files selected for processing (4)
  • templates/types/streaming/express/src/controllers/stream-helper.ts (3 hunks)
  • templates/types/streaming/fastapi/app/api/routers/models.py (2 hunks)
  • templates/types/streaming/nextjs/app/api/chat/stream-helper.ts (3 hunks)
  • templates/types/streaming/nextjs/app/components/ui/chat/chat-message/chat-sources.tsx (5 hunks)
Files skipped from review due to trivial changes (1)
  • templates/types/streaming/nextjs/app/components/ui/chat/chat-message/chat-sources.tsx
Files skipped from review as they are similar to previous changes (3)
  • templates/types/streaming/express/src/controllers/stream-helper.ts
  • templates/types/streaming/fastapi/app/api/routers/models.py
  • templates/types/streaming/nextjs/app/api/chat/stream-helper.ts

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 72beab6 and e728391.

Files selected for processing (4)
  • templates/types/streaming/express/src/controllers/service.ts (1 hunks)
  • templates/types/streaming/express/src/controllers/stream-helper.ts (3 hunks)
  • templates/types/streaming/nextjs/app/api/chat/service.ts (1 hunks)
  • templates/types/streaming/nextjs/app/api/chat/stream-helper.ts (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • templates/types/streaming/express/src/controllers/stream-helper.ts
  • templates/types/streaming/nextjs/app/api/chat/stream-helper.ts
Additional context used
Biome
templates/types/streaming/express/src/controllers/service.ts

[error] 11-102: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)


[error] 42-42: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 47-47: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 48-48: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

templates/types/streaming/nextjs/app/api/chat/service.ts

[error] 11-102: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)


[error] 42-42: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 47-47: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 48-48: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

@thucpn
Copy link
Collaborator Author

thucpn commented Jul 10, 2024

@marcusschiesser @leehuwuj I have updated code to save LlamaCloud file in local and return the local url.
Please help me have a look at the PR again

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e728391 and 49987ca.

Files selected for processing (1)
  • templates/types/streaming/fastapi/app/service.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • templates/types/streaming/fastapi/app/service.py

@marcusschiesser
Copy link
Collaborator

TS code looks good - @leehuwuj please check the python code and then you can merge it

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4eb9339 and 4a069f1.

Files selected for processing (3)
  • templates/components/vectordbs/python/none/generate.py (2 hunks)
  • templates/types/streaming/fastapi/app/api/routers/chat.py (3 hunks)
  • templates/types/streaming/fastapi/app/engine/generate.py (2 hunks)
Additional context used
Ruff
templates/types/streaming/fastapi/app/api/routers/chat.py

47-47: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)

Additional comments not posted (5)
templates/components/vectordbs/python/none/generate.py (2)

6-9: Review of import statements and order

The reordering of imports and the addition of new import statements (get_documents and init_settings) are consistent with Python best practices, which recommend grouping similar types of imports together. However, the removal of the logging import should be verified to ensure logging is not used elsewhere in the code without proper import.


27-27: Addition of is_local_file metadata

The addition of the is_local_file metadata field aligns with the PR's objective to manage files from LlamaCloud locally. This change is straightforward and correctly implemented within the loop for setting document metadata.

templates/types/streaming/fastapi/app/engine/generate.py (2)

6-15: Review of import statements and order

The reordering of import statements to place custom package imports (from app.engine.loaders and others) above standard library imports (os) is a common practice to improve readability. The addition of get_vector_store suggests an expansion in functionality which should be cross-verified with usage in the rest of the module.


70-70: Addition of is_local_file metadata

Similar to the previous file, the addition of the is_local_file metadata field is implemented correctly. It's important to ensure that this new metadata field is consistently used across all relevant parts of the application to avoid inconsistencies.

templates/types/streaming/fastapi/app/api/routers/chat.py (1)

2-20: Review of new imports and their usage

The addition of List from typing and BackgroundTasks from FastAPI are appropriate for the functionalities described. The import of NodeWithScore should be verified against its usage in the file to ensure it's not an unused import as previously flagged.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4a069f1 and fd57765.

Files selected for processing (1)
  • templates/components/llamaindex/typescript/documents/pipeline.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • templates/components/llamaindex/typescript/documents/pipeline.ts

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fd57765 and c933ef4.

Files selected for processing (1)
  • templates/types/streaming/express/package.json (1 hunks)
Files skipped from review due to trivial changes (1)
  • templates/types/streaming/express/package.json

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c933ef4 and 2bb7b67.

Files selected for processing (2)
  • templates/types/streaming/fastapi/app/api/routers/models.py (6 hunks)
  • templates/types/streaming/fastapi/app/api/services/file.py (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • templates/types/streaming/fastapi/app/api/routers/models.py
  • templates/types/streaming/fastapi/app/api/services/file.py

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2bb7b67 and 586189f.

Files selected for processing (1)
  • templates/types/streaming/fastapi/main.py (2 hunks)
Additional comments not posted (3)
templates/types/streaming/fastapi/main.py (3)

7-15: Import reordering looks good.

Reordering the imports for FastAPI, CORSMiddleware, and RedirectResponse below the router imports is acceptable and maintains consistency.


12-13: Verify the reasoning behind swapping function calls.

Swapping init_settings() and init_observability() might be to ensure settings are initialized before observability is set up. Verify if this change is necessary and correct.


50-50: Rearrangement of static file mounting looks good.

The rearrangement of static file mounting is acceptable and maintains consistency.

@leehuwuj leehuwuj force-pushed the feat/able-to-display-file-url-from-llamacloud branch from 586189f to 2bb7b67 Compare July 18, 2024 03:12
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 586189f and 0272ca5.

Files selected for processing (1)
  • templates/types/streaming/fastapi/app/api/services/file.py (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • templates/types/streaming/fastapi/app/api/services/file.py

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0272ca5 and ffc221f.

Files selected for processing (3)
  • templates/components/vectordbs/python/none/generate.py (2 hunks)
  • templates/types/streaming/fastapi/app/api/services/llama_cloud.py (1 hunks)
  • templates/types/streaming/fastapi/app/engine/generate.py (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • templates/components/vectordbs/python/none/generate.py
  • templates/types/streaming/fastapi/app/api/services/llama_cloud.py
  • templates/types/streaming/fastapi/app/engine/generate.py

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ffc221f and 8a5f098.

Files selected for processing (1)
  • templates/components/vectordbs/typescript/llamacloud/generate.ts (2 hunks)
Additional comments not posted (1)
templates/components/vectordbs/typescript/llamacloud/generate.ts (1)

3-3: Import statement is correct.

The new import statement for getDataSource is syntactically correct and aligns with the AI-generated summary.

Copy link
Collaborator

@marcusschiesser marcusschiesser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
.changeset/happy-hairs-kick.md (1)

5-5: Clarify the changeset description.

The description should be more specific about the changes made. Consider mentioning that the changes involve displaying files in sources using LlamaCloud indexes and saving files locally with their URLs.

- Display files in sources using LlamaCloud indexes.
+ Display files in sources using LlamaCloud indexes and save files locally with their URLs.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8a5f098 and 782f39b.

Files selected for processing (11)
  • .changeset/happy-hairs-kick.md (1 hunks)
  • templates/components/llamaindex/typescript/documents/helper.ts (1 hunks)
  • templates/components/llamaindex/typescript/documents/pipeline.ts (1 hunks)
  • templates/components/llamaindex/typescript/streaming/events.ts (3 hunks)
  • templates/components/vectordbs/python/llamacloud/generate.py (1 hunks)
  • templates/components/vectordbs/python/none/generate.py (2 hunks)
  • templates/components/vectordbs/typescript/llamacloud/generate.ts (2 hunks)
  • templates/types/streaming/fastapi/app/api/routers/models.py (6 hunks)
  • templates/types/streaming/fastapi/app/api/services/file.py (3 hunks)
  • templates/types/streaming/fastapi/app/engine/generate.py (2 hunks)
  • templates/types/streaming/fastapi/main.py (2 hunks)
Files skipped from review as they are similar to previous changes (8)
  • templates/components/llamaindex/typescript/documents/helper.ts
  • templates/components/llamaindex/typescript/documents/pipeline.ts
  • templates/components/vectordbs/python/none/generate.py
  • templates/components/vectordbs/typescript/llamacloud/generate.ts
  • templates/types/streaming/fastapi/app/api/routers/models.py
  • templates/types/streaming/fastapi/app/api/services/file.py
  • templates/types/streaming/fastapi/app/engine/generate.py
  • templates/types/streaming/fastapi/main.py
Additional comments not posted (4)
templates/components/vectordbs/python/llamacloud/generate.py (1)

33-35: Ensure metadata field is properly set.

The loop correctly sets the is_local_file metadata field for each document. Ensure that all documents have a metadata attribute and that it is a dictionary.

templates/components/llamaindex/typescript/streaming/events.ts (3)

11-33: Ensure proper error handling in appendSourceData.

The function correctly handles errors with a try-catch block. Ensure that all possible errors are logged and handled appropriately.


Line range hint 79-87:
Ensure proper error handling in callbackManager.on("retrieve-end").

The function correctly handles errors with a try-catch block in appendSourceData. Ensure that any errors in appendEventData are also logged and handled appropriately.


108-130: Ensure proper error handling in getNodeUrl.

The function correctly handles errors with a try-catch block. Ensure that all possible errors are logged and handled appropriately.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 782f39b and 25b74a1.

Files selected for processing (1)
  • helpers/index.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • helpers/index.ts

const pipelineId = metadata["pipeline_id"];
if (pipelineId && !isLocalFile) {
// file is from LlamaCloud and was not ingested locally
// TODO trigger but don't await file download and just use convention to generate the URL (see Python code)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thucpn see TODO

@marcusschiesser marcusschiesser merged commit 455ab68 into main Jul 18, 2024
7 checks passed
@marcusschiesser marcusschiesser deleted the feat/able-to-display-file-url-from-llamacloud branch July 18, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants