Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question and Answer example #71

Open
RajiRai opened this issue Apr 15, 2021 · 2 comments
Open

Question and Answer example #71

RajiRai opened this issue Apr 15, 2021 · 2 comments

Comments

@RajiRai
Copy link

RajiRai commented Apr 15, 2021

Hi,
Firstly thanks for this cool repo. I am trying to build a question and answer app using GPT3. How do I save a document file or feed the example with say 500 words text based on which users will question and the API will search the file or given text and provide the answer. Endpoint for is given in the GPT3 example but I am finding it tough to integrate it with this repo example. Any help is appreciated. Below the given code:

doc_list=["sample text to be searched."]

response = openai.Answer.create(
search_model="davinci",
model="curie",
question="What is sample text",
documents=doc_list,
examples_context="In 2017, U.S. life expectancy was 78.6 years.",
examples=[["What is human life expectancy in the United States?","78 years."]],
max_tokens=10,
stop=["\n", "<|endoftext|>"],
)

print(response)

Thanks,
Raji

@RajiRai
Copy link
Author

RajiRai commented Apr 15, 2021

Hi, I tried modifying the gpt.py file to add this endpoint

def submit_request(self, prompt):
"""Calls the OpenAI API with the specified parameters."""
response = openai.Answer.create(
search_model="davinci",
model="curie",
question=self.craft_query(prompt),
document=doc_list,
examples_context="In 2017, U.S. life expectancy was 78.6 years.",
examples=[["What is human life expectancy in the United States?","78 years."]],
max_tokens=self.get_max_tokens(),
temperature=self.get_temperature(),
stop=["\n", "<|endoftext|>"])
return response

in my example.py file I have added the doc_list which is a list of text.

when i execute the example.py file i am getting error as AttributeError: module 'openai' has no attribute 'Answer'

@shreyashankar
Copy link
Owner

Did you install the openai package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants