Skip to content

Conversation

jamesbraza
Copy link
Collaborator

@maykcaldas made a good comment here: #925 (comment)

This PR:

  • Creates a run_or_ensure function to allow both interpreter and Jupyter usage
  • Adds PDF download to README, so others can use
  • Fixes some README snippets

@jamesbraza jamesbraza self-assigned this May 21, 2025
@Copilot Copilot AI review requested due to automatic review settings May 21, 2025 18:50
@jamesbraza jamesbraza added the enhancement New feature or request label May 21, 2025
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. documentation Improvements or additions to documentation labels May 21, 2025
@@ -190,13 +192,13 @@ search over that index, then break the files into chunked evidence contexts, ran
All prior answers will be indexed and stored, you can view them by querying via the `search` subcommand, or access them yourself in your `PQA_HOME` directory, which defaults to `~/.pqa/`.

```bash
$ pqa search -i 'answers' 'antibodies'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This didn't run earlier regardless

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves usability by adding a run_or_ensure function to support both synchronous interpreter and asynchronous Jupyter notebook environments. It also updates the CLI usage in the README and adjusts agent functions to leverage the new utility.

  • Introduces run_or_ensure for coroutine handling.
  • Modifies several agent functions in init.py to use run_or_ensure instead of directly calling get_loop().
  • Updates README snippets to reflect the changes and enhance usability.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
paperqa/utils.py Adds the run_or_ensure function and updates imports.
paperqa/agents/init.py Updates function implementations to use run_or_ensure for async handling.
README.md Revises CLI examples to match the updated functionality.
Comments suppressed due to low confidence (1)

paperqa/utils.py:218

  • Ensure that the generic type 'T' is imported or defined (e.g., from typing import TypeVar; T = TypeVar('T')) to support generics in the run_or_ensure function.
def run_or_ensure(coro: Awaitable[T]) -> T | asyncio.Task[T]:

@jamesbraza jamesbraza requested a review from nadolskit May 21, 2025 19:03
@jamesbraza jamesbraza force-pushed the better-docs-jupyter branch from faee3ab to aaeb64d Compare May 21, 2025 19:06
@jamesbraza jamesbraza force-pushed the better-docs-jupyter branch from aaeb64d to faf8df3 Compare May 21, 2025 19:08
Copy link
Collaborator

@maykcaldas maykcaldas left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -190,13 +192,13 @@ search over that index, then break the files into chunked evidence contexts, ran
All prior answers will be indexed and stored, you can view them by querying via the `search` subcommand, or access them yourself in your `PQA_HOME` directory, which defaults to `~/.pqa/`.

```bash
$ pqa search -i 'answers' 'antibodies'
pqa -i 'answers' search 'ranking and contextual summarization'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we know how many people uses the cli? Based on the issues, there are a few people who use it mainly for ollama queries.

I'm curious if we should focus on addressing those ~10 people comments

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah let's address them, just in another PR if it's cool 😈

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 21, 2025
@jamesbraza jamesbraza merged commit 3cbc4dd into main May 21, 2025
7 checks passed
@jamesbraza jamesbraza deleted the better-docs-jupyter branch May 21, 2025 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants