Update app.py
Browse files
app.py
CHANGED
|
@@ -13,7 +13,7 @@ class Text(BaseModel):
|
|
| 13 |
|
| 14 |
|
| 15 |
app = FastAPI()
|
| 16 |
-
key = 'sk-
|
| 17 |
openai.api_key = key
|
| 18 |
headers = {
|
| 19 |
'Content-Type': 'application/json',
|
|
@@ -30,7 +30,7 @@ def home():
|
|
| 30 |
@app.post("/qa_maker")
|
| 31 |
def sentiment_analysis_ep(content: Text = None):
|
| 32 |
url = 'https://api.openai.com/v1/chat/completions'
|
| 33 |
-
prompt = '
|
| 34 |
messages = [{"role": "user", "content": prompt + content.content}]
|
| 35 |
data = {
|
| 36 |
"model": "gpt-3.5-turbo",
|
|
@@ -53,11 +53,11 @@ def chat_pdf_ep(content: Text = None):
|
|
| 53 |
messages = [
|
| 54 |
{
|
| 55 |
"role": "system",
|
| 56 |
-
"content": "
|
| 57 |
}
|
| 58 |
]
|
| 59 |
obj = json.loads(content.content)
|
| 60 |
-
messages.append({"role": "system", "content": "
|
| 61 |
history = obj['history']
|
| 62 |
for his in history:
|
| 63 |
messages.append({"role": "user", "content": his[0]})
|
|
@@ -84,11 +84,11 @@ def sale_ep(content: Text = None):
|
|
| 84 |
messages = [
|
| 85 |
{
|
| 86 |
"role": "system",
|
| 87 |
-
"content": "
|
| 88 |
}
|
| 89 |
]
|
| 90 |
obj = json.loads(content.content)
|
| 91 |
-
messages.append({"role": "system", "content": "
|
| 92 |
history = obj['history']
|
| 93 |
for his in history:
|
| 94 |
messages.append({"role": "user", "content": his[0]})
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
app = FastAPI()
|
| 16 |
+
key = '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'
|
| 17 |
openai.api_key = key
|
| 18 |
headers = {
|
| 19 |
'Content-Type': 'application/json',
|
|
|
|
| 30 |
@app.post("/qa_maker")
|
| 31 |
def sentiment_analysis_ep(content: Text = None):
|
| 32 |
url = 'https://api.openai.com/v1/chat/completions'
|
| 33 |
+
prompt = 'According to the article below, generate "question and answer" QA pairs, greater than 5, in a json format per line({“question”:"xxx","answer":"xxx"})generate:\n'
|
| 34 |
messages = [{"role": "user", "content": prompt + content.content}]
|
| 35 |
data = {
|
| 36 |
"model": "gpt-3.5-turbo",
|
|
|
|
| 53 |
messages = [
|
| 54 |
{
|
| 55 |
"role": "system",
|
| 56 |
+
"content": "You are a useful assistant to answer questions accurately using the content of the article."
|
| 57 |
}
|
| 58 |
]
|
| 59 |
obj = json.loads(content.content)
|
| 60 |
+
messages.append({"role": "system", "content": "Article content:\n" + obj['doc']})
|
| 61 |
history = obj['history']
|
| 62 |
for his in history:
|
| 63 |
messages.append({"role": "user", "content": his[0]})
|
|
|
|
| 84 |
messages = [
|
| 85 |
{
|
| 86 |
"role": "system",
|
| 87 |
+
"content": "You are a useful assistant to answer questions accurately using the content of the article"
|
| 88 |
}
|
| 89 |
]
|
| 90 |
obj = json.loads(content.content)
|
| 91 |
+
messages.append({"role": "system", "content": "Article content:\n" + obj['doc']})
|
| 92 |
history = obj['history']
|
| 93 |
for his in history:
|
| 94 |
messages.append({"role": "user", "content": his[0]})
|