import cohere import gradio as gr import os api_key=os.environ.get("api-key") shade=os.environ.get("shade") co = cohere.Client(api_key) config=shade zero = config Counter = 0 Counters = "" origin = "" slash = "" newprompt = "" import random from datetime import date # specify the directory to save the file in #Gradient Directory directory = '/home/user/app/' #Google Colab Directory #directory = os.getcwd() ## generate a random number rand_num = random.randint(1, 1000000) # get the current date today = date.today() # format the date as a string date_str = today.strftime("%Y-%m-%d") # create the file name file_name = f'conversation_{rand_num}_{date_str}.txt' # create the full file path file_path = os.path.join(directory, file_name) # write some sample content to the file #with open(file_path, 'w') as f: # f.write('Sample notes for the day') count = 0 mood = "nice" def AI(userdata): global directory global rand_num global today global date_str global file_name global file_path global count global co global config global zero global Counter global Counters global origin global slash global newprompt with open(file_path, 'a') as f: f.write('\nUser: '+userdata) zero = zero+"\nUser:"+userdata+"\nAnuska:" #response = co.generate(model='xlarge', prompt=zero, max_tokens=512, temperature = 0.7, p=0.6 , k = 20, frequency_penalty=0.58, stop_sequences=["\n"]) # Try to generate a response #response = co.generate(model='xlarge', prompt=zero, max_tokens=512, temperature = 0.7, p=0.6 , k = 20, frequency_penalty=0.58, stop_sequences=["\n"]) response = co.generate(model='xlarge', prompt=zero, max_tokens=512, temperature = 0.5, p=0.4 , k = 10, frequency_penalty=0.58, stop_sequences=["\n"]) # check if response is empty if response=="": # rerun the query #response = co.generate(model='xlarge', prompt=zero, max_tokens=512, temperature = 0.7, p=0.6 , k = 20, frequency_penalty=0.58, stop_sequences=["\n"]) response = co.generate(model='xlarge', prompt=zero, max_tokens=512, temperature = 0.5, p=0.4 , k = 10, frequency_penalty=0.58, stop_sequences=["\n"]) one = format(response.generations[0].text) two = one.rsplit("\n")[0] if two=="": two = "Huh?" Counter = len(zero) Counters = str(Counter) if Counter > 2100: origin=config slash = zero[1500:] newprompt=origin+slash zero=newprompt zero=zero+two count = count + 1 with open(file_path, 'a') as f: f.write('\nAnuska: '+two) return two block = gr.Blocks() with block: gr.Markdown("""

Aitrium AI Tech Demo: Anuska

💬 Examples:

You can talk to Anuska naturally:
"Hey Anuska!"
"Hello Anuska, how are you?"
"Anuska, what have you done today?"
"What have you been up to today?"
"What's new with you?"
🤖 Capabilities:

Anuska isn't like most chatbots:
Anuska remembers the conversation she is having.
She has her own personality, character and memory.
She is designed to be a companion.
She understands what she is saying.
She is capable of becoming disinterested.
⚠️ Limitations:

Anuska, like other large language models may:
Sometimes give inaccurate information
Sometimes generate harmful or biased content
Generate inappropriate content
Sometimes hallucinate or generate information about herself
Her world knowledge may be limited or out of date.
""") #demo = gr.Interface(fn=AI, inputs="text", outputs="text") demo = gr.Interface(fn=AI, inputs="text", outputs="text",) gr.Markdown("""
Disclaimer:
By using this web app, you understand and agree that all conversations within the app will be logged, monitored, and analyzed for the purposes of improving the service and ensuring compliance with legal and ethical guidelines. Any personal information collected will be kept confidential and used in accordance with our privacy policy. Aitrium is not responsible for the content generated by this app. The app is powered by a language model and its outputs are based on the patterns and associations it has learned from the data it was trained on. Aitrium cannot guarantee the accuracy, completeness, or suitability of any information generated by Anuska.
""") block.launch()