Spaces:
Sleeping
Sleeping
add date and structured logging
Browse files
billy.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
#!/usr/bin/env python
|
| 2 |
|
|
|
|
| 3 |
import openai
|
| 4 |
import os
|
| 5 |
import gradio as gr
|
|
@@ -14,7 +15,7 @@ VERSION = "1.0.0"
|
|
| 14 |
|
| 15 |
def billy(region: str, input: str):
|
| 16 |
"""Hillbily chatbot that tranlates phrases to funny old sayings."""
|
| 17 |
-
print(f"
|
| 18 |
|
| 19 |
messages = [
|
| 20 |
{
|
|
@@ -26,12 +27,14 @@ def billy(region: str, input: str):
|
|
| 26 |
CONTEXT = "What is a hillbillly colloquialism for: "
|
| 27 |
if input:
|
| 28 |
messages.append({"role": "user", "content": CONTEXT + input})
|
|
|
|
| 29 |
chat = openai.ChatCompletion.create(
|
| 30 |
model="gpt-3.5-turbo", messages=messages
|
| 31 |
)
|
| 32 |
|
| 33 |
reply = chat.choices[0].message.content
|
| 34 |
messages.append({"role": "assistant", "content": reply})
|
|
|
|
| 35 |
return reply
|
| 36 |
|
| 37 |
|
|
@@ -42,7 +45,7 @@ def main():
|
|
| 42 |
inputs = [
|
| 43 |
gr.Dropdown(
|
| 44 |
[
|
| 45 |
-
"
|
| 46 |
"Australia",
|
| 47 |
"Canada",
|
| 48 |
"England",
|
|
|
|
| 1 |
#!/usr/bin/env python
|
| 2 |
|
| 3 |
+
from datetime import datetime
|
| 4 |
import openai
|
| 5 |
import os
|
| 6 |
import gradio as gr
|
|
|
|
| 15 |
|
| 16 |
def billy(region: str, input: str):
|
| 17 |
"""Hillbily chatbot that tranlates phrases to funny old sayings."""
|
| 18 |
+
print(f"date: {datetime.now()}, region: {region}, input: {input}")
|
| 19 |
|
| 20 |
messages = [
|
| 21 |
{
|
|
|
|
| 27 |
CONTEXT = "What is a hillbillly colloquialism for: "
|
| 28 |
if input:
|
| 29 |
messages.append({"role": "user", "content": CONTEXT + input})
|
| 30 |
+
print(f"date: {datetime.now()}, messages: {messages}")
|
| 31 |
chat = openai.ChatCompletion.create(
|
| 32 |
model="gpt-3.5-turbo", messages=messages
|
| 33 |
)
|
| 34 |
|
| 35 |
reply = chat.choices[0].message.content
|
| 36 |
messages.append({"role": "assistant", "content": reply})
|
| 37 |
+
print(f"date: {datetime.now()}, reply: {reply}")
|
| 38 |
return reply
|
| 39 |
|
| 40 |
|
|
|
|
| 45 |
inputs = [
|
| 46 |
gr.Dropdown(
|
| 47 |
[
|
| 48 |
+
"American",
|
| 49 |
"Australia",
|
| 50 |
"Canada",
|
| 51 |
"England",
|