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