Spaces:
Runtime error
Runtime error
fix error
Browse files
app.py
CHANGED
@@ -40,21 +40,24 @@ reflections reveal a change or growth in thinking.
|
|
40 |
|
41 |
# Function Definitions
|
42 |
|
43 |
-
def api_calling(
|
44 |
-
|
45 |
engine="text-davinci-003",
|
46 |
-
prompt=
|
47 |
max_tokens=1024,
|
48 |
n=1,
|
49 |
stop=None,
|
50 |
temperature=0.5,
|
51 |
)
|
52 |
-
message =
|
53 |
return message
|
|
|
|
|
54 |
|
55 |
|
56 |
def message_and_history(input, history):
|
57 |
history = history or []
|
|
|
58 |
history.append({"role": "user", "content": input})
|
59 |
|
60 |
# Get chatbot's response
|
|
|
40 |
|
41 |
# Function Definitions
|
42 |
|
43 |
+
def api_calling(history):
|
44 |
+
response = openai.Completion.create(
|
45 |
engine="text-davinci-003",
|
46 |
+
prompt={"messages": history},
|
47 |
max_tokens=1024,
|
48 |
n=1,
|
49 |
stop=None,
|
50 |
temperature=0.5,
|
51 |
)
|
52 |
+
message = response.choices[0].message['content']
|
53 |
return message
|
54 |
+
|
55 |
+
|
56 |
|
57 |
|
58 |
def message_and_history(input, history):
|
59 |
history = history or []
|
60 |
+
history.insert(0, {"role": "system", "content": sys_message})
|
61 |
history.append({"role": "user", "content": input})
|
62 |
|
63 |
# Get chatbot's response
|