def ask(person, question, chatlog=None): prompttext = f"{chatlog}{person}: {question}…
- User
def ask(person, question, chat_log=None): prompt_text = f"{chat_log}{person}: {question} {start_sequence}:" response = openai.completions.create( model="llama3-70b-8192", prompt=prompt_text, temperature=1, max_tokens=150, # top_p=1, # frequency_penalty=0.1, # presence_penalty=1.2, stop=['\n'], ) result = response['choices'][0]['text'] return prompt_text + result, str(result)
def ask_with_chat_log(chat_log=None): prompt_text = f"{chat_log} {start_sequence}:" response = openai.completions.create( model="llama3-70b-8192", prompt=prompt_text, temperature=1, max_tokens=150, # top_p=1, # frequency_penalty=0.1, # presence_penalty=1.2, stop=['\n'], ) result = response['choices'][0]['text'] return prompt_text + result, str(result)
Rewrite these functions using client.chat.completions.create
- Assistant
To rewrite these functions using
client.chat.completions.create, we need to adjust the method call and how we handle the new completion object. Here's how you can do it:python