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: kotaemon as service #432

Closed
wants to merge 3 commits into from
Closed

feat: kotaemon as service #432

wants to merge 3 commits into from

Conversation

phv2312
Copy link
Contributor

@phv2312 phv2312 commented Oct 27, 2024

Description

  • Provide convinient method to call kotaemon without gradio App

Type of change

  • New features (non-breaking change).
  • Bug fix (non-breaking change).
  • Breaking change (fix or feature that would cause existing functionality not to work as expected).

Checklist

  • I have performed a self-review of my code.
  • I have added thorough tests if it is a core feature.
  • There is a reference to the original bug report and related work.
  • I have commented on my code, particularly in hard-to-understand areas.
  • The feature is well documented.

@phv2312
Copy link
Contributor Author

phv2312 commented Oct 27, 2024

How to use:

from kotaemon.deps.container import Container
from ktem.index.file.pipelines import DocumentRetrievalPipeline, IndexDocumentPipeline

"""
1. Indexing
"""
indexing_pipeline: IndexDocumentPipeline = Container.indexings.get("default").get()
print(indexing_pipeline)
stream = indexing_pipeline.stream(
    ["<your_filepath>"],
    reindex=True
)
for response in stream:
    print(response)


"""
2. Retriever
"""
crud = Container.crud
docids = crud.list_docids()

retriever_pipeline: DocumentRetrievalPipeline = Container.retrievers.get("default").get()
print(retriever_pipeline)

responses= retriever_pipeline.run(
    text="What is the main content?",
    doc_ids=docids
)
for response in responses:
    print(response.id_)
    print(response.text)

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.

1 participant