Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,8 @@
|
|
| 1 |
import openai
|
| 2 |
import gradio
|
| 3 |
-
import logging
|
| 4 |
|
| 5 |
openai.api_key = "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"
|
| 6 |
|
| 7 |
-
logging.basicConfig(filename='ai_barrister_usage.log', level=logging.INFO) # new configuration statement
|
| 8 |
-
|
| 9 |
messages = [
|
| 10 |
{
|
| 11 |
"role": "system",
|
|
@@ -14,19 +11,12 @@ messages = [
|
|
| 14 |
]
|
| 15 |
|
| 16 |
def CustomChatGPT(user_input):
|
| 17 |
-
# Log the user input
|
| 18 |
-
logging.info(f"Received user input: {user_input}")
|
| 19 |
-
|
| 20 |
messages.append({"role": "user", "content": user_input})
|
| 21 |
response = openai.ChatCompletion.create(
|
| 22 |
model = "gpt-3.5-turbo",
|
| 23 |
messages = messages
|
| 24 |
)
|
| 25 |
ChatGPT_reply = response["choices"][0]["message"]["content"]
|
| 26 |
-
|
| 27 |
-
# Log the assistant's response
|
| 28 |
-
logging.info(f"Assistant's reply: {ChatGPT_reply}")
|
| 29 |
-
|
| 30 |
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
| 31 |
return ChatGPT_reply
|
| 32 |
|
|
|
|
| 1 |
import openai
|
| 2 |
import gradio
|
|
|
|
| 3 |
|
| 4 |
openai.api_key = "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"
|
| 5 |
|
|
|
|
|
|
|
| 6 |
messages = [
|
| 7 |
{
|
| 8 |
"role": "system",
|
|
|
|
| 11 |
]
|
| 12 |
|
| 13 |
def CustomChatGPT(user_input):
|
|
|
|
|
|
|
|
|
|
| 14 |
messages.append({"role": "user", "content": user_input})
|
| 15 |
response = openai.ChatCompletion.create(
|
| 16 |
model = "gpt-3.5-turbo",
|
| 17 |
messages = messages
|
| 18 |
)
|
| 19 |
ChatGPT_reply = response["choices"][0]["message"]["content"]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
| 21 |
return ChatGPT_reply
|
| 22 |
|