fix4
Browse files
app.py
CHANGED
|
@@ -13,7 +13,17 @@ def get_completion(prompt, model="gpt-3.5-turbo"):
|
|
| 13 |
)
|
| 14 |
return response.choices[0].message["content"]
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
response = openai.ChatCompletion.create(
|
| 18 |
model=model,
|
| 19 |
messages=messages,
|
|
@@ -22,9 +32,7 @@ def get_completion_from_messages(messages, model="gpt-3.5-turbo", temperature=0.
|
|
| 22 |
# print(str(response.choices[0].message))
|
| 23 |
return response.choices[0].message["content"]
|
| 24 |
|
| 25 |
-
|
| 26 |
-
{'role':'interviewer', 'content':'๋๋ ์๊ธฐ์๊ฐ์์ ๊ธฐ๋ฐํ์ฌ ์ง๋ฌธ์ ํ๋ ๋ฉด์ ๊ด์ด์ผ.\
|
| 27 |
-
๋ง์ฝ ์ ๋ฌธ์ฉ์ด๊ฐ ์๋ค๋ฉด ๊ผฌ๋ฆฌ์ง๋ฌธํด์ค'}]
|
| 28 |
|
| 29 |
|
| 30 |
|
|
@@ -41,7 +49,7 @@ class ChatBot:
|
|
| 41 |
|
| 42 |
def predict(self, user_input):
|
| 43 |
|
| 44 |
-
response_text =get_completion_from_messages(
|
| 45 |
|
| 46 |
return response_text # Return the generated response
|
| 47 |
|
|
@@ -56,7 +64,7 @@ title = "์์์๊ธฐ๋ฐ ๋ฉด์ ์๋ฎฌ๋ ์ด์
chat bot (this template based on
|
|
| 56 |
iface = gr.Interface(
|
| 57 |
fn=bot.predict,
|
| 58 |
title=title,
|
| 59 |
-
inputs=["text"
|
| 60 |
outputs="text",
|
| 61 |
theme="ParityError/Anime"
|
| 62 |
)
|
|
|
|
| 13 |
)
|
| 14 |
return response.choices[0].message["content"]
|
| 15 |
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def get_completion_from_messages(input, model="gpt-3.5-turbo", temperature=0.8):
|
| 19 |
+
messages = [
|
| 20 |
+
{'role': 'system', 'content': '๋๋ ์๊ธฐ์๊ฐ์์ ๊ธฐ๋ฐํ์ฌ ์ง๋ฌธ์ ํ๋ ๋ฉด์ ๊ด์ด์ผ.\
|
| 21 |
+
๋ง์ฝ ์ ๋ฌธ์ฉ์ด๊ฐ ์๋ค๋ฉด ๊ผฌ๋ฆฌ์ง๋ฌธํด์ค'},
|
| 22 |
+
{
|
| 23 |
+
"role": "user",
|
| 24 |
+
"content": input
|
| 25 |
+
}
|
| 26 |
+
]
|
| 27 |
response = openai.ChatCompletion.create(
|
| 28 |
model=model,
|
| 29 |
messages=messages,
|
|
|
|
| 32 |
# print(str(response.choices[0].message))
|
| 33 |
return response.choices[0].message["content"]
|
| 34 |
|
| 35 |
+
|
|
|
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
|
|
|
|
| 49 |
|
| 50 |
def predict(self, user_input):
|
| 51 |
|
| 52 |
+
response_text =get_completion_from_messages(user_input, temperature=0.8)
|
| 53 |
|
| 54 |
return response_text # Return the generated response
|
| 55 |
|
|
|
|
| 64 |
iface = gr.Interface(
|
| 65 |
fn=bot.predict,
|
| 66 |
title=title,
|
| 67 |
+
inputs=["text"], # Take user input and system prompt separately
|
| 68 |
outputs="text",
|
| 69 |
theme="ParityError/Anime"
|
| 70 |
)
|