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(traces): add reranking span kind for document reranking in llama index #1588

Merged
merged 13 commits into from
Oct 12, 2023
21 changes: 2 additions & 19 deletions tutorials/internal/llama_index_tracing_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"from llama_index.callbacks import CallbackManager\n",
"from llama_index.embeddings.openai import OpenAIEmbedding\n",
"from llama_index.graph_stores.simple import SimpleGraphStore\n",
"from llama_index.indices.postprocessor.cohere_rerank import CohereRerank\n",
"from phoenix.trace.llama_index import (\n",
" OpenInferenceTraceCallbackHandler,\n",
")\n",
Expand All @@ -76,11 +75,7 @@
"if not (openai_api_key := os.getenv(\"OPENAI_API_KEY\")):\n",
" openai_api_key = getpass(\"🔑 Enter your OpenAI API key: \")\n",
"openai.api_key = openai_api_key\n",
"os.environ[\"OPENAI_API_KEY\"] = openai_api_key\n",
"\n",
"if not (cohere_api_key := os.getenv(\"COHERE_API_KEY\")):\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

this is the internal one - it seemed nice to have a notebook that executed a reranker?

Copy link
Contributor Author

@RogerHYang RogerHYang Oct 12, 2023

Choose a reason for hiding this comment

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

oh, my bad. I had mistaken this one with the public notebook llama_index_tracing_tutorial.ipynb which has a very similar name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted

" cohere_api_key = getpass(\"🔑 Enter your COHERE API key: \")\n",
"os.environ[\"COHERE_API_KEY\"] = cohere_api_key"
"os.environ[\"OPENAI_API_KEY\"] = openai_api_key"
]
},
{
Expand Down Expand Up @@ -145,10 +140,7 @@
" storage_context,\n",
" service_context=service_context,\n",
")\n",
"reranker = CohereRerank(top_n=2)\n",
"query_engine = index.as_query_engine(\n",
" node_postprocessors=[reranker],\n",
")"
"query_engine = index.as_query_engine()"
]
},
{
Expand All @@ -175,15 +167,6 @@
"queries"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"px.launch_app()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down