Spaces:
Build error
Build error
File size: 5,455 Bytes
9459b37 bd71a38 47749b7 bd71a38 9459b37 bd71a38 9459b37 82a8a8f 9459b37 82a8a8f 9459b37 1cda5ff 9459b37 73435e0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | 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("""
<h1><center>Aitrium AI Tech Demo: Anuska</center></h1>
<div style="display: flex;">
<div style="flex: 1; text-align: center; background-color: #cccccc; padding: 10px; border-right: 5px solid white;">
<strong>💬 Examples:</strong>
<hr style="border-top: 5px solid white; margin: 0px;">
<br><strong>You can talk to Anuska naturally:</strong>
<br>"Hey Anuska!"
<br>"Hello Anuska, how are you?"
<br>"Anuska, what have you done today?"
<br>"What have you been up to today?"
<br>"What's new with you?"
</div>
<div style="flex: 1; text-align: center; background-color: #cccccc; padding: 10px; border-right: 5px solid white;">
<strong>🤖 Capabilities:</strong>
<hr style="border-top: 5px solid white; margin: 0px;">
<br><strong>Anuska isn't like most chatbots:</strong>
<br>Anuska remembers the conversation she is having.
<br>She has her own personality, character and memory.
<br>She is designed to be a companion.
<br>She understands what she is saying.
<br>She is capable of becoming disinterested.
</div>
<div style="flex: 1; text-align: center; background-color: #cccccc; padding: 10px;">
<strong>⚠️ Limitations:</strong>
<hr style="border-top: 5px solid white; margin: 0px;">
<br><strong>Anuska, like other large language models may:</strong>
<br>Sometimes give inaccurate information
<br>Sometimes generate harmful or biased content
<br>Generate inappropriate content
<br>Sometimes hallucinate or generate information about herself
<br>Her world knowledge may be limited or out of date.
</div>
</div>
""")
#demo = gr.Interface(fn=AI, inputs="text", outputs="text")
demo = gr.Interface(fn=AI, inputs="text", outputs="text",)
gr.Markdown("""
<style>
.disclaimer {
background-color: yellow;
color: black;
padding: 10px;
font-family: 'Roboto', sans-serif;
text-align: center;
font-size: 1em;
}
</style>
<div class="disclaimer">
<strong>Disclaimer:</strong><br>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.
</div>
""")
block.launch() |