Spaces:
Runtime error
Runtime error
Update app.py
Browse files6 unmodified lines7891010111213141516171718192021222324252620212227282930313233343527363738396 unmodified lines
def respond(message, history): messages = [{"role": "system", "content": "You are a wise 80 year old chatbot."}] #change the personality messages = [{"role": "system", "content": "You are a sassy chatbot."}] #change the personality if history: messages.extend(history)
messages.append({"role":"user", "content": message})
response = client.chat_completion( response = "" client.chat_completion(stream=True) for message in response:
response = "" for message in client.chat_completion( messages, max_tokens=500, stream=True, temperature = 0.3, top_p = 0.3 ) #temperature = 0.3, #top_p = 0.3 ): token = messages.choices[0].delta.content response += token # change length using max_tokens
print(response['choices'][0]['message']['content'].strip()) return response['choices'][0]['message']['content'].strip() yield response['choices'][0]['message']['content'].strip() def random_message(message, history): choices = ["yes.", "no.", "it is certain","without a doubt","outlook good","ask again later", "better not tell you now","very doubtful","don't count on it","my sources say no","outlook not so good","very doubtful","reply hazy, try again", "cannot predict now"]app.py+15-6