Skip to content

Commit

Permalink
openai error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
aiproductguy committed Nov 10, 2024
1 parent 571622d commit c756ad2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion notebooks/streamlit-app-lightrag.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,11 @@ def rewrite_prompt(prompt: str) -> str:
"""Rewrite the user prompt into a templated format using OpenAI."""
try:
from openai import OpenAI
client = OpenAI(api_key=st.session_state.settings["api_key"])
api_key = get_api_key() # Get API key using our utility function
if not api_key:
raise ValueError("OpenAI API key not found")

client = OpenAI(api_key=api_key)

system_instruction = f"""
You are a prompt engineering assistant. Your task is to rewrite user prompts into a templated format.
Expand Down

0 comments on commit c756ad2

Please sign in to comment.