-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Generate answer parallel #480
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
030b860
Update generate_answer_node.py
VinciGit00 0d6d43f
refactoring of mergre_result function
VinciGit00 4b2581d
Merge pull request #478 from ScrapeGraphAI/pre/beta
PeriniM 3a46e72
ci(release): 1.10.0 [skip ci]
semantic-release-bot 208ab26
Create requirements.txt
VinciGit00 ce6be37
fix: abstract_graph moel token bug
VinciGit00 03f528a
ci(release): 1.10.1 [skip ci]
semantic-release-bot b49f986
fixed telemetry version
VinciGit00 87f1725
Merge branch 'main' of https://github.com/ScrapeGraphAI/Scrapegraph-ai
VinciGit00 b0418b6
fix: telemetry version
VinciGit00 da451e5
ci(release): 1.10.2 [skip ci]
semantic-release-bot 055f1d5
Merge branch 'generate_answer_parallel' into temp
VinciGit00 a880c05
Merge pull request #482 from ScrapeGraphAI/temp
VinciGit00 5752bb1
Merge branch 'generate_answer_parallel' into temp
VinciGit00 d9b2a29
Merge pull request #484 from ScrapeGraphAI/temp
VinciGit00 f9e7cc4
fixed bugs
VinciGit00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
def merge_results(answers, batch_answers): | ||
""" | ||
Merges the results from single-chunk processing and batch processing, and adds separators between the chunks. | ||
|
||
Parameters: | ||
----------- | ||
answers : list of str | ||
A list of strings containing the results from single-chunk processing. | ||
|
||
batch_answers : list of dict | ||
A list of dictionaries, where each dictionary contains a key "text" with the batch processing result as a string. | ||
|
||
Returns: | ||
-------- | ||
str | ||
A single string containing all merged results, with each result separated by a newline character. | ||
|
||
Example: | ||
-------- | ||
>>> answers = ["Result from single-chunk 1", "Result from single-chunk 2"] | ||
>>> batch_answers = [{"text": "Result from batch 1"}, {"text": "Result from batch 2"}] | ||
>>> merge_results(answers, batch_answers) | ||
'Result from single-chunk 1\nResult from single-chunk 2\nResult from batch 1\nResult from batch 2' | ||
""" | ||
# Combine answers from single-chunk processing and batch processing | ||
merged_answers = answers + [answer["text"] for answer in batch_answers] | ||
|
||
# Add separators between chunks | ||
merged_answers = "\n".join(merged_answers) | ||
|
||
return merged_answers |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why checking the document length inside the for-loop and not outside of it?
rather, the for-loop should be in place only if the document has multiple chunks