aboutsummaryrefslogtreecommitdiff
path: root/R2R/r2r/examples/scripts/run_web_rag.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /R2R/r2r/examples/scripts/run_web_rag.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-4a52a71956a8d46fcb7294ac71734504bb09bcc2.tar.gz
two version of R2R are hereHEADmaster
Diffstat (limited to 'R2R/r2r/examples/scripts/run_web_rag.py')
-rwxr-xr-xR2R/r2r/examples/scripts/run_web_rag.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/R2R/r2r/examples/scripts/run_web_rag.py b/R2R/r2r/examples/scripts/run_web_rag.py
new file mode 100755
index 00000000..7535ae27
--- /dev/null
+++ b/R2R/r2r/examples/scripts/run_web_rag.py
@@ -0,0 +1,26 @@
+import fire
+
+from r2r import R2RBuilder, SerperClient, WebSearchPipe
+from r2r.base.abstractions.llm import GenerationConfig
+
+
+def run_rag_pipeline(query="Who was Aristotle?"):
+ # Create search pipe override and pipes
+ web_search_pipe = WebSearchPipe(
+ serper_client=SerperClient() # TODO - Develop a `WebSearchProvider` for configurability
+ )
+
+ app = R2RBuilder().with_vector_search_pipe(web_search_pipe).build()
+
+ # Run the RAG pipeline through the R2R application
+ result = app.rag(
+ query,
+ rag_generation_config=GenerationConfig(model="gpt-4o"),
+ )
+
+ print(f"Search Results:\n\n{result.search_results}")
+ print(f"RAG Results:\n\n{result.completion}")
+
+
+if __name__ == "__main__":
+ fire.Fire(run_rag_pipeline)