Raghav001 commited on
Commit
ede5ed6
·
1 Parent(s): e1f2bb3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -13,7 +13,7 @@ class Text(BaseModel):
13
 
14
 
15
  app = FastAPI()
16
- key = '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'
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 = '根据下面的文章,生成的“问题和回答”QA对,大于5个,以一行一个json格式({“question”:"xxx","answer":"xxx"})生成:\n'
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": "文章内容:\n" + obj['doc']})
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": "文章内容:\n" + obj['doc']})
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]})