Troubleshooting Phoenix Tracing Issues with Langchain Integration
Hello everybody, I am trying to run phoenix locally using a notebook. I am also able to integrate Langchain and our OpenAI Endpoint, run the web app, etc. But the problem is that I just cannot see the traces in the web app... I tried everything, can somebody tell me, what I am doing wrong? # Installation der Pakete #!pip install "langchain>=0.1.0" langchain-openai "openai>=1" "arize-phoenix[evals]" tiktoken nest-asyncio # Setze die Umgebungsvariablen import os os.environ["AZURE_OPENAI_ENDPOINT"] = "..." os.environ["AZURE_OPENAI_API_KEY"] = "..." os.environ["OPENAI_API_VERSION"] = "..." os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"] = "..." os.environ["PHOENIX_PROJECT_NAME"] = "default" # Starten des Phoenix-Servers import phoenix as px import nest_asyncio nest_asyncio.apply() # needed for concurrent evals in notebook environments # Start Phoenix app try: session = px.launch_app() print("Phoenix app launched successfully.") except Exception as e: print(f"Failed to launch Phoenix app: {e}") # Instrumentieren von LangChain from phoenix.trace.langchain import LangChainInstrumentor # Instrument LangChain try: LangChainInstrumentor().instrument() print("LangChain successfully instrumented for Phoenix tracing.") except Exception as e: print(f"Failed to instrument LangChain: {e}") # Initialisieren deiner LangChain-Anwendung from openai import AzureOpenAI # Initialize Azure OpenAI model client = AzureOpenAI( azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"), api_version=os.getenv("OPENAI_API_VERSION") ) # Define the question question = "Give a brief summary of China's economic power." # Create the message for the model messages = [ { "role": "user", "content": question, } ] # Get the response from the LLM try: completion = client.chat.completions.create( model=os.getenv("AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"), messages=messages ) print("Response:", completion.to_json()) except Exception as e: print(f"Error: {e}") # Display the Phoenix dashboard in the notebook try: print(f"Phoenix app view: {px.active_session().url}") except AttributeError: print("No active Phoenix session found.")
