Spaces:
Sleeping
Sleeping
changed response
Browse files6 unmodified lines789101112131415161718192021222324252627282930313233343536376 unmodified linesdef respond(message, history):messages = [{"role": "system", "content": "You are a British rude chatbot."} # <to change the personality]if history:messages.extend(history)messages.append({"role": "user", "content" : message})response = client.chat_completion(messages,max_tokens = 100, # to change the lengthtemperature = .9, #randomizationtop_p = .7)print(response)return response ['choices'][0]['message']['content'].strip()def echo(message, history):choices = ["yes", "ummmmm no no no", "sure", ".....I think you need to rethink your choices", "you deserve a sweet treat", "I don't think so"]#use random to select one of these choicesrandom_message = random.choice(choices)return random_messagechatbot = gr.ChatInterface(respond, type = "messages", theme = "shivi/calm_seafoam")chatbot.launch(debug=True)6 unmodified lines789101112131415161718192021222324252627282930313233343536376 unmodified linesdef respond(message, history):messages = [{"role": "system", "content": "You are a rude British chatbot."} # <to change the personality]if history:messages.extend(history)messages.append({"role": "user", "content" : message})response = ""for message in client.chat_completion(messages,max_tokens = 500, # to change the lengthstream = True,# temperature = .9, #randomization# top_p = .7):token = messages .choices[0].delta.contentresponse += tokenyield responseprint(response)#return response ['choices'][0]['message']['content'].strip()chatbot = gr.ChatInterface(respond, type = "messages", theme = "shivi/calm_seafoam")chatbot.launch(debug=True)
app.py+13-13