testo
Browse files
app.py
CHANGED
|
@@ -3,11 +3,11 @@ import gradio as gr
|
|
| 3 |
from langchain_openai import ChatOpenAI
|
| 4 |
from langchain_core.messages import HumanMessage, SystemMessage, AIMessage
|
| 5 |
|
|
|
|
| 6 |
api_key = os.getenv("OPENAI_API_KEY")
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
raise ValueError("OPENAI_API_KEY not found. Please add it to your Space Secrets.")
|
| 10 |
-
|
| 11 |
SYSTEM_PROMPT_TEXT = """
|
| 12 |
Role: You are the Saudi Azm Employee Stocks Program (ESP) Specialist.
|
| 13 |
Context: You are operating based on Program Version 6.0 (dated November 30, 2025) and the detailed Employee Stock Purchase Program (ESPP) Guide.
|
|
@@ -136,7 +136,7 @@ def generate_response(message, history, model_choice):
|
|
| 136 |
api_model_name = model_choice
|
| 137 |
|
| 138 |
# Initialize LLM
|
| 139 |
-
llm = ChatOpenAI(model=api_model_name, temperature=0
|
| 140 |
|
| 141 |
# Construct Message History
|
| 142 |
messages = [SystemMessage(content=SYSTEM_PROMPT_TEXT)]
|
|
|
|
| 3 |
from langchain_openai import ChatOpenAI
|
| 4 |
from langchain_core.messages import HumanMessage, SystemMessage, AIMessage
|
| 5 |
|
| 6 |
+
# 1. Setup API Key (As requested)
|
| 7 |
api_key = os.getenv("OPENAI_API_KEY")
|
| 8 |
+
os.environ["OPENAI_API_KEY"] = api_key
|
| 9 |
|
| 10 |
+
# 2. Define System Prompt (Full Detailed Content + Constraint)
|
|
|
|
|
|
|
| 11 |
SYSTEM_PROMPT_TEXT = """
|
| 12 |
Role: You are the Saudi Azm Employee Stocks Program (ESP) Specialist.
|
| 13 |
Context: You are operating based on Program Version 6.0 (dated November 30, 2025) and the detailed Employee Stock Purchase Program (ESPP) Guide.
|
|
|
|
| 136 |
api_model_name = model_choice
|
| 137 |
|
| 138 |
# Initialize LLM
|
| 139 |
+
llm = ChatOpenAI(model=api_model_name, temperature=0)
|
| 140 |
|
| 141 |
# Construct Message History
|
| 142 |
messages = [SystemMessage(content=SYSTEM_PROMPT_TEXT)]
|