diff options
author | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
---|---|---|
committer | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
commit | 4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch) | |
tree | ee3dc5af3b6313e921cd920906356f5d4febc4ed /R2R/r2r/examples/scripts/run_hyde.py | |
parent | cc961e04ba734dd72309fb548a2f97d67d578813 (diff) | |
download | gn-ai-4a52a71956a8d46fcb7294ac71734504bb09bcc2.tar.gz |
Diffstat (limited to 'R2R/r2r/examples/scripts/run_hyde.py')
-rwxr-xr-x | R2R/r2r/examples/scripts/run_hyde.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/R2R/r2r/examples/scripts/run_hyde.py b/R2R/r2r/examples/scripts/run_hyde.py new file mode 100755 index 00000000..c82ce525 --- /dev/null +++ b/R2R/r2r/examples/scripts/run_hyde.py @@ -0,0 +1,33 @@ +import fire + +from r2r import R2RBuilder, R2RConfig +from r2r.base.abstractions.llm import GenerationConfig +from r2r.main.assembly.factory_extensions import R2RPipeFactoryWithMultiSearch + + +def main(task_prompt_name="hyde", query="Who was aristotle?"): + # Load the configuration file + config = R2RConfig.from_json() + + app = ( + R2RBuilder(config) + .with_pipe_factory(R2RPipeFactoryWithMultiSearch) + .build( + # Add optional override arguments which propagate to the pipe factory + task_prompt_name=task_prompt_name, + ) + ) + + # Run the RAG pipeline through the R2R application + result = app.rag( + query, + query_transform_generation_config=GenerationConfig(model="gpt-4o"), + rag_generation_config=GenerationConfig(model="gpt-3.5-turbo"), + ) + + print(f"Search Results:\n\n{result.search_results}") + print(f"RAG Results:\n\n{result.completion}") + + +if __name__ == "__main__": + fire.Fire(main) |