Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -45,23 +45,21 @@ import requests
|
|
45 |
import openai
|
46 |
import os
|
47 |
|
48 |
-
def function(Textbox,Textbox2):
|
49 |
target = os.environ.get("target")
|
50 |
target2 = os.environ.get("target2")
|
51 |
openai.api_key = target2
|
52 |
content = os.environ.get("content")
|
53 |
# model = os.environ.get("model")
|
54 |
# hrc = os.environ.get("hrc")
|
55 |
-
if
|
56 |
-
messages = [
|
57 |
-
|
58 |
-
]
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
model="gpt-3.5-turbo", messages=messages
|
64 |
-
)
|
65 |
reply = chat.choices[0].message.content
|
66 |
messages.append({"role": "assistant", "content": reply})
|
67 |
return reply
|
@@ -70,7 +68,8 @@ def function(Textbox,Textbox2):
|
|
70 |
|
71 |
inputs = [
|
72 |
gr.inputs.Textbox(label="Textbox",type="text"),
|
73 |
-
gr.inputs.Textbox(label="Textbox2",type="
|
|
|
74 |
]
|
75 |
|
76 |
iface = gr.Interface(fn=function, inputs=inputs, outputs="text")
|
|
|
45 |
import openai
|
46 |
import os
|
47 |
|
48 |
+
def function(Textbox,Textbox2,Textbox3):
|
49 |
target = os.environ.get("target")
|
50 |
target2 = os.environ.get("target2")
|
51 |
openai.api_key = target2
|
52 |
content = os.environ.get("content")
|
53 |
# model = os.environ.get("model")
|
54 |
# hrc = os.environ.get("hrc")
|
55 |
+
if Textbox3 == target:
|
56 |
+
# messages = [
|
57 |
+
# {"role": "system", "content": content},
|
58 |
+
# ]
|
59 |
+
if Textbox2:
|
60 |
+
chat = openai.ChatCompletion.create(
|
61 |
+
model="gpt-3.5-turbo", messages=Textbox2
|
62 |
+
)
|
|
|
|
|
63 |
reply = chat.choices[0].message.content
|
64 |
messages.append({"role": "assistant", "content": reply})
|
65 |
return reply
|
|
|
68 |
|
69 |
inputs = [
|
70 |
gr.inputs.Textbox(label="Textbox",type="text"),
|
71 |
+
gr.inputs.Textbox(label="Textbox2",type="text"),
|
72 |
+
gr.inputs.Textbox(label="Textbox3",type="password")
|
73 |
]
|
74 |
|
75 |
iface = gr.Interface(fn=function, inputs=inputs, outputs="text")
|