Spaces:
Runtime error
Runtime error
Commit
·
930d59b
1
Parent(s):
ffd2f2a
Update gpt.py
Browse files
gpt.py
CHANGED
|
@@ -5,13 +5,13 @@ model = "gpt-3.5-turbo-1106"
|
|
| 5 |
|
| 6 |
def get_keywords(question):
|
| 7 |
prompt = f"Extract 10 keywords from the following question, including synonyms. Use only lowercase letters:\n\n{question}"
|
| 8 |
-
response = openai.completions.create(model=model, prompt=prompt, max_tokens=60, temperature=0)
|
| 9 |
keywords = response.choices[0].text.strip().split(', ')
|
| 10 |
return keywords
|
| 11 |
|
| 12 |
def answer_question(chunk, question):
|
| 13 |
prompt = f"Based on the following information, what is the answer to this question?\n\nText:\n{chunk}\n\nQuestion:\n{question}"
|
| 14 |
-
response = openai.completions.create(model=model, prompt=prompt, max_tokens=150, temperature=0)
|
| 15 |
answer = response.choices[0].text.strip()
|
| 16 |
return answer
|
| 17 |
|
|
|
|
| 5 |
|
| 6 |
def get_keywords(question):
|
| 7 |
prompt = f"Extract 10 keywords from the following question, including synonyms. Use only lowercase letters:\n\n{question}"
|
| 8 |
+
response = openai.chat.completions.create(model=model, prompt=prompt, max_tokens=60, temperature=0)
|
| 9 |
keywords = response.choices[0].text.strip().split(', ')
|
| 10 |
return keywords
|
| 11 |
|
| 12 |
def answer_question(chunk, question):
|
| 13 |
prompt = f"Based on the following information, what is the answer to this question?\n\nText:\n{chunk}\n\nQuestion:\n{question}"
|
| 14 |
+
response = openai.chat.completions.create(model=model, prompt=prompt, max_tokens=150, temperature=0)
|
| 15 |
answer = response.choices[0].text.strip()
|
| 16 |
return answer
|
| 17 |
|