Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse files- backend.py +6 -3
backend.py
CHANGED
|
@@ -5,17 +5,20 @@ from dotenv import load_dotenv
|
|
| 5 |
import openai
|
| 6 |
import gradio as gr
|
| 7 |
|
| 8 |
-
print(f"{'+'*100} {load_dotenv()}")
|
| 9 |
|
| 10 |
if load_dotenv():
|
| 11 |
-
openai.api_key = os.getenv("
|
|
|
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
message_history = []
|
| 15 |
cost = 0
|
| 16 |
|
| 17 |
|
| 18 |
-
def add_text(
|
|
|
|
|
|
|
| 19 |
global message_history
|
| 20 |
message_history += [{"role": "system", "content": f"{system_role}"}]
|
| 21 |
message_history += [{"role": "user", "content": user_input}]
|
|
|
|
| 5 |
import openai
|
| 6 |
import gradio as gr
|
| 7 |
|
|
|
|
| 8 |
|
| 9 |
if load_dotenv():
|
| 10 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 11 |
+
else:
|
| 12 |
+
openai.api_key = os.environ["OPENAI_API_KEY"]
|
| 13 |
|
| 14 |
|
| 15 |
message_history = []
|
| 16 |
cost = 0
|
| 17 |
|
| 18 |
|
| 19 |
+
def add_text(
|
| 20 |
+
user_input: str, history: List, system_role: str = "You are a great assistant"
|
| 21 |
+
):
|
| 22 |
global message_history
|
| 23 |
message_history += [{"role": "system", "content": f"{system_role}"}]
|
| 24 |
message_history += [{"role": "user", "content": user_input}]
|