Update app.py
Browse files
app.py
CHANGED
@@ -150,6 +150,9 @@ def chatbot(input_text):
|
|
150 |
return str(response.response)
|
151 |
|
152 |
def chat(input_text, MaxToken=50, outputs=3):
|
|
|
|
|
|
|
153 |
# We use the Chat Completion endpoint for chat like inputs
|
154 |
response = openai.ChatCompletion.create(
|
155 |
# model used here is ChatGPT
|
@@ -157,7 +160,7 @@ def chat(input_text, MaxToken=50, outputs=3):
|
|
157 |
# gpt-4, gpt-4-0314, gpt-4-32k, gpt-4-32k-0314,
|
158 |
# gpt-3.5-turbo, gpt-3.5-turbo-0301
|
159 |
model="gpt-3.5-turbo",
|
160 |
-
messages=
|
161 |
# max_tokens generated by the AI model
|
162 |
# maximu value can be 4096 tokens for "gpt-3.5-turbo"
|
163 |
max_tokens = MaxToken,
|
@@ -165,7 +168,7 @@ def chat(input_text, MaxToken=50, outputs=3):
|
|
165 |
n = outputs,
|
166 |
)
|
167 |
return response.choices[0].message
|
168 |
-
|
169 |
with gr.Blocks(css=css) as demo:
|
170 |
realPath = str(os.path.dirname(os.path.realpath(__file__)))
|
171 |
img1 = gr.Image("images/header.png", elem_classes=".img.svelte-ms5bsk", elem_id="img.svelte-ms5bsk").style(
|
|
|
150 |
return str(response.response)
|
151 |
|
152 |
def chat(input_text, MaxToken=50, outputs=3):
|
153 |
+
MSGS = [
|
154 |
+
{"role": "user", "content": input_text},
|
155 |
+
]
|
156 |
# We use the Chat Completion endpoint for chat like inputs
|
157 |
response = openai.ChatCompletion.create(
|
158 |
# model used here is ChatGPT
|
|
|
160 |
# gpt-4, gpt-4-0314, gpt-4-32k, gpt-4-32k-0314,
|
161 |
# gpt-3.5-turbo, gpt-3.5-turbo-0301
|
162 |
model="gpt-3.5-turbo",
|
163 |
+
messages=MSGS,
|
164 |
# max_tokens generated by the AI model
|
165 |
# maximu value can be 4096 tokens for "gpt-3.5-turbo"
|
166 |
max_tokens = MaxToken,
|
|
|
168 |
n = outputs,
|
169 |
)
|
170 |
return response.choices[0].message
|
171 |
+
|
172 |
with gr.Blocks(css=css) as demo:
|
173 |
realPath = str(os.path.dirname(os.path.realpath(__file__)))
|
174 |
img1 = gr.Image("images/header.png", elem_classes=".img.svelte-ms5bsk", elem_id="img.svelte-ms5bsk").style(
|