Ted Sanders

Results 148 comments of Ted Sanders

I'm doing a full rewrite of the example and I'll include some of the changes you suggest.

I rewrote the example and included a prompt injection example, as you suggested: https://github.com/openai/openai-cookbook/blob/main/examples/Question_answering_using_embeddings.ipynb Will close this PR. Cheers.

> just for completeness, the same problem also appears in https://github.com/openai/openai-cookbook/blob/main/apps/web-crawl-q-and-a/web-qa.ipynb @logankilpatrick, do you want to replicate this quick change to the web crawl Q&A notebook when you have time?

Yes, will do. Use `cl100k_base` as the encoding. And if you use `tiktoken` to count tokens for ChatGPT API calls, for now you can add 4 to the lengths of...

In the meantime, you can use: ``` import tiktoken def num_tokens_from_messages(messages, model="gpt-3.5-turbo-0301"): """Returns the number of tokens used by a list of messages.""" try: encoding = tiktoken.encoding_for_model(model) except KeyError: encoding...

Updated here: https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb

Yep, if your users are untrusted third parties who control part of the input to the model, it can be difficult to ensure the model only does what you want....