Spaces:
Runtime error
Runtime error
Commit
·
224ad7b
1
Parent(s):
5121ad9
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import io
|
|
4 |
import pathlib
|
5 |
from typing import Union
|
6 |
import os
|
7 |
-
|
8 |
from PIL import Image
|
9 |
# import whisper
|
10 |
import openai
|
@@ -42,6 +42,7 @@ stability_api = client.StabilityInference(
|
|
42 |
whisper_from_pipeline = pipeline("automatic-speech-recognition",model="openai/whisper-medium")
|
43 |
EMBEDIDNGS = None
|
44 |
DATAFRAME_FILE = None
|
|
|
45 |
|
46 |
|
47 |
############# FUNCTION DEPENDING ON IPYTHON FUNCTIONS FROM OPENAI RESPONSE
|
@@ -286,10 +287,10 @@ def build_embeddings(file_name,file_ext):
|
|
286 |
global EMBEDIDNGS
|
287 |
EMBEDIDNGS = OpenAIEmbeddings(openai_api_key=os.environ['OPENAI_API_KEY'])
|
288 |
docsearch = FAISS.from_texts(texts, EMBEDIDNGS)
|
289 |
-
if not os.path.exists('/tmp/embeddings'):
|
290 |
-
os.mkdir('/tmp/embeddings')
|
291 |
-
docsearch.save_local('/tmp/embeddings')
|
292 |
-
print('Embeddings created
|
293 |
|
294 |
|
295 |
def ask_questions_abt_dataframes(file,file_ext):
|
@@ -348,8 +349,11 @@ def clear_chat_history(history:list)->list:
|
|
348 |
|
349 |
|
350 |
|
|
|
|
|
351 |
#################### DRIVER SCRIPT #####################
|
352 |
with gr.Blocks(theme='freddyaboulton/test-blue') as demo:
|
|
|
353 |
gr.Markdown("""<h1 style="color:skyblue;font-family:'Brush Script MT', cursive;text-align:center">GenZBot</h1>""")
|
354 |
gr.Markdown("""GenZBot is a virtual assistant that employs advanced artificial intelligence (AI) technologies to enhance its capabilities. Utilizing cutting-edge AI techniques such as Whisper, chatgpt, internet, Dall-E and OpenAI, GenZBot can provide users with a wide range of useful features. By leveraging AI, GenZBot can understand and respond to users' requests in a natural and intuitive manner, allowing for a more seamless and personalized experience. Its ability to generate paintings, drawings, and abstract art, as well as play music and videos, is made possible by sophisticated AI algorithms that can produce complex and nuanced results. Overall, GenZBot's extensive use of AI technology enables it to serve as a powerful and versatile digital assistant that can adapt to the needs of its users.""")
|
355 |
chatbot = gr.Chatbot()
|
|
|
4 |
import pathlib
|
5 |
from typing import Union
|
6 |
import os
|
7 |
+
import random
|
8 |
from PIL import Image
|
9 |
# import whisper
|
10 |
import openai
|
|
|
42 |
whisper_from_pipeline = pipeline("automatic-speech-recognition",model="openai/whisper-medium")
|
43 |
EMBEDIDNGS = None
|
44 |
DATAFRAME_FILE = None
|
45 |
+
RANDOM_USER = ''.join(chr(random.randint(65,90)) for i in range(8))+f'{random.randint(1,10000000000)}'
|
46 |
|
47 |
|
48 |
############# FUNCTION DEPENDING ON IPYTHON FUNCTIONS FROM OPENAI RESPONSE
|
|
|
287 |
global EMBEDIDNGS
|
288 |
EMBEDIDNGS = OpenAIEmbeddings(openai_api_key=os.environ['OPENAI_API_KEY'])
|
289 |
docsearch = FAISS.from_texts(texts, EMBEDIDNGS)
|
290 |
+
if not os.path.exists(f'/tmp/{RANDOM_USER}embeddings'):
|
291 |
+
os.mkdir('/tmp/{RANDOM_USER}embeddings')
|
292 |
+
docsearch.save_local('/tmp/{RANDOM_USER}embeddings')
|
293 |
+
print(f'Embeddings created to /tmp/{RANDOM_USER}embeddings')
|
294 |
|
295 |
|
296 |
def ask_questions_abt_dataframes(file,file_ext):
|
|
|
349 |
|
350 |
|
351 |
|
352 |
+
|
353 |
+
|
354 |
#################### DRIVER SCRIPT #####################
|
355 |
with gr.Blocks(theme='freddyaboulton/test-blue') as demo:
|
356 |
+
|
357 |
gr.Markdown("""<h1 style="color:skyblue;font-family:'Brush Script MT', cursive;text-align:center">GenZBot</h1>""")
|
358 |
gr.Markdown("""GenZBot is a virtual assistant that employs advanced artificial intelligence (AI) technologies to enhance its capabilities. Utilizing cutting-edge AI techniques such as Whisper, chatgpt, internet, Dall-E and OpenAI, GenZBot can provide users with a wide range of useful features. By leveraging AI, GenZBot can understand and respond to users' requests in a natural and intuitive manner, allowing for a more seamless and personalized experience. Its ability to generate paintings, drawings, and abstract art, as well as play music and videos, is made possible by sophisticated AI algorithms that can produce complex and nuanced results. Overall, GenZBot's extensive use of AI technology enables it to serve as a powerful and versatile digital assistant that can adapt to the needs of its users.""")
|
359 |
chatbot = gr.Chatbot()
|