This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_response(history, model ): | |
global messages, cost | |
response = openai.ChatCompletion.create( | |
model = model, | |
messages=messages, | |
temperature=0.2, | |
) | |
response_msg = response.choices[0].message.content | |
cost = cost + (response.usage['total_tokens'])*(0.002/1000) | |
messages = messages + [{"role":'assistant', 'content': response_msg}] | |
for char in response_msg: | |
history[-1][1] += char | |
#time.sleep(0.05) | |
yield history |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment