Spaces:
Sleeping
Sleeping
Nils Durner
commited on
Commit
·
03f0948
1
Parent(s):
3b2d5df
support new OpenAI package
Browse files- app.py +5 -3
- requirements.txt +2 -2
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import base64
|
| 3 |
import os
|
| 4 |
-
import
|
| 5 |
|
| 6 |
dump_controls = False
|
| 7 |
log_to_console = False
|
|
@@ -98,7 +98,9 @@ def process_values_js():
|
|
| 98 |
|
| 99 |
def bot(message, history, oai_key, system_prompt, seed, temperature, max_tokens, model):
|
| 100 |
try:
|
| 101 |
-
|
|
|
|
|
|
|
| 102 |
|
| 103 |
seed_i = None
|
| 104 |
if seed:
|
|
@@ -137,7 +139,7 @@ def bot(message, history, oai_key, system_prompt, seed, temperature, max_tokens,
|
|
| 137 |
if log_to_console:
|
| 138 |
print(f"br_prompt: {str(history_openai_format)}")
|
| 139 |
|
| 140 |
-
response =
|
| 141 |
model=model,
|
| 142 |
messages= history_openai_format,
|
| 143 |
temperature=temperature,
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import base64
|
| 3 |
import os
|
| 4 |
+
from openai import OpenAI
|
| 5 |
|
| 6 |
dump_controls = False
|
| 7 |
log_to_console = False
|
|
|
|
| 98 |
|
| 99 |
def bot(message, history, oai_key, system_prompt, seed, temperature, max_tokens, model):
|
| 100 |
try:
|
| 101 |
+
client = OpenAI(
|
| 102 |
+
api_key=oai_key
|
| 103 |
+
)
|
| 104 |
|
| 105 |
seed_i = None
|
| 106 |
if seed:
|
|
|
|
| 139 |
if log_to_console:
|
| 140 |
print(f"br_prompt: {str(history_openai_format)}")
|
| 141 |
|
| 142 |
+
response = client.chat.completions.create(
|
| 143 |
model=model,
|
| 144 |
messages= history_openai_format,
|
| 145 |
temperature=temperature,
|
requirements.txt
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
-
gradio
|
| 2 |
-
openai
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
openai >= 1.0.0
|