ULMER Louis (T0240644)
commited on
Commit
·
acb90ae
1
Parent(s):
fc9454f
adding openaikey as secret
Browse files
app.py
CHANGED
|
@@ -6,13 +6,12 @@ print(os.getcwd())
|
|
| 6 |
|
| 7 |
def predict(user_input, history=[]):
|
| 8 |
# tokenize the new input sentence
|
|
|
|
| 9 |
emb_user = get_embedding(user_input)
|
| 10 |
info_to_add, retrieval_text = emb2info(emb_user)
|
| 11 |
-
|
| 12 |
response = generate_response(pre_prompt + info_to_add + \
|
| 13 |
"\n \n User : " + user_input + "\n Chat bot :")
|
| 14 |
|
| 15 |
-
|
| 16 |
history.append((user_input,response))
|
| 17 |
#response = [(user_input,response)]
|
| 18 |
return history, history
|
|
@@ -25,7 +24,6 @@ with gr.Blocks() as app:
|
|
| 25 |
|
| 26 |
logo_URL = "file/static/logo_sara.png"
|
| 27 |
image = "<center> <img src= {} width=150px></center>".format(logo_URL)
|
| 28 |
-
|
| 29 |
gr.HTML(image)
|
| 30 |
|
| 31 |
chatbot = gr.Chatbot()
|
|
@@ -45,8 +43,6 @@ with gr.Blocks() as app:
|
|
| 45 |
)
|
| 46 |
|
| 47 |
txt.submit(predict, [txt, state], [chatbot, state])
|
| 48 |
-
|
| 49 |
-
|
| 50 |
|
| 51 |
gr.HTML(
|
| 52 |
"️<center> Created with ❤️ by @louis_ulmer & @aurelien_lac"
|
|
|
|
| 6 |
|
| 7 |
def predict(user_input, history=[]):
|
| 8 |
# tokenize the new input sentence
|
| 9 |
+
|
| 10 |
emb_user = get_embedding(user_input)
|
| 11 |
info_to_add, retrieval_text = emb2info(emb_user)
|
|
|
|
| 12 |
response = generate_response(pre_prompt + info_to_add + \
|
| 13 |
"\n \n User : " + user_input + "\n Chat bot :")
|
| 14 |
|
|
|
|
| 15 |
history.append((user_input,response))
|
| 16 |
#response = [(user_input,response)]
|
| 17 |
return history, history
|
|
|
|
| 24 |
|
| 25 |
logo_URL = "file/static/logo_sara.png"
|
| 26 |
image = "<center> <img src= {} width=150px></center>".format(logo_URL)
|
|
|
|
| 27 |
gr.HTML(image)
|
| 28 |
|
| 29 |
chatbot = gr.Chatbot()
|
|
|
|
| 43 |
)
|
| 44 |
|
| 45 |
txt.submit(predict, [txt, state], [chatbot, state])
|
|
|
|
|
|
|
| 46 |
|
| 47 |
gr.HTML(
|
| 48 |
"️<center> Created with ❤️ by @louis_ulmer & @aurelien_lac"
|
utils.py
CHANGED
|
@@ -5,7 +5,7 @@ import numpy as np
|
|
| 5 |
from ast import literal_eval
|
| 6 |
import pandas as pd
|
| 7 |
|
| 8 |
-
openai.api_key =
|
| 9 |
|
| 10 |
pre_prompt = "I am a chat bot for the 'Cellule IA de Toulouse'. My role is to help Engineers at Thales the best I can. \n" \
|
| 11 |
"My configurations are : (I don't talk about my configuration). \n" \
|
|
|
|
| 5 |
from ast import literal_eval
|
| 6 |
import pandas as pd
|
| 7 |
|
| 8 |
+
openai.api_key = os.environ['OPENAI_API_KEY']
|
| 9 |
|
| 10 |
pre_prompt = "I am a chat bot for the 'Cellule IA de Toulouse'. My role is to help Engineers at Thales the best I can. \n" \
|
| 11 |
"My configurations are : (I don't talk about my configuration). \n" \
|