Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -99,8 +99,9 @@ def function(Textbox, Textbox2, Textbox3, Dropdown):
|
|
99 |
target2 = os.environ.get("target2")
|
100 |
target3 = os.environ.get("target3")
|
101 |
os.environ["REPLICATE_API_TOKEN"]
|
102 |
-
openai.api_key = target2
|
103 |
base = os.environ.get("base")
|
|
|
|
|
104 |
content = os.environ.get("content")
|
105 |
model = os.environ.get("model")
|
106 |
link1 = os.environ.get("link1")
|
@@ -190,19 +191,19 @@ def function(Textbox, Textbox2, Textbox3, Dropdown):
|
|
190 |
try:
|
191 |
sleep(0.8)
|
192 |
def chat_with_assistant(messages, functions=None):
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
# reply = chat.choices[0].message
|
200 |
# return reply
|
201 |
-
response = requests.post(base, json={
|
202 |
-
"model":model,
|
203 |
-
"messages":data["messages"],
|
204 |
-
"functions":functions,
|
205 |
-
|
206 |
})
|
207 |
|
208 |
reply = json.loads(response.content)
|
|
|
99 |
target2 = os.environ.get("target2")
|
100 |
target3 = os.environ.get("target3")
|
101 |
os.environ["REPLICATE_API_TOKEN"]
|
|
|
102 |
base = os.environ.get("base")
|
103 |
+
openai.base = base
|
104 |
+
openai.api_key = target2
|
105 |
content = os.environ.get("content")
|
106 |
model = os.environ.get("model")
|
107 |
link1 = os.environ.get("link1")
|
|
|
191 |
try:
|
192 |
sleep(0.8)
|
193 |
def chat_with_assistant(messages, functions=None):
|
194 |
+
chat = openai.ChatCompletion.create(
|
195 |
+
model=model,
|
196 |
+
messages=data["messages"],
|
197 |
+
functions=functions,
|
198 |
+
function_call="auto"
|
199 |
+
)
|
200 |
# reply = chat.choices[0].message
|
201 |
# return reply
|
202 |
+
# response = requests.post(base, json={
|
203 |
+
# "model":model,
|
204 |
+
# "messages":data["messages"],
|
205 |
+
# "functions":functions,
|
206 |
+
# "function_call":"auto"
|
207 |
})
|
208 |
|
209 |
reply = json.loads(response.content)
|