Skip to content
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

feat: add raw response mode to process_query #79

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

cevatkerim
Copy link

  • Add raw_response option to return tuple instead of template
  • Update extract_content endpoint for plain text output

Example usage:

http://localhost:8000/extract/cyclotruc/gitingest?max_file_size=243&pattern_type=include&pattern=*.py
image

cevatkerim and others added 2 commits December 30, 2024 14:30
- Add raw_response option to return tuple instead of template
- Update extract_content endpoint for plain text output
Copy link
Owner

@cyclotruc cyclotruc left a comment

Choose a reason for hiding this comment

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

Looks like a good starting point for the API Thank you

@@ -18,40 +19,43 @@ async def process_query(
pattern_type: str = "exclude",
pattern: str = "",
is_index: bool = False,
) -> _TemplateResponse:
raw_response: bool = False
) -> Union[_TemplateResponse, tuple[str, str, str]]:
Copy link
Owner

Choose a reason for hiding this comment

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

We should now be able to use the _TemplateResponse | tuple[str, str, str] syntax

src/process_query.py Outdated Show resolved Hide resolved
@cyclotruc
Copy link
Owner

@cevatkerim Very good!
I tested with localhost:8000/extract/cyclotruc/gitingest and it seemed alright!

In order to reach the MVP state for an API we would probably need:

  • Read request headers in dynamic.py to choose which response to send (html or raw)
  • Remove the /extract/ route
  • Make it possible to force raw response via url query args, idk if there's a convention but maybe a field like?format=txt ?
  • Add a few lines in /api docs to explain the usage

I would be very happy to help you work on this branch if you invited me as contributer to your repo
Let me know if you have any ideas to add or if you see anything I'm missing

@cevatkerim
Copy link
Author

@cevatkerim Very good! I tested with localhost:8000/extract/cyclotruc/gitingest and it seemed alright!

In order to reach the MVP state for an API we would probably need:

  • Read request headers in dynamic.py to choose which response to send (html or raw)
  • Remove the /extract/ route
  • Make it possible to force raw response via url query args, idk if there's a convention but maybe a field like?format=txt ?
  • Add a few lines in /api docs to explain the usage

I would be very happy to help you work on this branch if you invited me as contributer to your repo Let me know if you have any ideas to add or if you see anything I'm missing

Sounds good I already added you as a collaborator. You should have access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
work in progress This PR is not ready yet but is being worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants