Commit ·
d6f25ed
1
Parent(s): 2bf90a8
Complete the full setup.
Browse filesOn branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
modified: app.py
deleted: last_audio.mp3
modified: supplier.py
- app.py +8 -17
- last_audio.mp3 +0 -0
- supplier.py +5 -39
app.py
CHANGED
|
@@ -4,22 +4,13 @@ from supplier import *
|
|
| 4 |
BASE_SAMPLES = ["What can you help me with?","What materials do we have?","What projects do we have today?"]
|
| 5 |
|
| 6 |
# create a system setting for llm
|
| 7 |
-
with gr.Blocks() as
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
background_edit = gr.Textbox(placeholder="change the background here",label="update background",lines = 5)
|
| 16 |
-
background_edit.submit(update_sys,background_edit,background)
|
| 17 |
-
with gr.Row():
|
| 18 |
-
clear = gr.Button("Clear")
|
| 19 |
-
submit = gr.Button("Submit")
|
| 20 |
-
|
| 21 |
-
clear.click(lambda:None,None,background_edit,queue=False)
|
| 22 |
-
submit.click(update_sys,background_edit,background,queue=False)
|
| 23 |
|
| 24 |
with gr.Blocks() as chat_window:
|
| 25 |
with gr.Row():
|
|
@@ -45,7 +36,7 @@ with gr.Blocks() as chat_window:
|
|
| 45 |
|
| 46 |
|
| 47 |
iface = gr.TabbedInterface(
|
| 48 |
-
[chat_window,
|
| 49 |
["Chat","Settings"],
|
| 50 |
title="MiMinions.ai",
|
| 51 |
css="footer {visibility: hidden}")
|
|
|
|
| 4 |
BASE_SAMPLES = ["What can you help me with?","What materials do we have?","What projects do we have today?"]
|
| 5 |
|
| 6 |
# create a system setting for llm
|
| 7 |
+
with gr.Blocks() as supply_chain_view:
|
| 8 |
+
pass
|
| 9 |
+
# with gr.Column():
|
| 10 |
+
# project_table = gr.Table(headers=["Project","Material","Quantity","Due Date"])
|
| 11 |
+
|
| 12 |
+
# with gr.Column():
|
| 13 |
+
# material_table = gr.Table(headers=["Material","Quantity","Supplier","Price"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
with gr.Blocks() as chat_window:
|
| 16 |
with gr.Row():
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
iface = gr.TabbedInterface(
|
| 39 |
+
[chat_window,supply_chain_view],
|
| 40 |
["Chat","Settings"],
|
| 41 |
title="MiMinions.ai",
|
| 42 |
css="footer {visibility: hidden}")
|
last_audio.mp3
DELETED
|
Binary file (382 kB)
|
|
|
supplier.py
CHANGED
|
@@ -11,46 +11,16 @@ OPENAI_CLIENT = OpenAI()
|
|
| 11 |
# aws_access_key_id = os.environ.get("AWS_ACCESS_KEY_ID")
|
| 12 |
# aws_secret_access_key = os.environ.get("AWS_SECRET_ACCESS_KEY")
|
| 13 |
|
| 14 |
-
sys_msg = [{
|
| 15 |
-
"role": "system",
|
| 16 |
-
"content": "Hi, I'm a chatbot! Ask me a question."
|
| 17 |
-
}]
|
| 18 |
-
|
| 19 |
App_state = {
|
| 20 |
"messages":[],
|
| 21 |
"sys_msg":[{
|
| 22 |
"role": "system",
|
| 23 |
-
"content": "Hi, I'm a
|
| 24 |
}],
|
| 25 |
"language":"en",
|
| 26 |
-
|
| 27 |
-
"voice":"Joanna",
|
| 28 |
}
|
| 29 |
|
| 30 |
-
# setup the polly client
|
| 31 |
-
# polly_client = boto3.client(
|
| 32 |
-
# "polly", # the service we want to use
|
| 33 |
-
# aws_access_key_id=aws_access_key_id,
|
| 34 |
-
# aws_secret_access_key=aws_secret_access_key,
|
| 35 |
-
# region_name='us-east-1')
|
| 36 |
-
|
| 37 |
-
# def get_voices():
|
| 38 |
-
# return polly_client.describe_voices()["Voices"]
|
| 39 |
-
|
| 40 |
-
# # return the audio based on the text
|
| 41 |
-
# def text_to_audio(messages,voice="Joanna",sample_rate = 22050):
|
| 42 |
-
# text = messages[-1][1]
|
| 43 |
-
# response = polly_client.synthesize_speech(VoiceId=voice,
|
| 44 |
-
# OutputFormat='mp3',
|
| 45 |
-
# SampleRate=str(sample_rate),
|
| 46 |
-
# Text = text)
|
| 47 |
-
|
| 48 |
-
# buffer = response["AudioStream"].read()
|
| 49 |
-
# audio_stream = np.frombuffer(buffer,dtype=np.uint16)
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
# return sample_rate,audio_stream
|
| 53 |
-
|
| 54 |
def send_chat(text,messages=[]):
|
| 55 |
'''
|
| 56 |
send_chat function takes two arguments: text and messages
|
|
@@ -105,16 +75,12 @@ def translate(file_path):
|
|
| 105 |
return ""
|
| 106 |
|
| 107 |
def text_to_audio(chat_messages):
|
| 108 |
-
text = chat_messages[
|
| 109 |
-
print("content:",text)
|
| 110 |
-
print("type:",type(text))
|
| 111 |
response = OPENAI_CLIENT.audio.speech.create(
|
| 112 |
model="tts-1",
|
| 113 |
-
voice="
|
| 114 |
input=text,
|
| 115 |
|
| 116 |
)
|
| 117 |
|
| 118 |
-
response.
|
| 119 |
-
print(response)
|
| 120 |
-
# return response.
|
|
|
|
| 11 |
# aws_access_key_id = os.environ.get("AWS_ACCESS_KEY_ID")
|
| 12 |
# aws_secret_access_key = os.environ.get("AWS_SECRET_ACCESS_KEY")
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
App_state = {
|
| 15 |
"messages":[],
|
| 16 |
"sys_msg":[{
|
| 17 |
"role": "system",
|
| 18 |
+
"content": "Hi, I'm a Factory supply chain assistant! Ask me a question."
|
| 19 |
}],
|
| 20 |
"language":"en",
|
| 21 |
+
"voice":"nova",
|
|
|
|
| 22 |
}
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
def send_chat(text,messages=[]):
|
| 25 |
'''
|
| 26 |
send_chat function takes two arguments: text and messages
|
|
|
|
| 75 |
return ""
|
| 76 |
|
| 77 |
def text_to_audio(chat_messages):
|
| 78 |
+
text = chat_messages[-1][-1]
|
|
|
|
|
|
|
| 79 |
response = OPENAI_CLIENT.audio.speech.create(
|
| 80 |
model="tts-1",
|
| 81 |
+
voice=App_state["voice"],
|
| 82 |
input=text,
|
| 83 |
|
| 84 |
)
|
| 85 |
|
| 86 |
+
return response.content
|
|
|
|
|
|