Find answers from the community

Updated last year

Hi I m having issues with deploying this

Hi I'm having issues with deploying this fastapi + llamaindex into heroku..
I have my code setup like this:

os.environ['OPENAI_API_KEY'] = "sk-APIKEY"
openai.api_key = os.getenv('OPENAI_API_KEY')

@app.post("/stream")
async def stream(query: Query):
# define LLM
llm = OpenAI(temperature=0, model="gpt-3.5-turbo", max_tokens=1000)
service_context = ServiceContext.from_defaults(llm=llm, chunk_size=51200)

documents = SimpleDirectoryReader('data2').load_data()
index = VectorStoreIndex.from_documents(documents, service_context=service_context)
query_engine = index.as_query_engine(similarity_top_k=10)
query_preamble= "Given the provided product details, recommend several products from the provided data, and describe them, that satisfies the following search query or question: "
prompt = query_preamble + query.content
response = query_engine.query(prompt + ". Now output this data in a numbered list without including 'Product Name' and 'Description' keywords. Then summarize everything at the end.")

return {"response": response}
g
T
19 comments
this was working fine in my local, and i have tested out endpoints so theres no problem with connecting to this api from frontend. However, i am getting this issue when i access /stream endpoint.
my openai key is correct
any possible ideas ?
Looks like an issue with your OpenAI API key
I have copied it correctly and have also tried different ones
let me diagnose more
same issue still, tried a different key
i think ive found an issue.. @Teemu
My OPENAI api keys are disappearing...
like in the openai dashboard, i just created a new key like a few minutes ago, then i refresh the page, and its gone
maybe its cause im including the key into github and its detecting it?
Are you committing them to a public repo? That's a terrible idea
just my public repo for testing
i just wanted to see if it works overall
Why does it need to be public for that?
You should never commit any API keys to a public repo
Okay that did the trick. I guess openai just autodetects if the api is exposed publicly
Yeah they scrape them
It's to stop malicious users from scraping and using them
Makes sense
Add a reply
Sign up and join the conversation on Discord